Add update notification/reminder for v2
This commit is contained in:
1 parent
f1ba4f45ff
commit
2115d69ce2
5 files changed
+42
-10
No files matched your search
+30
-2
@@ -96,12 +96,25 @@ static char *s_options_under[2];
|
||||
|
||||
static void push_setter_window();
|
||||
|
||||
static void push_status_window(StatusWindowPurpose purpose);
|
||||
|
||||
static void click_handler_disable_tutorial(void *recognizer, void *ctx) {
|
||||
settings.TutorialEnabled = false;
|
||||
persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
|
||||
window_stack_pop_all(true);
|
||||
}
|
||||
|
||||
static void click_handler_disable_update_notification(void *recognizer, void *ctx) {
|
||||
persist_write_bool(STORAGE_KEY_UPDATE_NOTIFICATION_DISABLED, true);
|
||||
window_stack_pop(true);
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
}
|
||||
|
||||
static void click_handler_skip_update_notification(void *recognizer, void *ctx) {
|
||||
window_stack_pop(true);
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
}
|
||||
|
||||
static void click_handler_push_setter(void *recognizer, void *ctx) {
|
||||
s_highlight_pos = 0;
|
||||
s_skip_current_day = true; // setting the next alarm should assume the user meant tomorrow
|
||||
@@ -139,6 +152,11 @@ static void status_math_failure_click_config_provider(void *ctx) {
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, click_handler_retry);
|
||||
}
|
||||
|
||||
static void status_update_notification_click_config_provider(void *ctx) {
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, click_handler_skip_update_notification);
|
||||
window_single_click_subscribe(BUTTON_ID_BACK, click_handler_disable_update_notification);
|
||||
}
|
||||
|
||||
static void status_window_load(StatusWindowPurpose purpose) {
|
||||
Layer *window_layer = window_get_root_layer(s_status_window);
|
||||
s_status_txt_layer = text_layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||
@@ -164,12 +182,17 @@ static void status_window_load(StatusWindowPurpose purpose) {
|
||||
case STATUS_MATH_FAILURE:
|
||||
text_layer_set_text(s_status_txt_layer, "Incorrect equation.\nTry again!");
|
||||
window_set_click_config_provider(s_status_window, status_math_failure_click_config_provider);
|
||||
break;
|
||||
case STATUS_UPDATE_NOTIFICATION:
|
||||
text_layer_set_text(s_status_txt_layer, "IMPORTANT - READ!!\nTrigalarm will be updated to v2 (w/breaking changes) on Dec 1 2026. See store description for info.\n\nPress SELECT to continue or BACK to disable this notification (and continue).");
|
||||
window_set_click_config_provider(s_status_window, status_update_notification_click_config_provider);
|
||||
}
|
||||
text_layer_set_background_color(s_status_txt_layer, GColorClear);
|
||||
layer_set_frame(text_layer_get_layer(s_status_txt_layer), GRect(0, (PBL_DISPLAY_HEIGHT / 2) - (text_layer_get_content_size(s_status_txt_layer).h / 2), PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||
text_layer_set_text_alignment(s_status_txt_layer, GTextAlignmentCenter);
|
||||
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_status_txt_layer));
|
||||
text_layer_enable_screen_text_flow_and_paging(s_status_txt_layer, 3);
|
||||
}
|
||||
|
||||
static void status_window_unload() {
|
||||
@@ -462,12 +485,17 @@ static void alarm_select_hold_handler(void *recognizer, void *ctx) {
|
||||
// set main alarm if the awareness alarm was solved within time limit
|
||||
tick_timer_service_unsubscribe(); // alarm is fully disarmed - prevent stimulus in confirmation window
|
||||
if (schedule_alarm(WAKE_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
if (!persist_read_bool(STORAGE_KEY_UPDATE_NOTIFICATION_DISABLED)) {
|
||||
push_status_window(STATUS_UPDATE_NOTIFICATION);
|
||||
} else {
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// otherwise, set awareness alarm and exit
|
||||
WakeupReason alarm_reason = s_alarm_reason;
|
||||
if (schedule_alarm(WAKE_AWARENESS_ALARM)) {
|
||||
if (settings.TutorialEnabled && (s_alarm_reason == WAKE_MAIN_ALARM || s_alarm_reason == WAKE_RECOVERY_MAIN_ALARM)) {
|
||||
if (settings.TutorialEnabled && (alarm_reason == WAKE_MAIN_ALARM || alarm_reason == WAKE_RECOVERY_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_MAIN_TUTORIAL);
|
||||
} else {
|
||||
window_stack_pop_all(true);
|
||||
|
||||
+2
-1
@@ -5,5 +5,6 @@ typedef enum
|
||||
STATUS_MAIN_TUTORIAL = 0,
|
||||
STATUS_CONFIRMATION = 1,
|
||||
STATUS_SET_FAILURE = 2,
|
||||
STATUS_MATH_FAILURE = 3
|
||||
STATUS_MATH_FAILURE = 3,
|
||||
STATUS_UPDATE_NOTIFICATION = 4
|
||||
} StatusWindowPurpose;
|
||||
@@ -9,6 +9,7 @@
|
||||
#define STORAGE_KEY_ALARM_HOUR 0
|
||||
#define STORAGE_KEY_ALARM_MINUTE 1
|
||||
#define STORAGE_KEY_PAVLOK_INTENSITY 2
|
||||
#define STORAGE_KEY_UPDATE_NOTIFICATION_DISABLED 3
|
||||
|
||||
typedef struct AppSettings {
|
||||
bool TutorialEnabled;
|
||||
|
||||
Reference in new issue
Block a user