use a constant at handling the default start time
This commit is contained in:
parent
40783684db
commit
42135f9b5b
3 changed files with 7 additions and 5 deletions
|
@ -572,13 +572,13 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupDefaultStartTime() {
|
||||
updateDefaultStartTimeText()
|
||||
settings_default_start_time_holder.setOnClickListener {
|
||||
val currentDefaultTime = if (config.defaultStartTime == -1) -1 else 0
|
||||
val currentDefaultTime = if (config.defaultStartTime == DEFAULT_START_TIME_NEXT_FULL_HOUR) DEFAULT_START_TIME_NEXT_FULL_HOUR else 0
|
||||
val items = ArrayList<RadioItem>()
|
||||
items.add(RadioItem(-1, getString(R.string.next_full_hour)))
|
||||
items.add(RadioItem(DEFAULT_START_TIME_NEXT_FULL_HOUR, getString(R.string.next_full_hour)))
|
||||
items.add(RadioItem(0, getString(R.string.other_time)))
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, currentDefaultTime) {
|
||||
if (it as Int == -1) {
|
||||
if (it as Int == DEFAULT_START_TIME_NEXT_FULL_HOUR) {
|
||||
config.defaultStartTime = it
|
||||
updateDefaultStartTimeText()
|
||||
} else {
|
||||
|
@ -595,7 +595,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateDefaultStartTimeText() {
|
||||
if (config.defaultStartTime == -1) {
|
||||
if (config.defaultStartTime == DEFAULT_START_TIME_NEXT_FULL_HOUR) {
|
||||
settings_default_start_time.text = getString(R.string.next_full_hour)
|
||||
} else {
|
||||
val hours = config.defaultStartTime / 60
|
||||
|
|
|
@ -155,7 +155,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
set(lastVibrateOnReminder) = prefs.edit().putBoolean(LAST_VIBRATE_ON_REMINDER, lastVibrateOnReminder).apply()
|
||||
|
||||
var defaultStartTime: Int
|
||||
get() = prefs.getInt(DEFAULT_START_TIME, -1)
|
||||
get() = prefs.getInt(DEFAULT_START_TIME, DEFAULT_START_TIME_NEXT_FULL_HOUR)
|
||||
set(defaultStartTime) = prefs.edit().putInt(DEFAULT_START_TIME, defaultStartTime).apply()
|
||||
|
||||
var defaultDuration: Int
|
||||
|
|
|
@ -34,6 +34,8 @@ const val ITEM_EVENT = 0
|
|||
const val ITEM_EVENT_SIMPLE = 1
|
||||
const val ITEM_HEADER = 2
|
||||
|
||||
const val DEFAULT_START_TIME_NEXT_FULL_HOUR = -1
|
||||
|
||||
const val DAY = 86400
|
||||
const val WEEK = 604800
|
||||
const val MONTH = 2592001 // exact value not taken into account, Joda is used for adding months and years
|
||||
|
|
Loading…
Reference in a new issue