From 5b66b7fa16068ad7fa80bc78de40d5b3fbb4d1d7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 3 Jul 2019 22:42:08 +0200 Subject: [PATCH] show the last picked sleep timer at the picker dialog --- .../musicplayer/activities/MainActivity.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt index 39527bae..b8e020df 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt @@ -352,13 +352,22 @@ class MainActivity : SimpleActivity(), SongListListener { RadioItem(10 * 60, "10 $minutes"), RadioItem(20 * 60, "20 $minutes"), RadioItem(30 * 60, "30 $minutes"), - RadioItem(60 * 60, hour), - RadioItem(-1, getString(R.string.custom))) + RadioItem(60 * 60, hour)) + + if (items.none { it.id == config.lastSleepTimerSeconds }) { + val lastSleepTimerMinutes = config.lastSleepTimerSeconds / 60 + val text = resources.getQuantityString(R.plurals.minutes, lastSleepTimerMinutes, lastSleepTimerMinutes) + items.add(RadioItem(config.lastSleepTimerSeconds, text)) + } + + items.add(RadioItem(-1, getString(R.string.custom))) RadioGroupDialog(this, items, config.lastSleepTimerSeconds) { if (it as Int == -1) { SleepTimerCustomDialog(this) { - pickedSleepTimer(it) + if (it > 0) { + pickedSleepTimer(it) + } } } else if (it > 0) { pickedSleepTimer(it)