From 3b4e89e7baabead116eadbea2c79b945db34bae2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 22 Sep 2018 11:19:59 +0200 Subject: [PATCH] make sure the selected default reminders are sorted properly --- .../calendar/activities/SettingsActivity.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index f231627a1..c0e6f56d4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -8,10 +8,7 @@ import android.text.TextUtils import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog import com.simplemobiletools.calendar.extensions.* -import com.simplemobiletools.calendar.helpers.CalDAVHandler -import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE -import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM -import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL +import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.models.EventType import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.CustomIntervalPickerDialog @@ -81,6 +78,14 @@ class SettingsActivity : SimpleActivity() { mStoredPrimaryColor = config.primaryColor } + override fun onStop() { + super.onStop() + val reminders = sortedSetOf(config.defaultReminder1, config.defaultReminder2, config.defaultReminder3).filter { it != REMINDER_OFF } + config.defaultReminder1 = reminders.getOrElse(0) { REMINDER_OFF } + config.defaultReminder2 = reminders.getOrElse(1) { REMINDER_OFF } + config.defaultReminder3 = reminders.getOrElse(2) { REMINDER_OFF } + } + private fun checkPrimaryColor() { if (config.primaryColor != mStoredPrimaryColor) { dbHelper.getEventTypes {