diff --git a/package.json b/package.json index 6a78cfe..5cc6787 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "circleColor", "vibrationEnabled", "heartRateEnabled", - "reminderHours" + "reminderHours", + "rememberDuration" ], "projectType": "native", "resources": { @@ -51,5 +52,5 @@ "watchface": false } }, - "version": "0.23.0" + "version": "0.24.0" } diff --git a/src/c/breathe_window.c b/src/c/breathe_window.c index 80a4537..145a218 100644 --- a/src/c/breathe_window.c +++ b/src/c/breathe_window.c @@ -13,7 +13,7 @@ static uint8_t s_radius_final, s_radius = 0; static int s_min_to_breathe = 1, s_min_breathed_today = 0, s_times_played = 0; static bool s_animation_completed = false, s_animating = false; static GPoint s_center; -static char s_min_to_breathe_text[3] = "1", s_instruct_text[9], s_min_text[5], s_min_today[25], s_greet_text[27], *s_start_time, *s_end_time; +static char s_min_to_breathe_text[3] = "1", s_instruct_text[27], s_min_text[25], s_min_today[25], s_greet_text[27], *s_start_time, *s_end_time; static time_t t; // ******************************************************************************************* Layer Update Procedures @@ -24,7 +24,7 @@ static void canvas_update_proc(Layer *s_drawing_layer, GContext *ctx) { // Updates text inside circle, side semicircle, and triangles static void inside_text_layer_update_proc(Layer *s_inside_text_layer, GContext *ctx) { - graphics_draw_inner_text(ctx, bounds, s_min_to_breathe, settings_get_textColor(), s_min_to_breathe_text, s_instruct_text, s_min_text); + graphics_draw_inner_text(ctx, bounds, s_animating, s_min_to_breathe, settings_get_textColor(), s_min_to_breathe_text, s_instruct_text, s_min_text); } // Draws text at top of screen @@ -80,6 +80,16 @@ static void finish_setup_callback(void *context) { layer_mark_dirty(s_lower_text_layer); } +// ******************************************************************************************* Other stuff +// Changes text in circle if singular or plural +static void set_min_text(int minutes, void *string) { + if (minutes == 1) { + snprintf(string, 5, "%s", "MIN"); + } else { + snprintf(string, 5, "%s", "MINS"); + } +} + // ******************************************************************************************* Animation Sequence Creator // Animation while breathing static void radius_contract_update(Animation *anim, AnimationProgress dist_normalized) { @@ -139,6 +149,10 @@ static void main_animation_end() { // Sets up and schedules circle contract and expand static void main_animation() { // Hides text layers + #ifdef PBL_ROUND + layer_set_hidden(s_inside_text_layer, true); + #endif + layer_set_hidden(s_upper_text_layer, true); layer_set_hidden(s_lower_text_layer, true); @@ -190,6 +204,9 @@ static void main_animation_callback () { static void first_breath_in_callback(void *context) { snprintf(s_greet_text, sizeof(s_greet_text), localize_get_inhale_text()); layer_set_hidden(s_upper_text_layer, false); + #ifdef PBL_ROUND + layer_set_hidden(s_inside_text_layer, true); + #endif } // Shows instructions to exhale; first hides the top text and then shows the bottom text @@ -224,7 +241,6 @@ static void animation_start_callback(void *context) { int random_number = rand() % 9; APP_LOG(APP_LOG_LEVEL_DEBUG, "The random_number is %d", random_number); APP_LOG(APP_LOG_LEVEL_DEBUG, "The string is %s", &*strings[random_number]); - snprintf(s_greet_text, sizeof(s_greet_text), "%s", &*strings[random_number]); // Same thing as above but for bottom text char* bottom_text[4] = {"BREATHE.", "EXHALE.", "CONCENTRATE.", "FOCUS."}; @@ -232,7 +248,7 @@ static void animation_start_callback(void *context) { char* french_bottom_text[4] = {"RESPIREZ.", "EXHALEZ.", "RESPIREZ.", "EXHALEZ."}; for (int i = 0; i <= 3; i++) { bottom_text[i] = french_bottom_text[i]; - } + } } else if (strncmp(localize_get_locale(), "es", 2) == 0) { char* spanish_bottom_text[4] = {"RESPIRA.", "EXHALA.", "RESPIRA.", "EXHALA."}; for (int i = 0; i <= 8; i++) { @@ -243,11 +259,19 @@ static void animation_start_callback(void *context) { int random_number_2 = rand() % 4; APP_LOG(APP_LOG_LEVEL_DEBUG, "The random_number #2 is %d", random_number_2); APP_LOG(APP_LOG_LEVEL_DEBUG, "The string is %s", &*bottom_text[random_number_2]); - snprintf(s_min_today, sizeof(s_min_today), "%s", &*bottom_text[random_number_2]); - - // Shows the text at top and bottom - layer_set_hidden(s_upper_text_layer, false); - layer_set_hidden(s_lower_text_layer, false); + + #ifdef PBL_RECT + // Shows the text at top and bottom + snprintf(s_greet_text, sizeof(s_greet_text), "%s", &*strings[random_number]); + snprintf(s_min_today, sizeof(s_min_today), "%s", &*bottom_text[random_number_2]); + layer_set_hidden(s_upper_text_layer, false); + layer_set_hidden(s_lower_text_layer, false); + #else + // Shows the text near the center of the screen + snprintf(s_instruct_text, sizeof(s_instruct_text), "%s", &*strings[random_number]); + snprintf(s_min_text, sizeof(s_min_text), "%s", &*bottom_text[random_number_2]); + layer_set_hidden(s_inside_text_layer, false); + #endif } // End animation show text @@ -277,6 +301,12 @@ static void animation_end_callback(void *context) { data_write_breathe_persist_data(s_min_breathed_today); data_write_date_persist_data(); + // Persist the duration of minutes + if (settings_get_rememberDuration()) { + APP_LOG(APP_LOG_LEVEL_DEBUG, "rememberDuration is enabled and duration has been saved."); + data_write_last_duration_data(s_min_to_breathe); + } + // Sets different number of digits for one digit or two digits if (s_min_to_breathe == 10) { snprintf(s_min_to_breathe_text, 3, "%dd", s_min_to_breathe); @@ -285,20 +315,15 @@ static void animation_end_callback(void *context) { } // Shows all the layers because breathing is done + #ifdef PBL_ROUND + set_min_text(s_min_to_breathe, s_min_text); + snprintf(s_instruct_text, sizeof(s_instruct_text), localize_get_breathe_text()); + #endif layer_set_hidden(s_inside_text_layer, false); layer_set_hidden(s_upper_text_layer, false); layer_set_hidden(s_lower_text_layer, false); } -// Changes text in circle if singular or plural -static void set_min_text(int minutes, void *string) { - if (minutes == 1) { - snprintf(string, 5, "%s", "MIN"); - } else { - snprintf(string, 5, "%s", "MINS"); - } -} - // ******************************************************************************************* Click Handlers static void up_click_handler(ClickRecognizerRef recognizer, void *context) { // Increments number, displays number. @@ -452,6 +477,8 @@ void breathe_window_push(int min) { snprintf(s_min_to_breathe_text, sizeof(s_min_to_breathe_text), "%d", s_min_to_breathe); set_min_text(s_min_to_breathe, s_min_text); + snprintf(s_greet_text, sizeof(s_greet_text), localize_get_greet_text()); + // Show window on the watch, with animated = true window_stack_push(s_main_window, true); } \ No newline at end of file diff --git a/src/c/data.c b/src/c/data.c index a5349ae..7b1c8e6 100644 --- a/src/c/data.c +++ b/src/c/data.c @@ -116,4 +116,20 @@ int data_read_breathe_persist_data() { return min_breathed_today; } return 0; +} + +void data_write_last_duration_data(int last_duration) { + persist_write_int(LAST_DURATION_KEY, last_duration); +} + +int data_read_last_duration_data() { + int last_duration = 1; + if (persist_exists(LAST_DURATION_KEY)) { + last_duration = persist_read_int(LAST_DURATION_KEY); + APP_LOG(APP_LOG_LEVEL_DEBUG, "The last duration was %d.", last_duration); + } else { + APP_LOG(APP_LOG_LEVEL_DEBUG, "User has not breathed before; created data."); + data_write_last_duration_data(last_duration); + } + return last_duration; } \ No newline at end of file diff --git a/src/c/data.h b/src/c/data.h index 25e7546..57d8ccd 100644 --- a/src/c/data.h +++ b/src/c/data.h @@ -3,6 +3,7 @@ #define MIN_BREATHED_TODAY_KEY 0 #define DATE_STORED_KEY 1 +#define LAST_DURATION_KEY 2 void data_init(); @@ -21,4 +22,6 @@ char* data_get_current_heart_rate_buffer(); char* data_get_date_today(); void data_write_breathe_persist_data(int min_to_breathe); void data_write_date_persist_data(); -int data_read_breathe_persist_data(); \ No newline at end of file +int data_read_breathe_persist_data(); +void data_write_last_duration_data(int last_duration); +int data_read_last_duration_data(); \ No newline at end of file diff --git a/src/c/graphics.c b/src/c/graphics.c index f23869b..6087092 100644 --- a/src/c/graphics.c +++ b/src/c/graphics.c @@ -40,21 +40,21 @@ void graphics_draw_upper_text(GContext *ctx, GRect bounds, bool is_animating, bo #endif graphics_context_set_text_color(ctx, (is_animating) ? textColor : PBL_IF_COLOR_ELSE(GColorDarkGray, textColor)); // Set text color to dark gray on main menu, but white for other sections - GSize greet_text_bounds = graphics_text_layout_get_content_size("THAT IS A LOT OF STEPS TO TAKE IN JUST ONE DAY, INNIT?", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + GSize greet_text_bounds = graphics_text_layout_get_content_size("THAT IS A LOT OF STEPS TO TAKE IN JUST ONE DAY, INNIT?", fonts_get_system_font(FONT_KEY), GRect(0, 0, bounds.size.w, bounds.size.h), GTextOverflowModeWordWrap, GTextAlignmentCenter); // Random string for size purposes if (is_animating) { // If animating, shows the normal text - graphics_draw_text(ctx, greet_text, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, greet_text, fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - greet_text_bounds.w) / 2, PBL_IF_RECT_ELSE(5, 15), greet_text_bounds.w, greet_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } else { if (heart_rate && data_get_current_heart_rate() > 0) { // If heart rate monitor is enabled in configuration and is available, show heart rate const char *heart_rate_buffer = data_get_current_heart_rate_buffer(); - graphics_draw_text(ctx, heart_rate_buffer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, heart_rate_buffer, fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - greet_text_bounds.w) / 2, PBL_IF_RECT_ELSE(5, 15), greet_text_bounds.w, greet_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } else { // Otherwise, show step counts if Pebble Health, and string if not. - graphics_draw_text(ctx, PBL_IF_HEALTH_ELSE(steps_buffer, greet_text), fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, PBL_IF_HEALTH_ELSE(steps_buffer, greet_text), fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - greet_text_bounds.w) / 2, PBL_IF_RECT_ELSE(5, 15), greet_text_bounds.w, greet_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } @@ -64,54 +64,66 @@ void graphics_draw_upper_text(GContext *ctx, GRect bounds, bool is_animating, bo // Method for updating the lower text layer void graphics_draw_lower_text(GContext *ctx, GRect bounds, bool is_animating, GColor textColor, char *min_today) { graphics_context_set_text_color(ctx, (is_animating) ? textColor : PBL_IF_COLOR_ELSE(GColorDarkGray, textColor)); // Like above, sets text color to dark gray on main menu, but white for other sections - GSize today_text_bounds = graphics_text_layout_get_content_size("TODAY: 10,000 MINUTES", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + GSize today_text_bounds = graphics_text_layout_get_content_size("TODAY: 10,000 MINUTES", fonts_get_system_font(FONT_KEY), GRect(0, 0, bounds.size.w, bounds.size.h), GTextOverflowModeWordWrap, GTextAlignmentCenter); - graphics_draw_text(ctx, min_today, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, min_today, fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - today_text_bounds.w) / 2, bounds.size.h - today_text_bounds.h - PBL_IF_RECT_ELSE(8, 20), today_text_bounds.w, today_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } // Method for updating the inner text, triangles, and the semicircle on the right center of the screen -void graphics_draw_inner_text(GContext *ctx, GRect bounds, int min_to_breathe, GColor textColor, char *min_to_breathe_text, char *instruct_text, char *min_text) { +void graphics_draw_inner_text(GContext *ctx, GRect bounds, bool is_animating, int min_to_breathe, GColor textColor, char *min_to_breathe_text, char *instruct_text, char *min_text) { // Draw side circle graphics_context_set_fill_color(ctx, textColor); - graphics_fill_circle(ctx, GPoint(bounds.size.w + 5, bounds.size.h / 2), 10); + #ifdef PBL_PLATFORM_EMERY + graphics_fill_circle(ctx, GPoint(bounds.size.w + 7, bounds.size.h / 2), 12); + #elif PBL_PLATFORM_CHALK + if (!is_animating) { + graphics_fill_circle(ctx, GPoint(bounds.size.w + 1, bounds.size.h / 2), 12); + } + #else + graphics_fill_circle(ctx, GPoint(bounds.size.w + 5, bounds.size.h / 2), 10); + #endif - // Draw triangles - switch(min_to_breathe) { - case 1 : - gpath_draw_filled(ctx, s_up_triangle); // Only draw the upper triangle because user cannot set a time lower than 1 - break; - case 10 : - gpath_draw_filled(ctx, s_down_triangle); // Only draw the lower triangle because the user cannot set a time higher than 10 - break; - default: - gpath_draw_filled(ctx, s_up_triangle); - gpath_draw_filled(ctx, s_down_triangle); + if (!is_animating) { + // Draw triangles + switch(min_to_breathe) { + case 1 : + gpath_draw_filled(ctx, s_up_triangle); // Only draw the upper triangle because user cannot set a time lower than 1 + break; + case 10 : + gpath_draw_filled(ctx, s_down_triangle); // Only draw the lower triangle because the user cannot set a time higher than 10 + break; + default: + gpath_draw_filled(ctx, s_up_triangle); + gpath_draw_filled(ctx, s_down_triangle); + } } // Draw text in circle graphics_context_set_text_color(ctx, textColor); - GSize min_to_breathe_bounds = graphics_text_layout_get_content_size("10", fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), - GRect(0, 0, bounds.size.w, bounds.size.h), - GTextOverflowModeWordWrap, GTextAlignmentCenter); - graphics_draw_text(ctx, min_to_breathe_text, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), - GRect((bounds.size.w - min_to_breathe_bounds.w) / 2, (bounds.size.h - min_to_breathe_bounds.h) / 2 - 6, min_to_breathe_bounds.w, min_to_breathe_bounds.h), - GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); - - GSize instruct_text_bounds = graphics_text_layout_get_content_size("RESPIRAR", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + if (!is_animating) { + GSize min_to_breathe_bounds = graphics_text_layout_get_content_size("10", fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), + GRect(0, 0, bounds.size.w, bounds.size.h), + GTextOverflowModeWordWrap, GTextAlignmentCenter); + graphics_draw_text(ctx, min_to_breathe_text, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS), + GRect((bounds.size.w - min_to_breathe_bounds.w) / 2, (bounds.size.h - min_to_breathe_bounds.h) / 2 - 6, min_to_breathe_bounds.w, min_to_breathe_bounds.h), + GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); + } + + GSize instruct_text_bounds = graphics_text_layout_get_content_size(PBL_IF_ROUND_ELSE("DONNEZ_VOUS DE L'ESPACE;", "BREATHE"), fonts_get_system_font(FONT_KEY), GRect(0, 0, bounds.size.w, bounds.size.h), GTextOverflowModeWordWrap, GTextAlignmentCenter); - graphics_draw_text(ctx, instruct_text, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, instruct_text, fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - instruct_text_bounds.w) / 2, (bounds.size.h - instruct_text_bounds.h) / 2 - 29, instruct_text_bounds.w, instruct_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); - GSize min_text_bounds = graphics_text_layout_get_content_size("MINS", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + GSize min_text_bounds = graphics_text_layout_get_content_size("CONCENTRATE.", fonts_get_system_font(FONT_KEY), GRect(0, 0, bounds.size.w, bounds.size.h), GTextOverflowModeWordWrap, GTextAlignmentCenter); - graphics_draw_text(ctx, min_text, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), + graphics_draw_text(ctx, min_text, fonts_get_system_font(FONT_KEY), GRect((bounds.size.w - min_text_bounds.w) / 2, (bounds.size.h - min_text_bounds.h) / 2 + 25, min_text_bounds.w, min_text_bounds.h), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } diff --git a/src/c/graphics.h b/src/c/graphics.h index 8ae334e..9e31234 100644 --- a/src/c/graphics.h +++ b/src/c/graphics.h @@ -2,11 +2,17 @@ #include #include "src/c/data.h" +#ifdef PBL_PLATFORM_EMERY + #define FONT_KEY FONT_KEY_GOTHIC_18_BOLD +#else + #define FONT_KEY FONT_KEY_GOTHIC_14_BOLD +#endif + void graphics_draw_upper_text(GContext *ctx, GRect bounds, bool is_animating, bool heart_rate, GColor textColor, char *); void graphics_draw_lower_text(GContext *ctx, GRect bounds, bool is_animating, GColor textColor, char *); -void graphics_draw_inner_text(GContext *ctx, GRect bounds, int min_to_breathe, GColor textColor, char *, char *, char *); +void graphics_draw_inner_text(GContext *ctx, GRect bounds, bool is_animating, int min_to_breathe, GColor textColor, char *, char *, char *); void graphics_draw_main_circle(GContext *ctx, GColor circleColor, GPoint center, int radius); diff --git a/src/c/localize.c b/src/c/localize.c index cc10a7d..599d1d6 100644 --- a/src/c/localize.c +++ b/src/c/localize.c @@ -9,19 +9,19 @@ char * localize_get_app_glance_text(int minutes) { switch (minutes) { case 1: if (strncmp(localize_get_locale(), "fr", 2) == 0) { - return "La journée plus récente: %d minute. Respirez maintenant!"; + return "Dernière session: %d minute. Respirez maintenant!"; } else if (strncmp(localize_get_locale(), "es", 2) == 0) { - return "El día más reciente: %d minuto. ¡Respira ahora!"; + return "Última sesión: %d minuto. ¡Respira ahora!"; } else { - return "Most recent day: %d minute. Breathe now!"; + return "Last session: %d minute. Breathe now!"; } default: if (strncmp(localize_get_locale(), "fr", 2) == 0) { - return "La journée plus récente: %d minutes. Respirez maintenant!"; + return "Dernière session: %d minutes. Respirez maintenant!"; } else if (strncmp(localize_get_locale(), "es", 2) == 0) { - return "El día más reciente: %d minutos. ¡Respira ahora!"; + return "Última sesión: %d minutos. ¡Respira ahora!"; } else { - return "Most recent day: %d minutes. Breathe now!"; + return "Last session: %d minutes. Breathe now!"; } } } @@ -142,4 +142,14 @@ char * localize_get_reminder_text() { } else { return "Time to breathe!"; } +} + +char * localize_get_greet_text() { + if (strncmp(localize_get_locale(), "fr", 2) == 0) { + return "BONJOUR!"; + } else if (strncmp(localize_get_locale(), "es", 2) == 0) { + return "¡HOLA!"; + } else { + return "HELLO!"; + } } \ No newline at end of file diff --git a/src/c/localize.h b/src/c/localize.h index 8dfa776..94aa4e0 100644 --- a/src/c/localize.h +++ b/src/c/localize.h @@ -12,4 +12,5 @@ char * localize_get_min_breathed_today_text(); char * localize_get_steps_today_text(int thousands); char * localize_get_heart_rate_text(); char * localize_get_reminder_action_menu_text(); -char * localize_get_reminder_text(); \ No newline at end of file +char * localize_get_reminder_text(); +char * localize_get_greet_text(); \ No newline at end of file diff --git a/src/c/main.c b/src/c/main.c index a51d2c5..768f2c7 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -9,7 +9,7 @@ #include "src/c/appglance.h" static void init() { - APP_LOG(APP_LOG_LEVEL_INFO, "You are running version 0.2.3 of this app."); + APP_LOG(APP_LOG_LEVEL_INFO, "You are running version 0.2.4 of this app."); #if PBL_HEALTH health_init(); // Subscribe to health service if health API is available #endif @@ -32,8 +32,12 @@ static void init() { } } else { // The app was started by the user; push the standard breathe window - breathe_window_push(1); -// reminder_window_push(); for testing + if (settings_get_rememberDuration()) { + breathe_window_push(data_read_last_duration_data()); + } else { + breathe_window_push(1); + } +// reminder_window_push(); // For testing // Schedule next wakeup, just in case if (settings_get_reminderHours() != 0) { wakeup_schedule_next_wakeup(settings_get_reminderHours(), 0); @@ -47,7 +51,7 @@ static void deinit() { health_service_set_heart_rate_sample_period(0); // Reset heart rate sample period to default as to not waste too much battery #endif char app_glance_text[79]; - snprintf(app_glance_text, sizeof(app_glance_text), localize_get_app_glance_text(data_read_breathe_persist_data()), data_read_breathe_persist_data()); + snprintf(app_glance_text, sizeof(app_glance_text), localize_get_app_glance_text(data_read_last_duration_data()), data_read_last_duration_data()); app_glance_reload(appglance_update_app_glance, app_glance_text); // Reload app glance } diff --git a/src/c/reminder_window.c b/src/c/reminder_window.c index f9b1c2a..868c0ba 100644 --- a/src/c/reminder_window.c +++ b/src/c/reminder_window.c @@ -44,7 +44,13 @@ static void canvas_update_proc(Layer *layer, GContext *ctx) { } graphics_context_set_fill_color(ctx, GColorBlack); - graphics_fill_circle(ctx, GPoint(bounds.size.w + 5, bounds.size.h / 2), 10); + #ifdef PBL_PLATFORM_EMERY + graphics_fill_circle(ctx, GPoint(bounds.size.w + 7, bounds.size.h / 2), 12); + #elif PBL_PLATFORM_CHALK + graphics_fill_circle(ctx, GPoint(bounds.size.w + 1, bounds.size.h / 2), 12); + #else + graphics_fill_circle(ctx, GPoint(bounds.size.w + 5, bounds.size.h / 2), 10); + #endif } static void action_performed_callback(ActionMenu *action_menu, const ActionMenuItem *action, void *context) { @@ -105,8 +111,8 @@ static void reminder_window_load(Window *window) { app_timer_register(DELTA, next_frame_handler, NULL); // Layer for text - s_text_layer = text_layer_create(GRect(0, bounds.size.w - PBL_IF_RECT_ELSE(16, 40), bounds.size.w, bounds.size.h / 2)); - text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); + s_text_layer = text_layer_create(GRect(0, bounds.size.w - PBL_IF_RECT_ELSE(16, 50), bounds.size.w, bounds.size.h / 2)); + text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY)); text_layer_set_background_color(s_text_layer, random_color); text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter); text_layer_set_text(s_text_layer, localize_get_reminder_text()); diff --git a/src/c/reminder_window.h b/src/c/reminder_window.h index 774053d..06e878f 100644 --- a/src/c/reminder_window.h +++ b/src/c/reminder_window.h @@ -1,3 +1,11 @@ #pragma once +#ifdef PBL_PLATFORM_EMERY + #define FONT_KEY FONT_KEY_GOTHIC_28_BOLD +#elif PBL_PLATFORM_CHALK + #define FONT_KEY FONT_KEY_GOTHIC_18_BOLD +#else + #define FONT_KEY FONT_KEY_GOTHIC_24_BOLD +#endif + void reminder_window_push(); \ No newline at end of file diff --git a/src/c/settings.c b/src/c/settings.c index 9e42813..99a334c 100644 --- a/src/c/settings.c +++ b/src/c/settings.c @@ -10,6 +10,7 @@ void settings_init() { settings.circleColor = PBL_IF_COLOR_ELSE(GColorJaegerGreen, GColorWhite); settings.textColor = GColorWhite; settings.vibrationEnabled = true; + settings.rememberDuration = false; #if PBL_API_EXISTS(health_service_peek_current_value) settings.heartRateEnabled = true; #else @@ -65,6 +66,11 @@ void settings_handle_settings(DictionaryIterator *iter, void *context) { wakeup_force_next_schedule(settings.reminderHours, 0); } } + + Tuple *remember_duration_t = dict_find(iter, MESSAGE_KEY_rememberDuration); + if (remember_duration_t) { + settings.rememberDuration = remember_duration_t->value->int32 == 1; + } } GColor settings_get_backgroundColor() { @@ -89,4 +95,8 @@ bool settings_get_heartRateEnabled() { int settings_get_reminderHours() { return settings.reminderHours; +} + +bool settings_get_rememberDuration() { + return settings.rememberDuration; } \ No newline at end of file diff --git a/src/c/settings.h b/src/c/settings.h index 75d53a5..481c0a9 100644 --- a/src/c/settings.h +++ b/src/c/settings.h @@ -11,6 +11,7 @@ typedef struct ClaySettings { bool vibrationEnabled; bool heartRateEnabled; int reminderHours; + bool rememberDuration; } ClaySettings; void settings_init(); @@ -22,4 +23,5 @@ GColor settings_get_circleColor(); GColor settings_get_textColor(); bool settings_get_vibrationEnabled(); bool settings_get_heartRateEnabled(); -int settings_get_reminderHours(); \ No newline at end of file +int settings_get_reminderHours(); +bool settings_get_rememberDuration(); \ No newline at end of file diff --git a/src/pkjs/config-es.js b/src/pkjs/config-es.js index 3f45d2b..806a1c3 100644 --- a/src/pkjs/config-es.js +++ b/src/pkjs/config-es.js @@ -5,7 +5,7 @@ module.exports = [ }, { "type": "text", - "defaultValue": "Esta es la página de ajustes para el app Breathe. Estás usando la version 0.2.3 del app.", + "defaultValue": "Esta es la página de ajustes para la app Breathe. Estás usando la version 0.2.4 de la app.", }, { "type": "section", @@ -35,7 +35,13 @@ module.exports = [ "type": "section", "items": [ {"type": "heading", - "defaultValue": "Vibraciones" + "defaultValue": "En la app" + }, + { + "type": "toggle", + "messageKey": "rememberDuration", + "defaultValue": false, + "label": "¿Recordar la duración anterior y usarla cuando se lance la app?", }, { "type": "toggle", @@ -72,19 +78,27 @@ module.exports = [ "type": "select", "messageKey": "reminderHours", "defaultValue": "4", - "label": "Recuérdame cada...", + "label": "Recuérdame de respirar...", "description": "El app te recordará a este intervalo diariamente, de 8:00 de la mañana hasta 8:00 de la tarde.", "options": [ { - "label": "2 horas", + "label": "Cada hora", + "value": "1" + }, + { + "label": "Cada 2 horas", "value": "2" }, { - "label": "4 horas", + "label": "Cada 3 horas", + "value": "3" + }, + { + "label": "Cada 4 horas", "value": "4" }, { - "label": "6 horas", + "label": "Cada6 horas", "value": "6" }, { diff --git a/src/pkjs/config-fr.js b/src/pkjs/config-fr.js index deb16c6..cf49494 100644 --- a/src/pkjs/config-fr.js +++ b/src/pkjs/config-fr.js @@ -5,7 +5,7 @@ module.exports = [ }, { "type": "text", - "defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 0.2.3 de l'app.", + "defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 0.2.4 de l'app.", }, { "type": "section", @@ -35,7 +35,13 @@ module.exports = [ "type": "section", "items": [ {"type": "heading", - "defaultValue": "Vibrations" + "defaultValue": "Dans l'app" + }, + { + "type": "toggle", + "messageKey": "rememberDuration", + "defaultValue": false, + "label": "Se rappeler de la durée précédente?", }, { "type": "toggle", @@ -72,19 +78,27 @@ module.exports = [ "type": "select", "messageKey": "reminderHours", "defaultValue": "4", - "label": "Me rappeler toutes les...", + "label": "Me rappeler de respirer", "description": "L'app vous rappellera de respirer à cet intervalle tous les jours, à partir de 8h00 jusqu'à 20h00.", "options": [ { - "label": "2 heures", + "label": "Toutes les heures", + "value": "1" + }, + { + "label": "Toutes les 2 heures", "value": "2" }, { - "label": "4 heures", + "label": "Toutes les 3 heures", + "value": "3" + }, + { + "label": "Toutes les 4 heures", "value": "4" }, { - "label": "6 heures", + "label": "Toutes les 6 heures", "value": "6" }, { diff --git a/src/pkjs/config.js b/src/pkjs/config.js index 21527f9..ed92e22 100644 --- a/src/pkjs/config.js +++ b/src/pkjs/config.js @@ -5,7 +5,7 @@ module.exports = [ }, { "type": "text", - "defaultValue": "This is the settings page for the Breathe app. You are running version 0.2.3 of Breathe.", + "defaultValue": "This is the settings page for the Breathe app. You are running version 0.2.4 of Breathe.", }, { "type": "section", @@ -35,7 +35,13 @@ module.exports = [ "type": "section", "items": [ {"type": "heading", - "defaultValue": "Haptic Feedback" + "defaultValue": "In-App" + }, + { + "type": "toggle", + "messageKey": "rememberDuration", + "defaultValue": false, + "label": "Remember last duration when launching", }, { "type": "toggle", @@ -72,19 +78,27 @@ module.exports = [ "type": "select", "messageKey": "reminderHours", "defaultValue": "4", - "label": "Remind to breathe every...", + "label": "Remind to breathe...", "description": "The app will remind you to breathe at these intervals, starting from 8AM and ending at 8PM daily.", "options": [ + { + "label": "Every hour", + "value": "1" + }, { - "label": "2 hours", + "label": "Every 2 hours", "value": "2" }, { - "label": "4 hours", + "label": "Every 3 hours", + "value": "3" + }, + { + "label": "Every 4 hours", "value": "4" }, { - "label": "6 hours", + "label": "Every 6 hours", "value": "6" }, { diff --git a/src/pkjs/index.js b/src/pkjs/index.js index 66a1e97..f091aa2 100644 --- a/src/pkjs/index.js +++ b/src/pkjs/index.js @@ -30,7 +30,7 @@ Pebble.addEventListener('webviewclosed', function(e) { dict[messageKeys.reminderHours] = parseInt(dict[messageKeys.reminderHours]); var platform = clay.meta.activeWatchInfo.platform; if (platform === 'aplite' || platform === 'basalt' || platform === 'chalk') { - dict[messageKeys.heartRateEnabled] = false; + dict[messageKeys.heartRateEnabled] = false; // Just in case } // Log all the settings for fun @@ -39,6 +39,7 @@ Pebble.addEventListener('webviewclosed', function(e) { console.log('The circleColor sent to Pebble is ' + dict[messageKeys.circleColor] + '.'); console.log('The vibrationEnabled sent to Pebble is ' + dict[messageKeys.vibrationEnabled] + '.'); console.log('The heartRateEnabled sent to Pebble is ' + dict[messageKeys.heartRateEnabled] + '.'); + console.log('The rememberDuration sent to Pebble is ' + dict[messageKeys.rememberDuration] + '.'); // Send settings values to watch side Pebble.sendAppMessage(dict, function(e) {