Replace sleep icon with new app logo
This commit is contained in:
20
package.json
20
package.json
@@ -38,12 +38,24 @@
|
|||||||
"name": "LOGO_25",
|
"name": "LOGO_25",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"menuIcon": true
|
"menuIcon": true,
|
||||||
|
"targetPlatforms": [
|
||||||
|
"basalt",
|
||||||
|
"chalk",
|
||||||
|
"emery",
|
||||||
|
"gabbro"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "raw",
|
"file": "logo_25_no_aa.png",
|
||||||
"name": "SLEEP_ICON",
|
"memoryFormat": "Smallest",
|
||||||
"file": "sleep.pdc"
|
"name": "LOGO_25",
|
||||||
|
"spaceOptimization": "storage",
|
||||||
|
"type": "bitmap",
|
||||||
|
"targetPlatforms": [
|
||||||
|
"diorite",
|
||||||
|
"flint"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "raw",
|
"type": "raw",
|
||||||
|
|||||||
BIN
resources/logo_25_no_aa.png
Normal file
BIN
resources/logo_25_no_aa.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 154 B |
Binary file not shown.
46
src/c/main.c
46
src/c/main.c
@@ -17,19 +17,19 @@ static TextLayer *s_sleep_time_layer;
|
|||||||
static TextLayer *s_last_watched_layer;
|
static TextLayer *s_last_watched_layer;
|
||||||
static Layer *s_button_bar_layer;
|
static Layer *s_button_bar_layer;
|
||||||
static Layer *s_sleep_bar_layer;
|
static Layer *s_sleep_bar_layer;
|
||||||
static Layer *s_sleep_icon_layer;
|
static BitmapLayer *s_logo_layer;
|
||||||
static Layer *s_pin_icon_layer;
|
static Layer *s_pin_icon_layer;
|
||||||
static GDrawCommandImage *s_sleep_icon;
|
static GBitmap *s_logo;
|
||||||
static GDrawCommandImage *s_pin_icon;
|
static GDrawCommandImage *s_pin_icon;
|
||||||
static const uint8_t s_icon_width = 25;
|
static const uint8_t s_icon_width = 25;
|
||||||
#if PBL_ROUND
|
#if PBL_ROUND
|
||||||
#if PBL_DISPLAY_WIDTH >= 200
|
#if PBL_DISPLAY_WIDTH >= 200
|
||||||
static const uint8_t s_sleep_bar_drop = 53;
|
static const uint8_t s_sleep_bar_drop = 54;
|
||||||
#else
|
#else
|
||||||
static const uint8_t s_sleep_bar_drop = 49;
|
static const uint8_t s_sleep_bar_drop = 50;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
static const uint8_t s_sleep_bar_drop = 31;
|
static const uint8_t s_sleep_bar_drop = 34;
|
||||||
#endif
|
#endif
|
||||||
#if PBL_DISPLAY_WIDTH >= 200
|
#if PBL_DISPLAY_WIDTH >= 200
|
||||||
#define LW_FONT_SIZE 28
|
#define LW_FONT_SIZE 28
|
||||||
@@ -39,7 +39,7 @@ static const uint8_t s_sleep_bar_drop = 31;
|
|||||||
|
|
||||||
// declare animation statics
|
// declare animation statics
|
||||||
static GRect s_sleep_bar_start = GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT);
|
static GRect s_sleep_bar_start = GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT);
|
||||||
static GRect s_sleep_icon_start = GRect((PBL_DISPLAY_WIDTH / 2) - 13, (PBL_DISPLAY_HEIGHT / 2) - 12, s_icon_width, s_icon_width);
|
static GRect s_logo_start = GRect((PBL_DISPLAY_WIDTH / 2) - 13, (PBL_DISPLAY_HEIGHT / 2) - 17, s_icon_width, s_icon_width);
|
||||||
|
|
||||||
// declare time tracking statics
|
// declare time tracking statics
|
||||||
static time_t s_sleep_timestamp;
|
static time_t s_sleep_timestamp;
|
||||||
@@ -94,11 +94,6 @@ static void sleep_bar_update_proc(Layer *layer, GContext *ctx) {
|
|||||||
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep_icon_update_proc(Layer *layer, GContext *ctx) {
|
|
||||||
graphics_context_set_antialiased(ctx, false);
|
|
||||||
gdraw_command_image_draw(ctx, s_sleep_icon, GPoint(0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void draw_pin() {
|
static void draw_pin() {
|
||||||
GDrawCommandList *command_list = gdraw_command_image_get_command_list(s_pin_icon);
|
GDrawCommandList *command_list = gdraw_command_image_get_command_list(s_pin_icon);
|
||||||
const uint32_t command_count = gdraw_command_list_get_num_commands(command_list);
|
const uint32_t command_count = gdraw_command_list_get_num_commands(command_list);
|
||||||
@@ -125,10 +120,10 @@ static void main_window_load(Window *window) {
|
|||||||
if (s_is_jellyfin == 0) {
|
if (s_is_jellyfin == 0) {
|
||||||
window_set_background_color(window, GColorWhite);
|
window_set_background_color(window, GColorWhite);
|
||||||
#if PBL_DISPLAY_WIDTH >= 200
|
#if PBL_DISPLAY_WIDTH >= 200
|
||||||
s_config_app_layer = text_layer_create(GRect(4, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(33, 49), PBL_DISPLAY_WIDTH - 8, PBL_DISPLAY_HEIGHT));
|
s_config_app_layer = text_layer_create(GRect(s_margin, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(33, 49), PBL_DISPLAY_WIDTH - 8, PBL_DISPLAY_HEIGHT));
|
||||||
text_layer_set_font(s_config_app_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
|
text_layer_set_font(s_config_app_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
|
||||||
#else
|
#else
|
||||||
s_config_app_layer = text_layer_create(GRect(4, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(43, 32), PBL_DISPLAY_WIDTH - 8, PBL_DISPLAY_HEIGHT));
|
s_config_app_layer = text_layer_create(GRect(s_margin, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(43, 32), PBL_DISPLAY_WIDTH - 8, PBL_DISPLAY_HEIGHT));
|
||||||
text_layer_set_font(s_config_app_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_24_BOLD, FONT_KEY_GOTHIC_18_BOLD)));
|
text_layer_set_font(s_config_app_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_24_BOLD, FONT_KEY_GOTHIC_18_BOLD)));
|
||||||
#endif
|
#endif
|
||||||
text_layer_set_background_color(s_config_app_layer, GColorClear);
|
text_layer_set_background_color(s_config_app_layer, GColorClear);
|
||||||
@@ -140,8 +135,9 @@ static void main_window_load(Window *window) {
|
|||||||
|
|
||||||
// sleep bar and icon
|
// sleep bar and icon
|
||||||
s_sleep_bar_layer = layer_create(s_sleep_bar_start);
|
s_sleep_bar_layer = layer_create(s_sleep_bar_start);
|
||||||
s_sleep_icon_layer = layer_create(s_sleep_icon_start);
|
s_logo_layer = bitmap_layer_create(s_logo_start);
|
||||||
layer_set_update_proc(s_sleep_icon_layer, sleep_icon_update_proc);
|
bitmap_layer_set_compositing_mode(s_logo_layer, GCompOpSet);
|
||||||
|
bitmap_layer_set_bitmap(s_logo_layer, s_logo);
|
||||||
|
|
||||||
// pin icon
|
// pin icon
|
||||||
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - PBL_IF_ROUND_ELSE(s_icon_width + 3, s_icon_width), (PBL_DISPLAY_HEIGHT / 2) - 13, s_icon_width, s_icon_width));
|
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - PBL_IF_ROUND_ELSE(s_icon_width + 3, s_icon_width), (PBL_DISPLAY_HEIGHT / 2) - 13, s_icon_width, s_icon_width));
|
||||||
@@ -150,11 +146,11 @@ static void main_window_load(Window *window) {
|
|||||||
|
|
||||||
s_last_watched_layer = text_layer_create(GRect(0, 0, 0, 0)); // placeholder, updated when layer is written to
|
s_last_watched_layer = text_layer_create(GRect(0, 0, 0, 0)); // placeholder, updated when layer is written to
|
||||||
#if PBL_DISPLAY_WIDTH >= 200
|
#if PBL_DISPLAY_WIDTH >= 200
|
||||||
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(21, -2), PBL_DISPLAY_WIDTH, 30));
|
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(22, -2), PBL_DISPLAY_WIDTH, 30));
|
||||||
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
|
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
|
||||||
#else
|
#else
|
||||||
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(24, -2), PBL_DISPLAY_WIDTH, 30));
|
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(25, -2), PBL_DISPLAY_WIDTH, 30));
|
||||||
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_18_BOLD, FONT_KEY_GOTHIC_24_BOLD)));
|
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_18_BOLD, FONT_KEY_GOTHIC_24_BOLD)));
|
||||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
||||||
#endif
|
#endif
|
||||||
@@ -176,7 +172,7 @@ static void main_window_load(Window *window) {
|
|||||||
} else {
|
} else {
|
||||||
#if PBL_RECT
|
#if PBL_RECT
|
||||||
#if PBL_DISPLAY_WIDTH >= 200
|
#if PBL_DISPLAY_WIDTH >= 200
|
||||||
text_layer_set_text(s_sleep_time_layer, " No sleep time found");
|
text_layer_set_text(s_sleep_time_layer, " No sleep time found");
|
||||||
#else
|
#else
|
||||||
text_layer_set_text(s_sleep_time_layer, " No sleep time");
|
text_layer_set_text(s_sleep_time_layer, " No sleep time");
|
||||||
#endif
|
#endif
|
||||||
@@ -207,7 +203,7 @@ static void main_window_load(Window *window) {
|
|||||||
layer_add_child(window_layer, s_pin_icon_layer);
|
layer_add_child(window_layer, s_pin_icon_layer);
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_last_watched_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_last_watched_layer));
|
||||||
layer_add_child(window_layer, s_sleep_bar_layer);
|
layer_add_child(window_layer, s_sleep_bar_layer);
|
||||||
layer_add_child(window_layer, s_sleep_icon_layer);
|
layer_add_child(window_layer, bitmap_layer_get_layer(s_logo_layer));
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_sleep_time_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_sleep_time_layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +214,7 @@ static void main_window_unload(Window *window) {
|
|||||||
pin_animation_deinit();
|
pin_animation_deinit();
|
||||||
text_layer_destroy(s_last_watched_layer);
|
text_layer_destroy(s_last_watched_layer);
|
||||||
text_layer_destroy(s_sleep_time_layer);
|
text_layer_destroy(s_sleep_time_layer);
|
||||||
layer_destroy(s_sleep_icon_layer);
|
bitmap_layer_destroy(s_logo_layer);
|
||||||
layer_destroy(s_sleep_bar_layer);
|
layer_destroy(s_sleep_bar_layer);
|
||||||
layer_destroy(s_pin_icon_layer);
|
layer_destroy(s_pin_icon_layer);
|
||||||
layer_destroy(s_button_bar_layer);
|
layer_destroy(s_button_bar_layer);
|
||||||
@@ -340,10 +336,10 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
|||||||
PropertyAnimation *sleep_bar_prop = property_animation_create_layer_frame(s_sleep_bar_layer, &s_sleep_bar_start, &GRect(0, -PBL_DISPLAY_HEIGHT + s_sleep_bar_drop, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
PropertyAnimation *sleep_bar_prop = property_animation_create_layer_frame(s_sleep_bar_layer, &s_sleep_bar_start, &GRect(0, -PBL_DISPLAY_HEIGHT + s_sleep_bar_drop, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||||
Animation *sleep_bar_anim = property_animation_get_animation(sleep_bar_prop);
|
Animation *sleep_bar_anim = property_animation_get_animation(sleep_bar_prop);
|
||||||
animation_set_duration(sleep_bar_anim, 512);
|
animation_set_duration(sleep_bar_anim, 512);
|
||||||
PropertyAnimation *sleep_icon_prop = property_animation_create_layer_frame(s_sleep_icon_layer, &s_sleep_icon_start, &GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, s_icon_width, s_icon_width));
|
PropertyAnimation *logo_prop = property_animation_create_layer_frame(bitmap_layer_get_layer(s_logo_layer), &s_logo_start, &GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, s_margin), 3, s_icon_width, s_icon_width));
|
||||||
Animation *sleep_icon_anim = property_animation_get_animation(sleep_icon_prop);
|
Animation *logo_anim = property_animation_get_animation(logo_prop);
|
||||||
animation_set_duration(sleep_icon_anim, 512);
|
animation_set_duration(logo_anim, 512);
|
||||||
Animation *load_spawn_anim = animation_spawn_create(sleep_bar_anim, sleep_icon_anim, NULL);
|
Animation *load_spawn_anim = animation_spawn_create(sleep_bar_anim, logo_anim, NULL);
|
||||||
animation_set_handlers(load_spawn_anim, (AnimationHandlers){.stopped = load_complete_animation_handler}, NULL);
|
animation_set_handlers(load_spawn_anim, (AnimationHandlers){.stopped = load_complete_animation_handler}, NULL);
|
||||||
animation_schedule(load_spawn_anim);
|
animation_schedule(load_spawn_anim);
|
||||||
return;
|
return;
|
||||||
@@ -374,7 +370,7 @@ static void init() {
|
|||||||
s_color_secondary = GColorWhite;
|
s_color_secondary = GColorWhite;
|
||||||
#endif
|
#endif
|
||||||
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ICON);
|
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ICON);
|
||||||
s_sleep_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_SLEEP_ICON);
|
s_logo = gbitmap_create_with_resource(RESOURCE_ID_LOGO_25);
|
||||||
|
|
||||||
// initialize pkjs
|
// initialize pkjs
|
||||||
app_message_register_inbox_received(inbox_received_handler);
|
app_message_register_inbox_received(inbox_received_handler);
|
||||||
|
|||||||
Reference in New Issue
Block a user