battery-minus

Pebble activity tracker that records battery events
git clone https://git.instinctive.eu/battery-minus.git
Log | Files | Refs | README | LICENSE

commit e2631ae30fda25ff91bf4fcbe00091ce0c69c2d2
parent 7ea437fb23701521a3b6efd0d37bf5cb16d21265
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Tue,  2 Feb 2016 22:05:23 +0000

Use simple dialog messages to give feedback for UI actions
Diffstat:
Msrc/battery-minus.c | 46++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/battery-minus.c b/src/battery-minus.c @@ -15,6 +15,7 @@ */ #include <pebble.h> +#include "simple_dialog.h" #include "storage.h" #undef DISPLAY_TEST_DATA @@ -134,14 +135,55 @@ static void do_start_worker(int index, void *context) { (void)index; (void)context; - app_worker_launch(); + char buffer[256]; + AppWorkerResult result = app_worker_launch(); + + switch (result) { + case APP_WORKER_RESULT_SUCCESS: + push_simple_dialog("Worker start requested.", true); + break; + case APP_WORKER_RESULT_ALREADY_RUNNING: + push_simple_dialog("Worker is already running.", true); + break; + case APP_WORKER_RESULT_ASKING_CONFIRMATION: + APP_LOG(APP_LOG_LEVEL_INFO, + "Frirmware requesting confirmation, skipping UI"); + break; + default: + snprintf(buffer, sizeof buffer, + "Unexpected result %d", + (int)result); + push_simple_dialog(buffer, false); + } } static void do_stop_worker(int index, void *context) { (void)index; (void)context; - app_worker_kill(); + char buffer[256]; + AppWorkerResult result = app_worker_kill(); + + switch (result) { + case APP_WORKER_RESULT_SUCCESS: + push_simple_dialog("Worker stop requested.", true); + break; + case APP_WORKER_RESULT_NOT_RUNNING: + push_simple_dialog("Worker is already stopped.", true); + break; + case APP_WORKER_RESULT_DIFFERENT_APP: + push_simple_dialog("A different worker is running.", true); + break; + case APP_WORKER_RESULT_ASKING_CONFIRMATION: + APP_LOG(APP_LOG_LEVEL_INFO, + "Frirmware requesting confirmation, skipping UI"); + break; + default: + snprintf(buffer, sizeof buffer, + "Unexpected result %d", + (int)result); + push_simple_dialog(buffer, false); + } } /*********************