Skip to content

Commit 3d18ac0

Browse files
srwarehamclaude
andcommitted
fw/notification: quiet time auto dismiss option
Introduces new auto dismiss option to quiet time notifications setting. Replaces the binary show/hide toggle with a tristate: "On - Persistent" notifications show and do not auto dismiss (default) "On - Auto Dismiss" notifications show and auto dismiss "Off" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sean Wareham <ebriouscoding@gmail.com>
1 parent cb84939 commit 3d18ac0

4 files changed

Lines changed: 49 additions & 33 deletions

File tree

include/pbl/services/notifications/alerts_preferences.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ void alerts_preferences_dnd_set_mute_speaker(bool enable);
5454
//! @return Whether the speaker is muted while DND is active
5555
bool alerts_preferences_dnd_get_mute_speaker(void);
5656

57+
//! Set whether notifications should auto-dismiss even when DND is active.
58+
//! When false (default), notifications stay on screen during DND.
59+
//! @param enable true to allow auto-dismiss during DND, false to suppress it
60+
void alerts_preferences_dnd_set_auto_dismiss(bool enable);
61+
62+
//! @return Whether auto-dismiss is allowed while DND is active
63+
bool alerts_preferences_dnd_get_auto_dismiss(void);
64+
5765
//! Set the always-on speaker mute. When set, the speaker is silenced
5866
//! regardless of DND state.
5967
//! @param muted true to mute the speaker, false to allow audio

src/fw/apps/system/settings/quiet_time.c

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,6 @@ static const char *prv_get_dnd_mask_subtitle(void *i18n_key) {
109109
return title;
110110
}
111111

112-
static const DndNotificationMode s_dnd_notification_mode_cycle[] = {
113-
DndNotificationModeShow,
114-
DndNotificationModeHide,
115-
};
116-
117-
static DndNotificationMode prv_cycle_dnd_notification_mode(void) {
118-
DndNotificationMode mode = alerts_preferences_dnd_get_show_notifications();
119-
int index = 0;
120-
for (size_t i = 0; i < ARRAY_LENGTH(s_dnd_notification_mode_cycle); i++) {
121-
if (s_dnd_notification_mode_cycle[i] == mode) {
122-
index = i;
123-
break;
124-
}
125-
}
126-
mode = s_dnd_notification_mode_cycle[(index + 1) % ARRAY_LENGTH(s_dnd_notification_mode_cycle)];
127-
alerts_preferences_dnd_set_show_notifications(mode);
128-
return mode;
129-
}
130-
131-
static const char *prv_get_dnd_notifications_enable(void *i18n_key) {
132-
switch (alerts_preferences_dnd_get_show_notifications()) {
133-
case DndNotificationModeShow:
134-
return i18n_get("Show", i18n_key);
135-
case DndNotificationModeHide:
136-
return i18n_get("Hide", i18n_key);
137-
default:
138-
return "???";
139-
}
140-
}
141112

142113
static void prv_get_dnd_time(DoNotDisturbScheduleType type, char *time_string, const uint8_t len) {
143114
DoNotDisturbSchedule schedule;
@@ -357,6 +328,28 @@ static void prv_schedule_submenu_push(void) {
357328
app_window_stack_push(window, true /* animated */);
358329
}
359330

331+
static const char *prv_get_dnd_notifications_subtitle(void *i18n_key) {
332+
if (alerts_preferences_dnd_get_show_notifications() == DndNotificationModeHide) {
333+
return i18n_get("Off", i18n_key);
334+
}
335+
if (alerts_preferences_dnd_get_auto_dismiss()) {
336+
return i18n_get("On - Auto Dismiss", i18n_key);
337+
}
338+
return i18n_get("On - Persistent", i18n_key);
339+
}
340+
341+
static void prv_cycle_dnd_notifications(void) {
342+
if (alerts_preferences_dnd_get_show_notifications() == DndNotificationModeHide) {
343+
alerts_preferences_dnd_set_show_notifications(DndNotificationModeShow);
344+
alerts_preferences_dnd_set_auto_dismiss(false);
345+
} else if (!alerts_preferences_dnd_get_auto_dismiss()) {
346+
alerts_preferences_dnd_set_auto_dismiss(true);
347+
} else {
348+
alerts_preferences_dnd_set_show_notifications(DndNotificationModeHide);
349+
alerts_preferences_dnd_set_auto_dismiss(false);
350+
}
351+
}
352+
360353
///////////////////////////////
361354
// Backlight sub-menu (touch boards)
362355
///////////////////////////////
@@ -453,7 +446,7 @@ static void prv_draw_row_cb(SettingsCallbacks *context, GContext *ctx,
453446
break;
454447
case QuietTimeItemNotifications:
455448
title = i18n_get("Notifications", data);
456-
subtitle = prv_get_dnd_notifications_enable(data);
449+
subtitle = prv_get_dnd_notifications_subtitle(data);
457450
break;
458451
#ifdef CONFIG_TOUCH
459452
case QuietTimeItemBacklight:
@@ -491,7 +484,7 @@ static void prv_select_click_cb(SettingsCallbacks *context, uint16_t row) {
491484
prv_cycle_dnd_mask();
492485
break;
493486
case QuietTimeItemNotifications:
494-
prv_cycle_dnd_notification_mode();
487+
prv_cycle_dnd_notifications();
495488
break;
496489
#ifdef CONFIG_TOUCH
497490
case QuietTimeItemBacklight:

src/fw/popups/notifications/notification_window.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,9 @@ T_STATIC LayoutLayer *prv_get_layout_handler(SwapLayer *swap_layer, int8_t rel_p
558558

559559
static bool prv_should_pop_due_to_inactivity(void) {
560560
// If not a modal, then we are in the notification history app and the pop timer makes no sense
561-
// If in DND mode we want to keep the notifications on the screen
562-
return s_in_use && s_notification_window_data.is_modal && !do_not_disturb_is_active();
561+
// If in DND mode we keep notifications on screen unless the user opted into auto-dismiss
562+
return s_in_use && s_notification_window_data.is_modal &&
563+
(!do_not_disturb_is_active() || alerts_preferences_dnd_get_auto_dismiss());
563564
}
564565

565566
static void prv_pop_timer_callback(void *data) {

src/fw/services/notifications/alerts_preferences.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static bool s_dnd_touch_backlight = true;
4343
#define PREF_KEY_DND_MUTE_SPEAKER "dndMuteSpeaker"
4444
static bool s_dnd_mute_speaker = false;
4545

46+
#define PREF_KEY_DND_AUTO_DISMISS "dndAutoDismiss"
47+
static bool s_dnd_auto_dismiss = false;
48+
4649
#define PREF_KEY_SPEAKER_MUTED "speakerMuted"
4750
static bool s_speaker_muted = false;
4851

@@ -334,6 +337,7 @@ void alerts_preferences_init(void) {
334337
RESTORE_PREF(PREF_KEY_NOTIF_DESIGN_STYLE, s_notification_alternative_design);
335338
RESTORE_PREF(PREF_KEY_NOTIF_VIBE_DELAY, s_notification_vibe_delay);
336339
RESTORE_PREF(PREF_KEY_NOTIF_BACKLIGHT, s_notification_backlight);
340+
RESTORE_PREF(PREF_KEY_DND_AUTO_DISMISS, s_dnd_auto_dismiss);
337341
#undef RESTORE_PREF
338342

339343
prv_migrate_legacy_dnd_schedule(&file);
@@ -552,6 +556,15 @@ bool alerts_preferences_dnd_get_mute_speaker(void) {
552556
return s_dnd_mute_speaker;
553557
}
554558

559+
void alerts_preferences_dnd_set_auto_dismiss(bool enable) {
560+
s_dnd_auto_dismiss = enable;
561+
SET_PREF(PREF_KEY_DND_AUTO_DISMISS, s_dnd_auto_dismiss);
562+
}
563+
564+
bool alerts_preferences_dnd_get_auto_dismiss(void) {
565+
return s_dnd_auto_dismiss;
566+
}
567+
555568
bool alerts_preferences_dnd_is_manually_enabled(void) {
556569
return s_do_not_disturb_manually_enabled;
557570
}
@@ -668,6 +681,7 @@ void alerts_preferences_handle_blob_db_event(PebbleBlobDBEvent *event) {
668681
RELOAD_IF_MATCH(PREF_KEY_DND_TOUCH_BACKLIGHT, s_dnd_touch_backlight);
669682
RELOAD_IF_MATCH(PREF_KEY_DND_MUTE_SPEAKER, s_dnd_mute_speaker);
670683
RELOAD_IF_MATCH(PREF_KEY_SPEAKER_MUTED, s_speaker_muted);
684+
RELOAD_IF_MATCH(PREF_KEY_DND_AUTO_DISMISS, s_dnd_auto_dismiss);
671685

672686
#undef RELOAD_IF_MATCH
673687

0 commit comments

Comments
 (0)