Skip to content

Commit

Permalink
Improved for Pebble Round
Browse files Browse the repository at this point in the history
  • Loading branch information
wildhart committed Feb 2, 2016
1 parent ed8cf0d commit 96a4b18
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 34 deletions.
2 changes: 1 addition & 1 deletion appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"sdkVersion": "3",
"shortName": "Meds Timer",
"targetPlatforms": [
"aplite"
"basalt"
],
"uuid": "95d07e1a-2451-4ffa-aa44-836e523a7648",
"versionLabel": "1.4",
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void main_save_data(void) {
persist_write_int(STORAGE_KEY_VERSION, CURRENT_STORAGE_VERSION);
data_timestamp=time(NULL);
persist_write_int(STORAGE_KEY_TIMESTAMP, data_timestamp);
#ifdef PBL_IF_SDK_3
#ifdef PBL_SDK_3
persist_write_int(STORAGE_KEY_TIMELINE, timeline_settings);
#endif
persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(Settings));
Expand All @@ -159,7 +159,7 @@ static void main_load_data(void) {
if (stored_version) {
data_loaded_from_watch = true;
if (persist_exists(STORAGE_KEY_TIMESTAMP)) data_timestamp=persist_read_int(STORAGE_KEY_TIMESTAMP);
#ifdef PBL_IF_SDK_3
#ifdef PBL_SDK_3
timeline_settings = persist_exists(STORAGE_KEY_TIMELINE) ? persist_read_int(STORAGE_KEY_TIMELINE) : (TIMELINE_FLAG_ON | TIMELINE_FLAG_NOTIFICATIONS);
#endif
persist_read_data(STORAGE_KEY_SETTINGS, &settings, sizeof(Settings));
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#define END_TIME(JOB) ((time_t) (JOB)->Seconds + (time_t) (JOB)->Repeat_hrs*3600)

#define FONT_GOTHIC_24_BOLD fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)
#define FONT_GOTHIC_28_BOLD fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)
#define FONT_GOTHIC_18_BOLD fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)
#define FONT_GOTHIC_14_BOLD fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)
#define FONT_GOTHIC_18 fonts_get_system_font(FONT_KEY_GOTHIC_18)
Expand Down
49 changes: 29 additions & 20 deletions src/main_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ static void initialise_ui(void) {
#ifndef PBL_SDK_3
window_set_fullscreen(s_window, false);
#endif

GRect bounds = layer_get_bounds(window_get_root_layer(s_window));
uint8_t margin=(bounds.size.w-144)/2;

// s_menulayer
s_menulayer = menu_layer_create(GRect(0, STATUS_BAR_LAYER_HEIGHT, bounds.size.w, bounds.size.h-STATUS_BAR_LAYER_HEIGHT));
Expand All @@ -56,7 +56,9 @@ static void initialise_ui(void) {
#ifdef PBL_SDK_3
force_back_button(s_window,s_menulayer);
// s_textlayer_wait
s_textlayer_wait = text_layer_create(GRect(14, (bounds.size.h-5*26)/2, bounds.size.w-2*14, 5*26));
s_textlayer_wait = text_layer_create(GRect(14+margin, (bounds.size.h-5*26)/2, bounds.size.w-2*(14+margin), 5*26));
text_layer_set_background_color(s_textlayer_wait,GColorBlack);
text_layer_set_text_color(s_textlayer_wait,GColorWhite);
text_layer_set_text(s_textlayer_wait, "\nUpdating timeline before closing...");
text_layer_set_text_alignment(s_textlayer_wait, GTextAlignmentCenter);
text_layer_set_font(s_textlayer_wait, FONT_ROBOTO_21_CONDENSED);
Expand Down Expand Up @@ -137,7 +139,7 @@ static void menu_draw_header_callback(GContext* ctx, const Layer *cell_layer, ui
case MENU_SECTION_JOBS:
case MENU_SECTION_OTHER:
break;
case MENU_SECTION_SETTINGS: menu_cell_basic_header_draw(ctx, cell_layer, "Options"); break;
case MENU_SECTION_SETTINGS: menu_cell_basic_header_draw(ctx, cell_layer, PBL_IF_ROUND_ELSE(" Options","Options")); break;
}
}

Expand All @@ -155,10 +157,11 @@ void menu_cell_draw_job(GContext* ctx, const Layer *cell_layer, const uint8_t in
#ifndef PBL_SDK_3
graphics_context_set_text_color(ctx, GColorBlack);
#endif
uint8_t margin=(bounds.size.w-144)/2;

graphics_draw_text(ctx, jobs_get_job_name(index), FONT_GOTHIC_24_BOLD, GRect(4, -4, bounds.size.w-8, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, jobs_get_job_clock_as_text(index), FONT_GOTHIC_18, GRect(4, 20, bounds.size.w-8, 14), GTextOverflowModeFill, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, jobs_get_job_repeat_as_text(index), FONT_GOTHIC_14, GRect(4, 20+4, bounds.size.w-8, 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, jobs_get_job_name(index), FONT_GOTHIC_24_BOLD, GRect(4+margin, -4, bounds.size.w-2*(4+margin), 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, jobs_get_job_clock_as_text(index), FONT_GOTHIC_18, GRect(4+margin, 20, bounds.size.w-2*(4+margin), 14), GTextOverflowModeFill, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, jobs_get_job_repeat_as_text(index), FONT_GOTHIC_14, GRect(4+margin, 20+4, bounds.size.w-2*(4+margin), 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);

//graphics_draw_bitmap_in_rect(ctx, timer.Active && timer.Job==index ? bitmap_play : bitmap_pause, GRect(6, (bounds.size.h-16)/2, 16, 16));
}
Expand All @@ -169,11 +172,12 @@ void menu_cell_draw_other(GContext* ctx, const Layer *cell_layer, const char *ti
#ifndef PBL_SDK_3
graphics_context_set_text_color(ctx, GColorBlack);
#endif
uint8_t margin=(bounds.size.w-144)/2;

graphics_draw_text(ctx, title, FONT_GOTHIC_24_BOLD, GRect(28, -4, bounds.size.w-28, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
if (sub_title) graphics_draw_text(ctx, sub_title, FONT_GOTHIC_18, GRect(28, 20, bounds.size.w-28-4, 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, title, FONT_GOTHIC_24_BOLD, GRect(28+margin, -4, bounds.size.w-28-2*margin, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
if (sub_title) graphics_draw_text(ctx, sub_title, FONT_GOTHIC_18, GRect(28+margin, 20, bounds.size.w-28-margin-4, 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);

if (icon) graphics_draw_bitmap_in_rect(ctx, icon, GRect(6,(bounds.size.h-16)/2, 16, 16));
if (icon) graphics_draw_bitmap_in_rect(ctx, icon, GRect(6+margin,(bounds.size.h-16)/2, 16, 16));
}

static void menu_cell_draw_setting(GContext* ctx, const Layer *cell_layer, const char *title, const char *setting, const char *hint) {
Expand All @@ -182,10 +186,11 @@ static void menu_cell_draw_setting(GContext* ctx, const Layer *cell_layer, const
#ifndef PBL_SDK_3
graphics_context_set_text_color(ctx, GColorBlack);
#endif
uint8_t margin=(bounds.size.w-144)/2;

graphics_draw_text(ctx, title, FONT_GOTHIC_24_BOLD, GRect(4, -4, bounds.size.w-8, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, setting, FONT_GOTHIC_18_BOLD, GRect(4, 2, bounds.size.w-8, 18), GTextOverflowModeFill, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, hint, FONT_GOTHIC_18, GRect(4, 20, bounds.size.w-8, 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, title, FONT_GOTHIC_24_BOLD, GRect(4+margin, -4, bounds.size.w-2*(4+margin), 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
graphics_draw_text(ctx, setting, FONT_GOTHIC_18_BOLD, GRect(4+margin, 2, bounds.size.w-2*(4+margin), 18), GTextOverflowModeFill, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, hint, FONT_GOTHIC_18, GRect(4+margin, 20, bounds.size.w-2*(4+margin), 14), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}

static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
Expand All @@ -203,9 +208,11 @@ static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuI
break;
case MENU_SETTINGS_ALARM: menu_cell_draw_setting(ctx, cell_layer, "Alarm", settings.Alarm ? "ON" : "OFF",NULL); break;
case MENU_SETTINGS_SORT: menu_cell_draw_setting(ctx, cell_layer, "Sort", settings.Sort ? "YES" : "NO",NULL); break;
case MENU_SETTINGS_CONFIG: menu_cell_draw_other(ctx, cell_layer, check_phone_message ? "Check phone..." : "Config/Donate", NULL , bitmap_settings); break;
#ifdef PBL_SDK_3
case MENU_SETTINGS_TIMELINE: menu_cell_draw_setting(ctx, cell_layer, "Timeline", timeline_settings&TIMELINE_FLAG_ON ? "ON" : "OFF",NULL); break;
case MENU_SETTINGS_TL_NOTIFICATIONS: menu_cell_draw_setting(ctx, cell_layer, "..Notifications", timeline_settings&TIMELINE_FLAG_NOTIFICATIONS ? "ON" : "OFF",NULL); break;
case MENU_SETTINGS_CONFIG: menu_cell_draw_other(ctx, cell_layer, check_phone_message ? "Check phone..." : "Config/Donate", NULL , bitmap_settings); break;
#endif
}
}
}
Expand Down Expand Up @@ -238,6 +245,14 @@ static void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, v
main_save_data();
menu_layer_reload_data(s_menulayer);
break;
case MENU_SETTINGS_CONFIG:
export_after_save=true;
main_save_data();
check_phone_message=true;
menu_layer_reload_data(s_menulayer);
app_timer_register(2000 /* milliseconds */, timer_callback, NULL);
break;
#ifdef PBL_SDK_3
case MENU_SETTINGS_TIMELINE:
timeline_settings^=TIMELINE_FLAG_ON ; // ^ = XOR
main_save_data();
Expand All @@ -248,13 +263,7 @@ static void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, v
main_save_data();
menu_layer_reload_data(s_menulayer);
break;
case MENU_SETTINGS_CONFIG:
export_after_save=true;
main_save_data();
check_phone_message=true;
menu_layer_reload_data(s_menulayer);
app_timer_register(2000 /* milliseconds */, timer_callback, NULL);
break;
#endif
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pebble-js-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Pebble.addEventListener("appmessage", function(e) {
}
if (typeof(e.payload.KEY_TIMELINE)!="undefined") {
deleteAllPins();
if (e.payload.KEY_TIMELINE & TIMELINE_FLAG_ON) createAllPins(e.payload); else sendDict({KEY_PINS_DONE:1});
if (e.payload.KEY_TIMELINE & TIMELINE_FLAG_ON) createAllPins(e.payload);
if (requests_outstanding===0) sendDict({KEY_PINS_DONE:1});
}
});

Expand Down
36 changes: 26 additions & 10 deletions src/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,46 @@

// BEGIN AUTO-GENERATED UI CODE; DO NOT MODIFY
static Window *s_window;
static GFont s_res_gothic_28_bold;
static GFont s_res_gothic_14;
static TextLayer *s_textlayer_heading;
static TextLayer *s_textlayer_features;

#define MARGIN PBL_IF_ROUND_ELSE(12,0)
#define HEIGHT PBL_IF_ROUND_ELSE(56,32)

void select_button_handler(ClickRecognizerRef recognizer, void *context) {
update_hide();
}

void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_button_handler);
}

static void initialise_ui(void) {
s_window = window_create();
#ifndef PBL_SDK_3
window_set_fullscreen(s_window, false);
#endif

s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
GRect bounds = layer_get_bounds(window_get_root_layer(s_window));

// s_textlayer_heading
s_textlayer_heading = text_layer_create(GRect(2, -1, 140, 28));
text_layer_set_text(s_textlayer_heading, "New Feature:");
text_layer_set_font(s_textlayer_heading, s_res_gothic_28_bold);
s_textlayer_heading = text_layer_create(GRect(0, -1, bounds.size.w, HEIGHT+MARGIN));
text_layer_set_text(s_textlayer_heading, PBL_IF_ROUND_ELSE("New\nFeatures:","New Features:"));
text_layer_set_background_color(s_textlayer_heading,GColorBlack);
text_layer_set_text_alignment(s_textlayer_heading, GTextAlignmentCenter);
text_layer_set_text_color(s_textlayer_heading,GColorWhite);
text_layer_set_font(s_textlayer_heading, FONT_GOTHIC_28_BOLD);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_heading);

// s_textlayer_features
s_textlayer_features = text_layer_create(GRect(2, 27, 140, 125));
text_layer_set_text(s_textlayer_features, "* Medications now appear on the timeline");
text_layer_set_font(s_textlayer_features, s_res_gothic_14);
s_textlayer_features = text_layer_create(GRect(2+MARGIN, HEIGHT+MARGIN, bounds.size.w-2*(2+MARGIN), bounds.size.h-HEIGHT-MARGIN));
text_layer_set_text(s_textlayer_features, "* Medications now appear on the timeline\n\n* Optimised for Pebble Time Round");
text_layer_set_font(s_textlayer_features, FONT_GOTHIC_18);
#ifdef PBL_ROUND
text_layer_set_text_alignment(s_textlayer_features, GTextAlignmentCenter);
#endif
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_features);
window_set_click_config_provider(s_window,(void*)click_config_provider);
}

static void destroy_ui(void) {
Expand Down

0 comments on commit 96a4b18

Please sign in to comment.