Skip to content

feat: add Quick Settings tile to start timer with last used duration - #51

Open
Xitee1 wants to merge 4 commits into
mainfrom
claude/android-quick-settings-tile-nxvxre
Open

feat: add Quick Settings tile to start timer with last used duration#51
Xitee1 wants to merge 4 commits into
mainfrom
claude/android-quick-settings-tile-nxvxre

Conversation

@Xitee1

@Xitee1 Xitee1 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an Android Quick Settings tile that starts the sleep timer with the last used duration directly from the QS panel, without opening the app.

  • New SleepTimerTileService (:app, next to the other platform entry points): a Hilt-injected TileService that dispatches the existing ACTION_START / ACTION_CANCEL service contract.
  • Last used duration = the persisted UserSettings.presetMinutes, which the dial already writes on every commit — no new state or setting needed.
  • Tile behavior:
    • Idle → inactive tile, subtitle shows the preset (e.g. "15 min"); tap starts the timer via startForegroundService.
    • Running → active tile, subtitle shows remaining minutes (updates live while the panel is open by observing the in-process TimerRepository StateFlow); tap cancels, mirroring the notification's Cancel action.
    • Fading out → active tile with a "Fading out" subtitle; tap cancels (restores volume via the service's existing cancel path).
  • If a cancel tap races the countdown's natural expiry, the service's existing stale-intent guard turns it into a clean stopSelf — no ForegroundServiceDidNotStartInTimeException.
  • Tile label/subtitle strings are localized in both values/ and values-de/.

Testing

  • CI (assembleDebug + lint) verifies the build — no Android SDK was available in the sandbox for a local build.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kk4QRUoCmfQgD6xgUE9Phn


Generated by Claude Code

claude and others added 4 commits July 14, 2026 17:59
Adds a Quick Settings tile that starts the sleep timer with the
persisted preset (the last dial-committed duration) directly from the
QS panel, without opening the app. While a timer is running the tile
shows the remaining minutes and a tap cancels it, mirroring the
notification's Cancel action.

The tile observes the in-process TimerRepository StateFlow while the
panel is open, so it stays in sync with the foreground service tick.
Tile strings are localized in both en and de.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4QRUoCmfQgD6xgUE9Phn
…settings-tile-nxvxre

# Conflicts:
#	app/src/main/AndroidManifest.xml
Rebuild the tap path: onClick now starts the service synchronously from
the preset cached by the listening collector, with an in-flight flag
against double-taps — no more cancellable DataStore read racing the
tile's destruction and the tap's FGS start exemption.

Add SleepTimerService.intent()/start()/cancel() companion helpers so all
five dispatch surfaces share one intent shape and start() owns the
ForegroundServiceStartNotAllowedException catch; drop the hand-rolled
builders in the tile, widget provider/renderer, notification manager,
and TimerViewModel.

Make cancelTimer's teardown NonCancellable so a second ACTION_CANCEL
tripping the stale-intent guard can no longer strand a phantom running
phase before the volume restore and IDLE write.

Fold the status into tile.label below API 29 (no subtitle there), reuse
app_name and widget_minutes instead of tile-private duplicates, document
that lock-screen tapping is deliberate, and correct the stale doc
comments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
An ACTION_QS_TILE_PREFERENCES intent filter on MainActivity makes the
system launch the app for the tile's long-press action; without one it
falls back to the App-info screen.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants