feat(timers): redo the add-timer flow as a full-screen calculator keypad
The Timers tab gets a full rewrite of how a timer is created, after Google Clock as the interaction reference (PLAN.md §11): - A dedicated TimerSetupScreen replaces the bottom-sheet/inline setup panel: a per-unit "00h 00m 00s" readout, a "00" key, and a big centred play button that never shifts position when Clear fades in beside it. - The keypad grows into the thumb zone on its own screen (92dp keys, pushed toward the bottom), and both it and the readout read bold. - Presets are dropped from the flow; TimerDurationEntry gains the matching domain support (hoursSegment/minutesSegment/secondsSegment, plusDoubleZero()). - An empty timer list shows the same readout/keypad/Start inline, in place of a "tap + to add" card — the keypad is still the empty state, just the redesigned one. - Timer cards are disconnected like the Alarms tab's own list, each with an instant, unconfirmed delete via a small corner button (re-creating a timer is faster than reading a confirmation dialog would be). - Hero readouts go bold app-wide to match: stopwatch, alarm rows, world clock, the ring screen, and both editors' length/time displays (ClockulaReadoutDefaults.Hero and matching call sites). Alongside: Android 16 Live Update support for the running-timer notification (POST_PROMOTED_NOTIFICATIONS, ProgressStyle), the live pill restyled to a plain tonal circle, the alarm dismiss-chooser dialog moved onto Floret's OptionCard, and small fixes to addTime's zero/negative-result handling, repeat-day selection and alarm routes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3ff74dc1d5
commit
d47220947b
48 files changed
+1102
-600
No files matched your search
@@ -166,6 +166,44 @@ class TimerRepositoryTest {
|
||||
assertThat(timer.snapshotAt(1_100.seconds, T0).remaining).isEqualTo(260.seconds)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `subtracting a minute rebases a running timer and preserves its configured duration`() = runTest {
|
||||
val id = startedTimer()
|
||||
elapsed.value = 1_100.seconds
|
||||
|
||||
repository.addTime(id, -1.minutes)
|
||||
|
||||
val timer = repository.find(id)!!
|
||||
assertThat(timer.state).isEqualTo(TimerState.RUNNING)
|
||||
assertThat(timer.snapshotAt(1_100.seconds, T0).remaining).isEqualTo(140.seconds)
|
||||
assertThat(timer.endsAtElapsedRealtime).isEqualTo(1_240.seconds)
|
||||
assertThat(timer.duration).isEqualTo(5.minutes)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `subtracting at or below a minute leaves the timer unchanged`() = runTest {
|
||||
val id = startedTimer()
|
||||
elapsed.value = 1_250.seconds
|
||||
val before = dao.stored.single()
|
||||
|
||||
repository.addTime(id, -1.minutes)
|
||||
|
||||
assertThat(dao.stored.single()).isEqualTo(before)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `subtracting from paused timer keeps it paused`() = runTest {
|
||||
val id = startedTimer()
|
||||
elapsed.value = 1_100.seconds
|
||||
repository.pause(id)
|
||||
|
||||
repository.addTime(id, -1.minutes)
|
||||
|
||||
val timer = repository.find(id)!!
|
||||
assertThat(timer.state).isEqualTo(TimerState.PAUSED)
|
||||
assertThat(timer.remaining).isEqualTo(140.seconds)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `adding time to a running timer whose end anchor has passed grants the whole extra`() = runTest {
|
||||
val id = startedTimer()
|
||||
|
||||
@@ -137,4 +137,23 @@ class TimerDurationEntryTest {
|
||||
Locale.setDefault(previous)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the per-unit segments keep their own leading zero unlike display`() {
|
||||
val entry = typed("130")
|
||||
|
||||
assertThat(listOf(entry.hoursSegment, entry.minutesSegment, entry.secondsSegment))
|
||||
.containsExactly("00", "01", "30")
|
||||
.inOrder()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the double-zero key shifts in two zeroes at once`() {
|
||||
assertThat(typed("5").plusDoubleZero()).isEqualTo(typed("500"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a double zero into an empty entry is ignored, same as a single leading zero`() {
|
||||
assertThat(TimerDurationEntry().plusDoubleZero()).isEqualTo(TimerDurationEntry())
|
||||
}
|
||||
}
|
||||
+1
@@ -58,6 +58,7 @@ class TimerNotificationPolicyTest {
|
||||
listOf(TimerNotificationAction.PAUSE, TimerNotificationAction.ADD_MINUTE) to
|
||||
subject.timer.endsAtWallClock,
|
||||
)
|
||||
assertThat(state.duration).isEqualTo(subject.timer.duration)
|
||||
}
|
||||
|
||||
/** §5.5 #3 */
|
||||
|
||||
@@ -14,6 +14,7 @@ class AlarmRoutesTest {
|
||||
@Test
|
||||
fun `the editor route carries the alarm's id`() {
|
||||
assertThat(AlarmRoutes.editor(7L)).isEqualTo("alarms/edit/7")
|
||||
assertThat(AlarmRoutes.newEditor(7L)).isEqualTo("alarms/edit/7?pickTime=true")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.jeanlucmakiola.clockula.ui.shell
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.clockula.stopwatch.StopwatchIntents
|
||||
import de.jeanlucmakiola.clockula.timer.TimerIntents
|
||||
import de.jeanlucmakiola.clockula.ui.alarms.AlarmRoutes
|
||||
import de.jeanlucmakiola.clockula.ui.timers.TimerRoutes
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@@ -150,6 +151,14 @@ class ShellNavigationTest {
|
||||
assertThat(ShellNavigation.destinationOf(TimerRoutes.editor(7L))).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `editors highlight their parent tab`() {
|
||||
assertThat(ShellNavigation.selectedDestinationOf(AlarmRoutes.EDITOR_PATTERN))
|
||||
.isEqualTo(ClockulaDestination.ALARMS)
|
||||
assertThat(ShellNavigation.selectedDestinationOf(TimerRoutes.EDITOR_PATTERN))
|
||||
.isEqualTo(ClockulaDestination.TIMERS)
|
||||
}
|
||||
|
||||
/** §5.15 #2 */
|
||||
@Test
|
||||
fun `the shell stands aside on back, leaving the timer editor to pop itself`() {
|
||||
|
||||
@@ -68,10 +68,10 @@ class TimerListRowsTest {
|
||||
|
||||
/** §5.11 #4 */
|
||||
@Test
|
||||
fun `an idle timer reads its configured length, full`() {
|
||||
fun `an idle timer reads its configured length, empty progress`() {
|
||||
val row = rows(listOf(idleTimer(duration = 5.minutes))).single()
|
||||
|
||||
assertThat(row.remaining to row.progress).isEqualTo(5.minutes to 1f)
|
||||
assertThat(row.remaining to row.progress).isEqualTo(5.minutes to 0f)
|
||||
}
|
||||
|
||||
/** §5.11 #5 */
|
||||
@@ -89,15 +89,15 @@ class TimerListRowsTest {
|
||||
|
||||
val row = rows(listOf(timer)).single()
|
||||
|
||||
assertThat(row.remaining to row.progress).isEqualTo(60.seconds to 0.2f)
|
||||
assertThat(row.remaining to row.progress).isEqualTo(60.seconds to 0.8f)
|
||||
}
|
||||
|
||||
/** §5.11 #7 */
|
||||
@Test
|
||||
fun `an expired timer reads empty`() {
|
||||
fun `an expired timer reads full progress`() {
|
||||
val row = rows(listOf(expiredTimer(duration = 5.minutes))).single()
|
||||
|
||||
assertThat(row.remaining to row.progress).isEqualTo(Duration.ZERO to 0f)
|
||||
assertThat(row.remaining to row.progress).isEqualTo(Duration.ZERO to 1f)
|
||||
}
|
||||
|
||||
/** §5.11 #8 */
|
||||
@@ -110,10 +110,10 @@ class TimerListRowsTest {
|
||||
|
||||
/** §5.11 #9 */
|
||||
@Test
|
||||
fun `a timer with more left than its length is clamped full`() {
|
||||
fun `a timer with more left than its length is clamped empty`() {
|
||||
val timer = runningTimerWith(left = 10.minutes, elapsedNow = now, duration = 5.minutes)
|
||||
|
||||
assertThat(rows(listOf(timer)).single().progress).isEqualTo(1f)
|
||||
assertThat(rows(listOf(timer)).single().progress).isEqualTo(0f)
|
||||
}
|
||||
|
||||
/** §5.11 #10 */
|
||||
|
||||
Reference in new issue
Block a user