refactor(settings): remove the unused default timer duration
Settings > Timers offered a "Default duration", but nothing that creates a timer ever read it: the keypad starts empty. The row, its preference, ClockDefaults.timerDuration and the backup field are gone, and the screen's hint and the hub's subtitle now only speak of the sound. Backups no longer write default_timer_duration_millis. Older files that carry it still import, since the codec ignores unknown keys. Closes #5
This commit is contained in:
1 parent
face2edb8d
commit
cac5b2dfca
18 files changed
+55
-101
No files matched your search
@@ -58,7 +58,6 @@ class BackupCodecTest {
|
||||
alarmRingtoneUri = "content://media/1",
|
||||
timerRingtoneUri = "content://media/2",
|
||||
dismissChallenge = DismissChallenge.HOLD,
|
||||
timerDuration = 10.minutes,
|
||||
homeZoneId = "America/New_York",
|
||||
),
|
||||
timerPresets = listOf(1.minutes, 2.minutes, 10.minutes),
|
||||
@@ -113,6 +112,32 @@ class BackupCodecTest {
|
||||
assertThat(decoded).isInstanceOf(BackupResult.Success::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an older file with the retired default timer duration still imports`() {
|
||||
val json = """
|
||||
{
|
||||
"format": "clockula-backup",
|
||||
"version": 1,
|
||||
"exportedAt": 0,
|
||||
"alarms": [],
|
||||
"timers": [],
|
||||
"worldClocks": [],
|
||||
"settings": { "default_snooze_minutes": 7, "default_timer_duration_millis": 600000 }
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val decoded = BackupCodec.decode(json)
|
||||
|
||||
assertThat(decoded).isInstanceOf(BackupResult.Success::class.java)
|
||||
val defaults = (decoded as BackupResult.Success).content.settings.defaults
|
||||
assertThat(defaults).isEqualTo(ClockDefaults(snoozeMinutes = 7))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the retired default timer duration is no longer written`() {
|
||||
assertThat(BackupCodec.encode(sampleContent())).doesNotContain("default_timer_duration_millis")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `wrong format rejects the whole file`() {
|
||||
val decoded = BackupCodec.decode(minimalDocument(format = "something-else"))
|
||||
|
||||
@@ -20,7 +20,6 @@ import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
* The clock defaults every alarm and timer inherits. A value the user could
|
||||
@@ -53,7 +52,6 @@ class ClockPrefsTest {
|
||||
prefs.setAlarmRingtoneUri("content://a")
|
||||
prefs.setTimerRingtoneUri("content://t")
|
||||
prefs.setDismissChallenge(DismissChallenge.HOLD)
|
||||
prefs.setTimerDuration(90.seconds)
|
||||
prefs.setHomeZoneId("Europe/Berlin")
|
||||
|
||||
assertThat(prefs.defaults.first()).isEqualTo(
|
||||
@@ -65,7 +63,6 @@ class ClockPrefsTest {
|
||||
alarmRingtoneUri = "content://a",
|
||||
timerRingtoneUri = "content://t",
|
||||
dismissChallenge = DismissChallenge.HOLD,
|
||||
timerDuration = 90.seconds,
|
||||
homeZoneId = "Europe/Berlin",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.RegisterExtension
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
|
||||
/**
|
||||
* The real [SettingsViewModel] over the real [de.jeanlucmakiola.clockula.data.prefs.SettingsPrefs]
|
||||
@@ -120,7 +119,6 @@ class SettingsViewModelTest {
|
||||
viewModel.onSnoozeLimitChanged(2)
|
||||
viewModel.onVolumeRampChanged(30)
|
||||
viewModel.onDismissChallengeChanged(DismissChallenge.MATH)
|
||||
viewModel.onTimerDurationChanged(20.minutes)
|
||||
advanceUntilIdle()
|
||||
|
||||
val defaults = (viewModel.state.value as SettingsUiState.Loaded).defaults
|
||||
@@ -129,7 +127,6 @@ class SettingsViewModelTest {
|
||||
assertThat(defaults.snoozeLimit).isEqualTo(2)
|
||||
assertThat(defaults.volumeRampSeconds).isEqualTo(30)
|
||||
assertThat(defaults.dismissChallenge).isEqualTo(DismissChallenge.MATH)
|
||||
assertThat(defaults.timerDuration).isEqualTo(20.minutes)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user