From 92b49808ced01843f7e49b92dd198d797f083a5a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 12 Mar 2019 10:22:32 +0100 Subject: [PATCH] show the reminder types only at caldav synced events --- .../calendar/pro/activities/EventActivity.kt | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index c68bee00c..0666a35b8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -154,21 +154,21 @@ class EventActivity : SimpleActivity() { event_reminder_1_type.setOnClickListener { showReminderTypePicker(mReminder1Type) { mReminder1Type = it - updateReminderTypeImage(event_reminder_1_type, mReminder1Type) + updateReminderTypeImage(event_reminder_1_type, mReminder1Minutes, mReminder1Type) } } event_reminder_2_type.setOnClickListener { showReminderTypePicker(mReminder2Type) { mReminder2Type = it - updateReminderTypeImage(event_reminder_2_type, mReminder2Type) + updateReminderTypeImage(event_reminder_2_type, mReminder2Minutes, mReminder2Type) } } event_reminder_3_type.setOnClickListener { showReminderTypePicker(mReminder3Type) { mReminder3Type = it - updateReminderTypeImage(event_reminder_3_type, mReminder3Type) + updateReminderTypeImage(event_reminder_3_type, mReminder3Minutes, mReminder3Type) } } @@ -588,12 +588,11 @@ class EventActivity : SimpleActivity() { updateReminder1Text() updateReminder2Text() updateReminder3Text() - updateReminderTypeTexts() + updateReminderTypeImages() } private fun updateReminder1Text() { event_reminder_1.text = getFormattedMinutes(mReminder1Minutes) - event_reminder_1_type.beVisibleIf(mReminder1Minutes != REMINDER_OFF) } private fun updateReminder2Text() { @@ -607,8 +606,6 @@ class EventActivity : SimpleActivity() { alpha = 1f } } - - event_reminder_2_type.beVisibleIf(mReminder2Minutes != REMINDER_OFF) } private fun updateReminder3Text() { @@ -622,8 +619,6 @@ class EventActivity : SimpleActivity() { alpha = 1f } } - - event_reminder_3_type.beVisibleIf(mReminder3Minutes != REMINDER_OFF) } private fun showReminderTypePicker(currentValue: Int, callback: (Int) -> Unit) { @@ -636,13 +631,14 @@ class EventActivity : SimpleActivity() { } } - private fun updateReminderTypeTexts() { - updateReminderTypeImage(event_reminder_1_type, mReminder1Type) - updateReminderTypeImage(event_reminder_2_type, mReminder2Type) - updateReminderTypeImage(event_reminder_3_type, mReminder3Type) + private fun updateReminderTypeImages() { + updateReminderTypeImage(event_reminder_1_type, mReminder1Minutes, mReminder1Type) + updateReminderTypeImage(event_reminder_2_type, mReminder2Minutes, mReminder2Type) + updateReminderTypeImage(event_reminder_3_type, mReminder3Minutes, mReminder3Type) } - private fun updateReminderTypeImage(view: ImageView, type: Int) { + private fun updateReminderTypeImage(view: ImageView, minutes: Int, type: Int) { + view.beVisibleIf(minutes != REMINDER_OFF && mEventCalendarId != STORED_LOCALLY_ONLY) val drawable = if (type == REMINDER_NOTIFICATION) R.drawable.ic_bell else R.drawable.ic_email val icon = resources.getColoredDrawableWithColor(drawable, config.textColor) view.setImageDrawable(icon) @@ -685,6 +681,7 @@ class EventActivity : SimpleActivity() { mEventCalendarId = it config.lastUsedCaldavCalendarId = it updateCurrentCalendarInfo(getCalendarWithId(calendars, it)) + updateReminderTypeImages() } } } else { @@ -836,9 +833,9 @@ class EventActivity : SimpleActivity() { val reminder3 = keys.getOrElse(2) { REMINDER_OFF } val types = sortedReminders.values.toList() - mReminder1Type = types.getOrElse(0) { REMINDER_NOTIFICATION } - mReminder2Type = types.getOrElse(1) { REMINDER_NOTIFICATION } - mReminder3Type = types.getOrElse(2) { REMINDER_NOTIFICATION } + mReminder1Type = if (mEventCalendarId == STORED_LOCALLY_ONLY) REMINDER_NOTIFICATION else types.getOrElse(0) { REMINDER_NOTIFICATION } + mReminder2Type = if (mEventCalendarId == STORED_LOCALLY_ONLY) REMINDER_NOTIFICATION else types.getOrElse(1) { REMINDER_NOTIFICATION } + mReminder3Type = if (mEventCalendarId == STORED_LOCALLY_ONLY) REMINDER_NOTIFICATION else types.getOrElse(2) { REMINDER_NOTIFICATION } config.apply { if (usePreviousEventReminders) {