Skip to content

Commit

Permalink
Merge pull request #1 from wildhart/timeline
Browse files Browse the repository at this point in the history
Timeline and Pebble Time Round
  • Loading branch information
wildhart committed Feb 6, 2016
2 parents 73ed77d + 264ef15 commit 24ab05f
Show file tree
Hide file tree
Showing 14 changed files with 677 additions and 342 deletions.
18 changes: 15 additions & 3 deletions appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
"KEY_MEDICATIONS": 100,
"KEY_MODE": 1,
"KEY_SORT": 3,
"KEY_TIMELINE": 8,
"KEY_TIMESTAMP": 7,
"KEY_VERSION": 4
},
"capabilities": [
"configurable"
],
"companyName": "[email protected]",
"enableMultiJS": false,
"longName": "Medication Timer",
"projectType": "native",
"resources": {
"media": [
{
"file": "images/icons-inv.png",
"name": "IMAGE_ICON_MATRIX_INV",
"targetPlatforms": null,
"type": "png"
},
{
"file": "images/menu_icon.png",
"menuIcon": true,
Expand All @@ -31,11 +39,15 @@
}
]
},
"sdkVersion": "2",
"sdkVersion": "3",
"shortName": "Meds Timer",
"targetPlatforms": [
"aplite",
"basalt",
"chalk"
],
"uuid": "95d07e1a-2451-4ffa-aa44-836e523a7648",
"versionCode": 1,
"versionLabel": "1.3",
"versionLabel": "1.6",
"watchapp": {
"watchface": false
}
Expand Down
Binary file added resources/images/icons-inv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 39 additions & 29 deletions src/job_adjust.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ static const char* help_fixed[2]={"Timer runs from when drug WAS actually taken"
static char num_buffer[NUM_BUFFER_LENGTH];

static Window *s_window;
static GFont s_res_gothic_24_bold;
static GFont s_res_gothic_18;
static GFont s_res_gothic_14;
static ActionBarLayer *s_actionbarlayer;
static TextLayer *s_textlayer_name;
static TextLayer *s_textlayer_repeat;
static TextLayer *s_textlayer_hrs;
static TextLayer *s_textlayer_note;
static TextLayer *layers[N_LAYERS];
Expand Down Expand Up @@ -51,7 +49,7 @@ static void action_bar_select_click_handler() {
} else {
active_layer++;
set_layer_text();
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, bitmap_tick);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, bitmaps[BITMAP_TICK][PBL_IF_SDK_3_ELSE(1,0)]);
}
}

Expand All @@ -67,51 +65,63 @@ static void initialise_ui(void) {
window_set_fullscreen(s_window, false);
#endif

s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
// s_actionbarlayer
s_actionbarlayer = action_bar_layer_create();
action_bar_layer_add_to_window(s_actionbarlayer, s_window);
action_bar_layer_set_background_color(s_actionbarlayer, GColorBlack);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_UP, bitmap_add);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_DOWN, bitmap_minus);
action_bar_layer_set_click_config_provider(s_actionbarlayer, action_bar_click_config_provider);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer);

// s_textlayer_name
s_textlayer_name = text_layer_create(GRect(5, 7, 100, 30));
text_layer_set_font(s_textlayer_name, s_res_gothic_24_bold);
text_layer_set_font(s_textlayer_name, FONT_GOTHIC_24_BOLD);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_name);

layers[0] = text_layer_create(GRect(20, 60, 20, 24));
// s_textlayer_repeat
s_textlayer_repeat = text_layer_create(GRect(5+PBL_IF_ROUND_ELSE(20,0), 36+PBL_IF_ROUND_ELSE(16,0), 100, 30));
text_layer_set_font(s_textlayer_repeat, FONT_GOTHIC_18);
text_layer_set_text(s_textlayer_repeat, "Repeat Every");
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_repeat);

// hours number
layers[0] = text_layer_create(GRect(20-14+PBL_IF_ROUND_ELSE(20,0), 60+PBL_IF_ROUND_ELSE(16,0), 20, 24));
text_layer_set_text_alignment(layers[0], GTextAlignmentCenter);
text_layer_set_font(layers[0], s_res_gothic_18);
text_layer_set_font(layers[0], FONT_GOTHIC_18);
layer_add_child(window_get_root_layer(s_window), (Layer *)layers[0]);

// s_textlayer_hrs
s_textlayer_hrs = text_layer_create(GRect(20+20+2, 60, 30, 24));
text_layer_set_font(s_textlayer_hrs, s_res_gothic_18);
s_textlayer_hrs = text_layer_create(GRect(20+20+2-14+PBL_IF_ROUND_ELSE(20,0), 60+PBL_IF_ROUND_ELSE(16,0), 30, 24));
text_layer_set_font(s_textlayer_hrs, FONT_GOTHIC_18);
text_layer_set_text(s_textlayer_hrs, "hrs");
text_layer_set_text_alignment(s_textlayer_hrs, GTextAlignmentLeft);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_hrs);

// s_textlayer_fixed
layers[1] = text_layer_create(GRect(66, 60, 50, 24));
layers[1] = text_layer_create(GRect(66-14+PBL_IF_ROUND_ELSE(20,0), 60+PBL_IF_ROUND_ELSE(16,0), 50, 24));
text_layer_set_text_alignment(layers[1], GTextAlignmentCenter);
text_layer_set_font(layers[1], s_res_gothic_18);
text_layer_set_font(layers[1], FONT_GOTHIC_18);
layer_add_child(window_get_root_layer(s_window), (Layer *)layers[1]);

// s_textlayer_note
s_textlayer_note = text_layer_create(GRect(15, 94, 100, 45));
text_layer_set_font(s_textlayer_note, s_res_gothic_14);
s_textlayer_note = text_layer_create(GRect(15-2+PBL_IF_ROUND_ELSE(20,0), 94+PBL_IF_ROUND_ELSE(16,0), 100, 45));
text_layer_set_font(s_textlayer_note, FONT_GOTHIC_14);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_note);

// s_actionbarlayer
s_actionbarlayer = action_bar_layer_create();
action_bar_layer_add_to_window(s_actionbarlayer, s_window);
action_bar_layer_set_background_color(s_actionbarlayer, GColorBlack);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_UP, bitmaps[BITMAP_ADD][PBL_IF_SDK_3_ELSE(1,0)]);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_DOWN, bitmaps[BITMAP_MINUS][PBL_IF_SDK_3_ELSE(1,0)]);
action_bar_layer_set_click_config_provider(s_actionbarlayer, action_bar_click_config_provider);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer);

#ifdef PBL_ROUND
GRect bounds = layer_get_bounds(window_get_root_layer(s_window));
layer_set_frame((Layer *)s_textlayer_name, GRect(0,20,bounds.size.w,30));
text_layer_set_text_alignment(s_textlayer_name, GTextAlignmentCenter);
#endif
}

static void destroy_ui(void) {
window_destroy(s_window);
action_bar_layer_destroy(s_actionbarlayer);
text_layer_destroy(s_textlayer_name);
text_layer_destroy(s_textlayer_repeat);
text_layer_destroy(s_textlayer_hrs);
text_layer_destroy(s_textlayer_note);

for (uint8_t l=0; l<N_LAYERS; l++) text_layer_destroy(layers[l]);
Expand All @@ -126,12 +136,12 @@ void job_adjust_show() {
window_set_window_handlers(s_window, (WindowHandlers) {
.unload = handle_window_unload,
});
text_layer_set_text(s_textlayer_name, jobs_get_job_name(job_index));
text_layer_set_text(s_textlayer_name, jobs[job_index].Name);
active_layer=0;
values[0]=jobs_get_job_repeat(job_index);
values[1]=jobs_get_job_fixed(job_index);
values[0]=jobs[job_index].Repeat_hrs;
values[1]=jobs[job_index].Fixed;
set_layer_text(active_layer);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, bitmap_play);
action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, bitmaps[BITMAP_PLAY][PBL_IF_SDK_3_ELSE(1,0)]);

window_stack_push(s_window, true);
}
Expand Down
29 changes: 22 additions & 7 deletions src/job_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,37 @@ bool job_changed;
// BEGIN AUTO-GENERATED UI CODE; DO NOT MODIFY
static Window *s_window;
static MenuLayer *s_menulayer;
#ifdef PBL_SDK_3
static StatusBarLayer *s_status_bar;
#endif

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

GRect bounds = layer_get_bounds(window_get_root_layer(s_window));

// s_menulayer
s_menulayer = menu_layer_create(GRect(0, 0, 144, 152));
s_menulayer = menu_layer_create(GRect(0, STATUS_BAR_LAYER_HEIGHT, bounds.size.w, bounds.size.h-STATUS_BAR_LAYER_HEIGHT));
menu_layer_set_click_config_onto_window(s_menulayer, s_window);
layer_add_child(window_get_root_layer(s_window), (Layer *)s_menulayer);

#ifdef PBL_SDK_3
// Set up the status bar last to ensure it is on top of other Layers
s_status_bar = status_bar_layer_create();
layer_add_child(window_get_root_layer(s_window), status_bar_layer_get_layer(s_status_bar));
#endif
}

static void destroy_ui(void) {
window_destroy(s_window);
menu_layer_destroy(s_menulayer);

#ifdef PBL_SDK_3
status_bar_layer_destroy(s_status_bar);
#endif
}
// END AUTO-GENERATED UI CODE

Expand Down Expand Up @@ -52,12 +67,12 @@ static int16_t menu_get_cell_height_callback(MenuLayer *menu_layer, MenuIndex *c
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
switch (cell_index->row) {
case MENU_JOB: menu_cell_draw_job(ctx, cell_layer, job_index); break;
case MENU_RESET: menu_cell_draw_other(ctx, cell_layer, "Reset Timer", NULL, bitmap_reset); break;
case MENU_ADD10: menu_cell_draw_other(ctx, cell_layer, "Add 10 Minutes", NULL, bitmap_add); break;
case MENU_SUB10: menu_cell_draw_other(ctx, cell_layer, "Sub 10 Minutes", NULL, bitmap_minus); break;
case MENU_RENAME: menu_cell_draw_other(ctx, cell_layer, "Rename", NULL, bitmap_edit); break;
case MENU_ADJUST: menu_cell_draw_other(ctx, cell_layer, "Set Repeat", NULL, bitmap_adjust); break;
case MENU_DELETE: menu_cell_draw_other(ctx, cell_layer, "Delete", NULL, bitmap_delete); break;
case MENU_RESET: menu_cell_draw_other(ctx, cell_layer, "Reset Timer", NULL, bitmaps[BITMAP_RESET]); break;
case MENU_ADD10: menu_cell_draw_other(ctx, cell_layer, "Add 10 Minutes", NULL, bitmaps[BITMAP_ADD]); break;
case MENU_SUB10: menu_cell_draw_other(ctx, cell_layer, "Sub 10 Minutes", NULL, bitmaps[BITMAP_MINUS]); break;
case MENU_RENAME: menu_cell_draw_other(ctx, cell_layer, "Rename", NULL, bitmaps[BITMAP_EDIT]); break;
case MENU_ADJUST: menu_cell_draw_other(ctx, cell_layer, "Set Repeat", NULL, bitmaps[BITMAP_ADJUST]); break;
case MENU_DELETE: menu_cell_draw_other(ctx, cell_layer, "Delete", NULL, bitmaps[BITMAP_DELETE]); break;
}
}

Expand Down
Loading

0 comments on commit 24ab05f

Please sign in to comment.