Skip to content

Commit 14f5566

Browse files
asybajplexer
authored andcommitted
settings/settings_quiet_time: Add "Notifications" toggle option to Quiet Time settings
Add a new "Notifications" option to the Quiet Time settings menu that allows users to control whether notifications are displayed during DND. When "Notifications" is set to "Hide": - All notifications are suppressed during Quiet Time. - Analytics are still recorded for incoming notifications. - The notification window is not displayed. When "Notifications" is set to "Show" (default): - Notifications behave normally during Quiet Time. - Existing interruption mask settings still apply. This provides users with finer control over their Quiet Time experience, allowing them to completely silence notifications while still allowing important interruptions (calls, alarms) based on the interruption mask. Signed-off-by: Federico Bechini <[email protected]>
1 parent 65d6e15 commit 14f5566

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/fw/apps/system_apps/settings/settings_quiet_time.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum QuietTimeItem {
4141
QuietTimeItemWeekdayScheduled,
4242
QuietTimeItemWeekendScheduled,
4343
QuietTimeItemInterruptions,
44+
QuietTimeItemNotifications,
4445
QuietTimeItem_Count,
4546
};
4647

@@ -79,6 +80,36 @@ static const char *prv_get_dnd_mask_subtitle(void *i18n_key) {
7980
return title;
8081
}
8182

83+
static const DndNotificationMode s_dnd_notification_mode_cycle[] = {
84+
DndNotificationModeShow,
85+
DndNotificationModeHide,
86+
};
87+
88+
static DndNotificationMode prv_cycle_dnd_notification_mode(void) {
89+
DndNotificationMode mode = alerts_preferences_dnd_get_show_notifications();
90+
int index = 0;
91+
for (size_t i = 0; i < ARRAY_LENGTH(s_dnd_notification_mode_cycle); i++) {
92+
if (s_dnd_notification_mode_cycle[i] == mode) {
93+
index = i;
94+
break;
95+
}
96+
}
97+
mode = s_dnd_notification_mode_cycle[(index + 1) % ARRAY_LENGTH(s_dnd_notification_mode_cycle)];
98+
alerts_preferences_dnd_set_show_notifications(mode);
99+
return mode;
100+
}
101+
102+
static const char *prv_get_dnd_notifications_enable(void *i18n_key) {
103+
switch (alerts_preferences_dnd_get_show_notifications()) {
104+
case DndNotificationModeShow:
105+
return i18n_get("Show", i18n_key);
106+
case DndNotificationModeHide:
107+
return i18n_get("Hide", i18n_key);
108+
default:
109+
return "???";
110+
}
111+
}
112+
82113
///////////////////////////////
83114
// DND Action Menu Window
84115
///////////////////////////////
@@ -261,6 +292,10 @@ static void prv_draw_row_cb(SettingsCallbacks *context, GContext *ctx,
261292
title = i18n_get("Interruptions", data);
262293
strncpy(subtitle, prv_get_dnd_mask_subtitle(data), buffer_length);
263294
break;
295+
case QuietTimeItemNotifications:
296+
title = i18n_get("Notifications", data);
297+
strncpy(subtitle, prv_get_dnd_notifications_enable(data), buffer_length);
298+
break;
264299
default:
265300
WTF;
266301
}
@@ -287,6 +322,9 @@ static void prv_select_click_cb(SettingsCallbacks *context, uint16_t row) {
287322
case QuietTimeItemInterruptions:
288323
prv_cycle_dnd_mask();
289324
break;
325+
case QuietTimeItemNotifications:
326+
prv_cycle_dnd_notification_mode();
327+
break;
290328
default:
291329
WTF;
292330
}

src/fw/popups/notifications/notification_window.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,12 @@ static void prv_handle_notification_added_common(Uuid *id, NotificationType type
13271327
return;
13281328
}
13291329

1330+
if (do_not_disturb_is_active() &&
1331+
alerts_preferences_dnd_get_show_notifications() == DndNotificationModeHide) {
1332+
alerts_incoming_alert_analytics();
1333+
return;
1334+
}
1335+
13301336
NotificationWindowData *data = &s_notification_window_data;
13311337

13321338
// will fail and return early if already init'ed.

src/fw/services/normal/notifications/alerts_preferences.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ static AlertMask s_mask = AlertMaskAllOn;
3131
#define PREF_KEY_DND_INTERRUPTIONS_MASK "dndInterruptionsMask"
3232
static AlertMask s_dnd_interruptions_mask = AlertMaskAllOff;
3333

34+
#define PREF_KEY_DND_SHOW_NOTIFICATIONS "dndShowNotifications"
35+
static DndNotificationMode s_dnd_show_notifications = DndNotificationModeShow;
36+
3437
#define PREF_KEY_VIBE "vibe"
3538
static bool s_vibe_on_notification = true;
3639

@@ -263,6 +266,7 @@ void alerts_preferences_init(void) {
263266
RESTORE_PREF(PREF_KEY_DND_MANUALLY_ENABLED, s_do_not_disturb_manually_enabled);
264267
RESTORE_PREF(PREF_KEY_DND_SMART_ENABLED, s_do_not_disturb_smart_dnd_enabled);
265268
RESTORE_PREF(PREF_KEY_DND_INTERRUPTIONS_MASK, s_dnd_interruptions_mask);
269+
RESTORE_PREF(PREF_KEY_DND_SHOW_NOTIFICATIONS, s_dnd_show_notifications);
266270
RESTORE_PREF(PREF_KEY_LEGACY_DND_SCHEDULE, s_legacy_dnd_schedule);
267271
RESTORE_PREF(PREF_KEY_LEGACY_DND_SCHEDULE_ENABLED, s_legacy_dnd_schedule_enabled);
268272
RESTORE_PREF(s_dnd_schedule_keys[WeekdaySchedule].schedule_pref_key,
@@ -414,6 +418,15 @@ AlertMask alerts_preferences_dnd_get_mask(void) {
414418
return s_dnd_interruptions_mask;
415419
}
416420

421+
void alerts_preferences_dnd_set_show_notifications(DndNotificationMode mode) {
422+
s_dnd_show_notifications = mode;
423+
SET_PREF(PREF_KEY_DND_SHOW_NOTIFICATIONS, s_dnd_show_notifications);
424+
}
425+
426+
DndNotificationMode alerts_preferences_dnd_get_show_notifications(void) {
427+
return s_dnd_show_notifications;
428+
}
429+
417430
bool alerts_preferences_dnd_is_manually_enabled(void) {
418431
return s_do_not_disturb_manually_enabled;
419432
}

src/fw/services/normal/notifications/alerts_preferences.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <stdbool.h>
77

8+
#include "alerts_private.h"
9+
810
typedef enum FirstUseSource {
911
FirstUseSourceManualDNDActionMenu = 0,
1012
FirstUseSourceManualDNDSettingsMenu,
@@ -19,6 +21,18 @@ typedef enum MuteBitfield {
1921
MuteBitfield_Weekends = 0b01000001,
2022
} MuteBitfield;
2123

24+
typedef enum {
25+
DndNotificationModeHide = 0,
26+
DndNotificationModeShow = 1,
27+
} DndNotificationMode;
28+
29+
//! Set notification display mode when DND is active
30+
//! @param mode The display mode (Show or Hide)
31+
void alerts_preferences_dnd_set_show_notifications(DndNotificationMode mode);
32+
33+
//! @return The notification display mode when DND is active
34+
DndNotificationMode alerts_preferences_dnd_get_show_notifications(void);
35+
2236
//! Checks whether a given "first use" dialog has been shown and sets it as complete
2337
//! @param source The "first use" bit to check
2438
//! @return true if the dialog has already been shown, false otherwise

0 commit comments

Comments
 (0)