Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Close if no interaction when woken up
Browse files Browse the repository at this point in the history
The app now closes if the user does not touch the watch within 30 seconds of it waking up and reminding them to breathe. This prevents the app from wasting battery from drawing and redrawing the PDC for hours on end if the user did not touch the watch (which was what it did before).
  • Loading branch information
aaronhktan committed Nov 20, 2016
1 parent 0eb812d commit 61be74c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
"watchface": false
}
},
"version": "0.25.0"
"version": "0.27.0"
}
10 changes: 10 additions & 0 deletions src/c/reminder_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ static ActionMenuLevel *s_root_level;
static int s_min_to_breathe;
static Layer *s_canvas_layer;
static TextLayer *s_text_layer;
static AppTimer *s_close_timer;
static GDrawCommandSequence *s_command_seq;
GColor random_color;

int s_index = 0;

// Closes app
static void close_app() {
window_stack_pop_all(true);
}

// Finds and displays the next frame in PDC
static void next_frame_handler(void *context) {
layer_mark_dirty(s_canvas_layer);
Expand Down Expand Up @@ -56,6 +62,7 @@ static void canvas_update_proc(Layer *layer, GContext *ctx) {
static void action_performed_callback(ActionMenu *action_menu, const ActionMenuItem *action, void *context) {
// Some amount of minutes was selected; find which one and pass to breathe_window to start
s_min_to_breathe = (int)action_menu_item_get_action_data(action);
app_timer_cancel(s_close_timer);
window_stack_remove(s_reminder_window, false);
breathe_window_push(s_min_to_breathe);
}
Expand Down Expand Up @@ -120,6 +127,9 @@ static void reminder_window_load(Window *window) {
layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

init_action_menu();

// Start timer to close the app after 30 seconds if the user doesn't respond as to not waste battery
s_close_timer = app_timer_register(30000, close_app, NULL);
}

// DESTROY ALL THE THINGS (hopefully)
Expand Down
6 changes: 5 additions & 1 deletion src/pkjs/config-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "Esta es la página de ajustes para la app Breathe. Estás usando la version 0.2.5 de la app.",
"defaultValue": "Esta es la página de ajustes para la app Breathe. Estás usando la version 0.2.7 de la app.",
},
{
"type": "section",
Expand Down Expand Up @@ -119,6 +119,10 @@ module.exports = [
}
]
},
{
"type": "text",
"defaultValue": "<em>&nbsp;&nbsp;Muchas gracias a los probadores beta: <br>&nbsp;Ayush Gupta, y David Voicu</em>",
},
{
"type": "submit",
"defaultValue": "Guardar mis ajustes"
Expand Down
6 changes: 5 additions & 1 deletion src/pkjs/config-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 0.2.5 de l'app.",
"defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 0.2.7 de l'app.",
},
{
"type": "section",
Expand Down Expand Up @@ -119,6 +119,10 @@ module.exports = [
}
]
},
{
"type": "text",
"defaultValue": "<em>&nbsp;&nbsp;Un grand merci aux bêta-testeurs: <br>&nbsp;Ayush Gupta, et David Voicu</em>",
},
{
"type": "submit",
"defaultValue": "Sauvegarder mes paramètres"
Expand Down
6 changes: 5 additions & 1 deletion src/pkjs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "This is the settings page for the Breathe app. You are running version 0.2.5 of Breathe.",
"defaultValue": "This is the settings page for the Breathe app. You are running version 0.2.7 of Breathe.",
},
{
"type": "section",
Expand Down Expand Up @@ -119,6 +119,10 @@ module.exports = [
}
]
},
{
"type": "text",
"defaultValue": "<em>&nbsp;&nbsp;Many thanks to the beta testers: <br>&emsp;Ayush Gupta, and David Voicu</em>",
},
{
"type": "submit",
"defaultValue": "Save Settings"
Expand Down

0 comments on commit 61be74c

Please sign in to comment.