feat(alarms): choose what the volume buttons do while ringing
A new setting in Settings > Alarms: while the ring screen shows, the volume buttons change the volume (the default, and what they did before), snooze, dismiss, or do nothing. It is app-wide, stored next to the clock defaults, and included in the backup; a backup without it restores "change the volume". A press is made without looking, so VolumeButtonPolicy keeps it from ending an alarm more finally than the ring screen would. Dismiss with a dismiss challenge set snoozes instead, so the challenge still stands. With no snoozes left, Snooze (and Dismiss behind a challenge) falls back to changing the volume, never to the engine's refused-snooze path, which dismisses. The key's snooze also asks the engine to keep ringing if the limit turns out to be reached after all (AlarmEngine.snooze's new dismissIfRefused). The ring screen decides whether a press is its own on key down and keeps that for the release, leaves the keys alone once another alarm has taken over the ring, and ignores a second snooze or dismiss while the first is still running. Only the ring screen handles the keys. While the ring is a heads-up over another app, a background app gets no key events, and the one way around that does not hold up: a remote-playback MediaSession whose VolumeProvider takes the keys. On Android 13 and later MediaSessionRecord.canHandleVolumeKey refuses such a session from an app without a MediaRouter2 routing session, which Clockula's would be, so on current Pixels the keys never reach it. Where it does work, it loses to whatever app is in front or played last, shows a cast-volume slider and a phantom media player, and takes media buttons while the alarm rings. AOSP DeskClock and BlackyHawky's Clock also handle the keys in their alarm activity only. ARCHITECTURE.md records the limitation. Fixes #18
This commit is contained in:
1 parent
3f431a7f32
commit
94f09e9e5a
22 files changed
+598
-20
No files matched your search
@@ -297,6 +297,13 @@
|
||||
<string name="settings_section_alarms">Alarms</string>
|
||||
<string name="settings_alarms_subtitle">Sound, snooze and dismiss for new alarms</string>
|
||||
<string name="settings_alarm_defaults_hint">New alarms start with these. Each alarm can still change them in its editor.</string>
|
||||
<!-- #18: what the volume buttons do while an alarm rings -->
|
||||
<string name="settings_volume_buttons">Volume buttons while ringing</string>
|
||||
<string name="settings_volume_buttons_hint">Applies to every alarm while its ring screen is showing. With a dismiss challenge set, Dismiss snoozes instead, so the challenge still has to be done. When a snooze is called for but none are left, the buttons change the volume instead and the alarm keeps ringing.</string>
|
||||
<string name="volume_buttons_control_volume">Change the volume</string>
|
||||
<string name="volume_buttons_snooze">Snooze</string>
|
||||
<string name="volume_buttons_dismiss">Dismiss</string>
|
||||
<string name="volume_buttons_nothing">Do nothing</string>
|
||||
<string name="settings_section_timers">Timers</string>
|
||||
<string name="settings_timers_sound_subtitle">Sound for new timers</string>
|
||||
<string name="settings_timer_sound_hint">New timers ring with this sound. Each timer can still change it in its editor.</string>
|
||||
|
||||
Reference in new issue
Block a user