diff --git a/package.json b/package.json index 09810e3..228e254 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,11 @@ "name": "IMAGE_SNOOZE", "file": "images/action_bar_icon_snooze.png" }, + { + "type": "bitmap", + "name": "IMAGE_REPLAY", + "file": "images/action_bar_icon_replay.png" + }, { "type": "bitmap", "name": "IMAGE_DELETE", diff --git a/resources/images/action_bar_icon_replay.png b/resources/images/action_bar_icon_replay.png new file mode 100644 index 0000000..abea00f Binary files /dev/null and b/resources/images/action_bar_icon_replay.png differ diff --git a/src/main.c b/src/main.c index a38fb21..52d2ab7 100644 --- a/src/main.c +++ b/src/main.c @@ -143,6 +143,27 @@ static void popup_window_snooze_timer_callback(CountdownTimer *countdown_timer, +/* + * PopupWindow replay timer callback + * restarts the timer with its original duration + */ + +static void popup_window_replay_timer_callback(CountdownTimer *countdown_timer, void *context) { + countdown_timer_update(countdown_timer, countdown_timer_get_duration(countdown_timer), false); + countdown_timer_start(countdown_timer); + popup_window_pop(s_popup_window, true); + // show detail if not on top + if (!detail_window_get_topmost_window(s_detail_window)) { + detail_window_set_countdown_timer(s_detail_window, countdown_timer); + detail_window_push(s_detail_window, false); + } + detail_window_deep_refresh(s_detail_window); + // log activity + s_last_activity = countdown_timer_get_epoch_ms(); +} + + + /* * PopupWindow stop timer callback * cancels the current timer vibration sequence @@ -418,6 +439,7 @@ static void initialize(void) { // create pop-up window PopupWindowCallbacks popup_callbacks = { .up_click = popup_window_snooze_timer_callback, + .select_click = popup_window_replay_timer_callback, .down_click = popup_window_stop_timer_callback, }; s_popup_window = popup_window_create(); diff --git a/src/popup_window.c b/src/popup_window.c index 8757e93..6b63f71 100644 --- a/src/popup_window.c +++ b/src/popup_window.c @@ -73,7 +73,7 @@ struct PopupWindow { TextLayer *text; //< displays title text ActionBarLayer *action; //< optional action bar for dialogs PopupWindowCallbacks callbacks; //< callbacks for optional ActionBar - GBitmap *snooze_icon, *stop_icon; //< icons for ActionBar + GBitmap *snooze_icon, *stop_icon, *replay_icon; //< icons for ActionBar #ifndef PBL_PLATFORM_APLITE GDrawCommandSequence *draw_sequence; //< draw command sequence @@ -220,7 +220,7 @@ static void up_click_handler(ClickRecognizerRef recognizer, void *context) { /* * SELECT click handler callback * - * nothing yet... here for completeness + * replays the completed timer with its original duration */ static void select_click_handler(ClickRecognizerRef recognizer, void *context) { @@ -228,7 +228,7 @@ static void select_click_handler(ClickRecognizerRef recognizer, void *context) { if (popup_window->callbacks.select_click == NULL) { return; } - return popup_window->callbacks.select_click(context); + return popup_window->callbacks.select_click(popup_window->countdown_timer, context); } @@ -267,6 +267,7 @@ static void prv_window_load(Window* window){ // get window parameters popup_window->stop_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_DISMISS); popup_window->snooze_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SNOOZE); + popup_window->replay_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_REPLAY); // get window parameters Layer *root = window_get_root_layer(popup_window->window); @@ -293,6 +294,7 @@ static void prv_window_load(Window* window){ action_bar_layer_set_context(popup_window->action, popup_window); action_bar_layer_set_click_config_provider(popup_window->action, click_config_provider); action_bar_layer_set_icon(popup_window->action, BUTTON_ID_UP, popup_window->snooze_icon); + action_bar_layer_set_icon(popup_window->action, BUTTON_ID_SELECT, popup_window->replay_icon); action_bar_layer_set_icon(popup_window->action, BUTTON_ID_DOWN, popup_window->stop_icon); if (popup_window->action_visible) { @@ -313,6 +315,7 @@ static void prv_window_unload(Window* window){ window_destroy(popup_window->window); gbitmap_destroy(popup_window->snooze_icon); gbitmap_destroy(popup_window->stop_icon); + gbitmap_destroy(popup_window->replay_icon); #ifndef PBL_PLATFORM_APLITE if (popup_window->draw_sequence != NULL) { gdraw_command_sequence_destroy(popup_window->draw_sequence); diff --git a/src/popup_window.h b/src/popup_window.h index 639c516..35b96a4 100644 --- a/src/popup_window.h +++ b/src/popup_window.h @@ -69,7 +69,7 @@ typedef void (*PopupWindowUpClick)(CountdownTimer *countdown_timer, void *contex * called when the SELECT button is pressed */ -typedef void (*PopupWindowSelectClick)(void *context); +typedef void (*PopupWindowSelectClick)(CountdownTimer *countdown_timer, void *context);