static void message_handler(DictionaryIterator *received, void *context) { bool refresh_window = 0; app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "this is message_handler"); /* options */ Tuple *tuple_black_on_white = dict_find(received, OPTION_BLACK_ON_WHITE); Tuple *tuple_show_date = dict_find(received, OPTION_SHOW_DATE); Tuple *tuple_show_battery = dict_find(received, OPTION_SHOW_BATTERY); Tuple *tuple_larger_clock_font = dict_find(received, OPTION_LARGER_CLOCK_FONT); /* options */ if (tuple_black_on_white) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_black_on_white"); refresh_window = 1; black_on_white = (bool)tuple_black_on_white->value->int32; } if (tuple_show_date) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_data"); refresh_window = 1; show_date = (bool)tuple_show_date->value->int32; } if (tuple_show_battery) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_battery"); refresh_window = 1; show_battery = (bool)tuple_show_battery->value->int32; } if (tuple_larger_clock_font) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_larger_clock_font"); refresh_window = 1; larger_clock_font = (bool)tuple_larger_clock_font->value->int32; } /* options */ persist_write_bool(OPTION_BLACK_ON_WHITE, black_on_white); persist_write_bool(OPTION_SHOW_DATE, show_date); persist_write_bool(OPTION_SHOW_BATTERY, show_battery); persist_write_bool(OPTION_LARGER_CLOCK_FONT, larger_clock_font); if (refresh_window) { main_window_unload(s_main_window); main_window_destroy(); main_window_create(); main_window_load(s_main_window); } }
void custom_main_window_load(Window *window) { Layer *window_layer=window_get_root_layer(window); #ifdef BG_IMAGE_GRECT GRect bounds=BG_IMAGE_GRECT; /* Hand crafted */ #else /* BG_IMAGE_GRECT */ GRect bounds=layer_get_bounds(window_layer); /* screen size, center image */ #endif /* BG_IMAGE_GRECT */ // Create GBitmap, then set to created BitmapLayer s_background_bitmap_main = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MAIN); s_background_bitmap_alt = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ALT); s_background_layer = bitmap_layer_create(bounds); #ifdef FAST_SWITCH /* show s_bg_image and then within 1 second show the next image */ if (s_bg_image == RESOURCE_ID_IMAGE_MAIN) #else /* not FAST_SWITCH */ /* ** set reverse image, TICK_HANDLER()/custom_tick_handler() is called ** almost immediately which will toggle the image */ if (s_bg_image != RESOURCE_ID_IMAGE_MAIN) #endif /* FAST_SWITCH/KEEP_IMAGE */ { bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap_main); } else { bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap_alt); } #ifdef PBL_COLOR bitmap_layer_set_compositing_mode(s_background_layer, GCompOpSet); #else /* PBL_BW MONO */ bitmap_layer_set_compositing_mode(s_background_layer, GCompOpAssign); #endif window_set_background_color(main_window, background_color); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); /* End of custom code, call generic code */ main_window_load(window); }