From 82eb63ca6910e1c6c50a6d2e6891961c836a8767 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 2 Jan 2017 23:16:29 +0100 Subject: [PATCH] fix default reminder value --- .../calendar/activities/SettingsActivity.kt | 14 ++++++++++---- .../calendar/helpers/Constants.kt | 6 +++--- 2 files changed, 13 insertions(+), 7 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 c07d30ab4..5b75c6a8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -10,9 +10,7 @@ import android.view.View import android.widget.AdapterView import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.beVisibleIf -import com.simplemobiletools.calendar.helpers.DAY_MINS -import com.simplemobiletools.calendar.helpers.HOUR_MINS -import com.simplemobiletools.calendar.helpers.REMINDER_CUSTOM +import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.commons.extensions.* import kotlinx.android.synthetic.main.activity_settings.* @@ -110,13 +108,21 @@ class SettingsActivity : SimpleActivity() { settings_custom_reminder_holder.visibility = View.GONE } - config.defaultReminderType = itemIndex + config.defaultReminderType = getDefaultReminderValue(itemIndex) } isInitialSetup = false } } } + private fun getDefaultReminderValue(index: Int): Int { + return when (index) { + 0 -> REMINDER_OFF + 1 -> REMINDER_AT_START + else -> REMINDER_CUSTOM + } + } + private fun saveReminder() { val value = custom_reminder_value.value val multiplier = when (custom_reminder_other_period.selectedItemPosition) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index 95e71cc93..7b01cb318 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -14,9 +14,9 @@ val MONTHLY_VIEW = 1 val YEARLY_VIEW = 2 val EVENTS_LIST_VIEW = 3 -val REMINDER_OFF = -1 -val REMINDER_AT_START = 0 -val REMINDER_CUSTOM = 1 +val REMINDER_OFF = 0 +val REMINDER_AT_START = 1 +val REMINDER_CUSTOM = 2 val DAY = 86400 val WEEK = 604800