Block alarm exits, add app glance, and fix wakeup being scheduled incorrectly
This commit is contained in:
+21
-2
@@ -42,6 +42,17 @@ static const GColor s_highlight_color = GColorMediumAquamarine;
|
|||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
|
static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *context) {
|
||||||
|
static char s_glance_buffer[11];
|
||||||
|
snprintf(s_glance_buffer, sizeof(s_glance_buffer), "Up @ %02d:%02d", s_setter_time.HourSet, s_setter_time.MinuteSet);
|
||||||
|
AppGlanceSlice slice = {
|
||||||
|
.expiration_time = time(NULL) + (7 * SECONDS_PER_DAY),
|
||||||
|
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
|
||||||
|
.layout.subtitle_template_string = s_glance_buffer,
|
||||||
|
};
|
||||||
|
app_glance_add_slice(session, slice);
|
||||||
|
}
|
||||||
|
|
||||||
static void setter_seconds_handler(struct tm *tick_time, TimeUnits units_changed) {
|
static void setter_seconds_handler(struct tm *tick_time, TimeUnits units_changed) {
|
||||||
struct tm now_tm = *tick_time;
|
struct tm now_tm = *tick_time;
|
||||||
|
|
||||||
@@ -131,8 +142,8 @@ static void setter_select_click_handler(void *recognizer, void *ctx) {
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm now_tm = *localtime(&now);
|
struct tm now_tm = *localtime(&now);
|
||||||
struct tm target_tm = now_tm;
|
struct tm target_tm = now_tm;
|
||||||
target_tm.tm_hour = s_setter_time.HourSet;
|
target_tm.tm_hour = s_setter_time.HourWIP;
|
||||||
target_tm.tm_min = s_setter_time.MinuteSet;
|
target_tm.tm_min = s_setter_time.MinuteWIP;
|
||||||
target_tm.tm_sec = 0;
|
target_tm.tm_sec = 0;
|
||||||
time_t target = mktime(&target_tm);
|
time_t target = mktime(&target_tm);
|
||||||
if (target <= now) {
|
if (target <= now) {
|
||||||
@@ -160,6 +171,9 @@ static void setter_select_click_handler(void *recognizer, void *ctx) {
|
|||||||
|
|
||||||
// move selection back to start
|
// move selection back to start
|
||||||
s_highlight_pos = 0;
|
s_highlight_pos = 0;
|
||||||
|
|
||||||
|
// set app glance
|
||||||
|
app_glance_reload(glance_reload_callback, NULL);
|
||||||
} else {
|
} else {
|
||||||
s_highlight_pos++;
|
s_highlight_pos++;
|
||||||
}
|
}
|
||||||
@@ -300,6 +314,10 @@ static void alarm_window_unload() {
|
|||||||
text_layer_destroy(s_alarm_txt_layer);
|
text_layer_destroy(s_alarm_txt_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void alarm_click_config_provider(void *ctx) {
|
||||||
|
window_single_click_subscribe(BUTTON_ID_BACK, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
s_window = window_create();
|
s_window = window_create();
|
||||||
|
|
||||||
@@ -308,6 +326,7 @@ static void init() {
|
|||||||
window_set_window_handlers(
|
window_set_window_handlers(
|
||||||
s_window,
|
s_window,
|
||||||
(WindowHandlers){.load = alarm_window_load, .unload = alarm_window_unload});
|
(WindowHandlers){.load = alarm_window_load, .unload = alarm_window_unload});
|
||||||
|
window_set_click_config_provider(s_window, alarm_click_config_provider);
|
||||||
window_stack_push(s_window, false);
|
window_stack_push(s_window, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user