make sure the selected default reminders are sorted properly

This commit is contained in:
tibbi 2018-09-22 11:19:59 +02:00
parent 89a6576a15
commit 3b4e89e7ba
1 changed files with 9 additions and 4 deletions

View File

@ -8,10 +8,7 @@ import android.text.TextUtils
import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog
import com.simplemobiletools.calendar.extensions.* import com.simplemobiletools.calendar.extensions.*
import com.simplemobiletools.calendar.helpers.CalDAVHandler import com.simplemobiletools.calendar.helpers.*
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.models.EventType import com.simplemobiletools.calendar.models.EventType
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.CustomIntervalPickerDialog import com.simplemobiletools.commons.dialogs.CustomIntervalPickerDialog
@ -81,6 +78,14 @@ class SettingsActivity : SimpleActivity() {
mStoredPrimaryColor = config.primaryColor 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() { private fun checkPrimaryColor() {
if (config.primaryColor != mStoredPrimaryColor) { if (config.primaryColor != mStoredPrimaryColor) {
dbHelper.getEventTypes { dbHelper.getEventTypes {