int main(void) { appmessage_max_size = app_message_inbox_size_maximum(); if (appmessage_max_size > 4096) appmessage_max_size = 4096; //Limit inbox size to conserve RAM. #ifdef PBL_PLATFORM_APLITE //Aplite has so little memory, we can't squeeze much more than that out of appmessage buffer. appmessage_max_size = 124; #endif app_message_register_inbox_received(received_data); app_message_register_outbox_sent(sent_data); app_message_open(appmessage_max_size, 408); loadingMode = true; send_initial_packet(); app_timer_register(3000, loading_retry_timer, NULL); switchWindow(0); app_event_loop(); window_stack_pop_all(false); free(config_periodicVibrationPattern); AppLaunchReason appLaunchReason = launch_reason(); if (appLaunchReason == APP_LAUNCH_PHONE && !config_dontClose) { // If app was launched by phone and close to last app is disabled, always exit to the watchface instead of to the menu exit_reason_set(APP_EXIT_ACTION_PERFORMED_SUCCESSFULLY); } return 0; }
/////////////////////////////////////////// TIMER ////////////////////////////////////////// static void exit_timer(struct tm* tick_time, TimeUnits units_changed) { if (exit_counter-- <= 0) { vibes_cancel(); window_stack_pop_all(true); vibes_cancel(); } }
void PushNewMenu(MenuDefinition *menuDef) { SetCurrentMenu(menuDef); if(currentMenuDef) { int i = 0; MenuWindow *newMenuWindow = NULL; for(i = 0; i < MAX_MENU_WINDOWS; ++i) { if(!menuWindows[i].inUse) { newMenuWindow = &menuWindows[i]; break; } } if(!newMenuWindow) { window_stack_pop_all(true); return; } newMenuWindow->inUse = true; newMenuWindow->menu = currentMenuDef; newMenuWindow->window = InitializeMenuWindow(newMenuWindow, "Menu", currentMenuDef->animated, currentMenuDef->init ? currentMenuDef->init : MenuInit, currentMenuDef->deinit ? currentMenuDef->deinit : MenuDeinit, currentMenuDef->appear ? currentMenuDef->appear : MenuAppear, currentMenuDef->disappear ? currentMenuDef->disappear : MenuDisappear); } }
static void in_received_handler(DictionaryIterator *iter, void *context) { Tuple *tuple; // send the launch_arg when we receive ready from JS tuple = dict_find(iter, APP_KEY_READY); if (tuple) { DictionaryIterator *iter; app_message_outbox_begin(&iter); dict_write_uint32(iter, APP_KEY_ACTION, launch_get_args()); dict_write_end(iter); app_message_outbox_send(); } // update text tuple = dict_find(iter, APP_KEY_TEXT); if (tuple) { snprintf(text, sizeof(text), "%s", tuple->value->cstring); text_layer_set_text(text_layer, text); } // quit the app tuple = dict_find(iter, APP_KEY_QUIT); if (tuple) { window_stack_pop_all(false); } }
int main() { app_message_register_outbox_sent(data_delivered); app_message_register_inbox_received(received_data); app_message_open(124, 50); DictionaryIterator *iterator; app_message_outbox_begin(&iterator); dict_write_uint8(iterator, 0, 0); dict_write_uint8(iterator, 1, 0); dict_write_uint16(iterator, 2, PROTOCOL_VERSION); #ifdef PBL_PLATFORM_APLITE dict_write_uint8(iterator, 3, 0); #else dict_write_uint8(iterator, 3, 1); #endif app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED); app_message_outbox_send(); switchWindow(0); app_event_loop(); window_stack_pop_all(false); return 0; }
static void go_back_handler(ClickRecognizerRef recognizer, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Back button pressed."); if (hint_layer) { text_layer_destroy(hint_layer); hint_layer = NULL; } else window_stack_pop_all(true); // Exit the app. }
static void auto_close_info_window(void *data) { app_timer = NULL; force_update(); const bool animated = false; window_stack_pop_all(animated); window_stack_push(main_window, true); }
// Handles timer event when app has been idle for X minutes and auto-closes app static void autoclose_handler(void *data) { if (s_autoclose_timer != NULL) { s_autoclose_timer = NULL; if (s_autoclose_timeout != 0 && window_stack_get_top_window() == s_window) { // If autoclose is still enabled and the main window is on top, then exit the app window_stack_pop_all(false); } } }
// Create a button Button *drawing_button_create(void) { Button *button = (Button*)malloc(sizeof(Button)); if (button) { memcpy(button->left, ButtonPlay, sizeof(ButtonPlay)); memcpy(button->right, ButtonPlay, sizeof(ButtonPlay)); button->click_epoch = 0; button->playing = false; button->ani_done = true; return button; } // error handling APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to create button"); window_stack_pop_all(false); return NULL; }
int main(void) { app_message_register_inbox_received(received_data); app_message_register_outbox_sent(data_sent); app_message_open(124, 50); inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168)); switchWindow(0); app_timer_register(300, timerTriggered, NULL); app_event_loop(); inverter_layer_destroy(inverter_layer); window_stack_pop_all(false); return 0; }
void simply_window_stack_show(SimplyWindowStack *self, SimplyWindow *window, bool is_push) { bool animated = (self->simply->splash == NULL); self->is_showing = true; window_stack_pop_all(!is_push); self->is_showing = false; if (is_push) { window_stack_push(self->pusher, false); } window_stack_push(window->window, animated); if (is_push) { window_stack_remove(self->pusher, false); } }
// Destroys the objects created by create_objects(). void destroy_objects() { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "destroy_objects"); window_stack_pop_all(false); layer_destroy(clock_face_layer); clock_face_layer = NULL; bwd_destroy(&clock_face); face_index = -1; #ifdef MAKE_CHRONOGRAPH destroy_chrono_objects(); #endif // MAKE_CHRONOGRAPH deinit_battery_gauge(); deinit_bluetooth_indicator(); for (int i = 0; i < NUM_DATE_WINDOWS; ++i) { layer_destroy(date_window_layers[i]); date_window_layers[i] = NULL; } bwd_destroy(&date_window); bwd_destroy(&date_window_mask); #ifdef SUPPORT_MOON bwd_destroy(&moon_bitmap); #endif // SUPPORT_MOON layer_destroy(minute_layer); layer_destroy(hour_layer); layer_destroy(second_layer); hand_cache_destroy(&hour_cache); hand_cache_destroy(&minute_cache); hand_cache_destroy(&second_cache); if (date_lang_font != NULL) { safe_unload_custom_font(&date_lang_font); } display_lang = -1; window_destroy(window); window = NULL; }
int main(void) { app_message_register_inbox_received(received_data); app_message_register_outbox_sent(data_sent); app_message_open(124, 50); switchWindow(0); DictionaryIterator *iterator; app_message_outbox_begin(&iterator); dict_write_uint8(iterator, 0, 0); app_message_outbox_send(); app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED); app_comm_set_sniff_interval(SNIFF_INTERVAL_NORMAL); app_event_loop(); window_stack_pop_all(false); return 0; }
/* * down_single_click_handler removes the current watchface, to the main window, and then * rotates to the last watchface */ void down_single_click_handler(ClickRecognizerRef recognizer, void *context) { switch (current_window) { case 0: for (int i = 0; i < MAX_WATCH_FACES; i ++) { window_stack_push(watchfaces[i].window, true); } current_window=3; break; case 1: case 2: case 3: window_stack_pop(true); current_window--; break; default: APP_LOG(APP_LOG_LEVEL_DEBUG, "up_single_click_handler: bad current_window: %d", current_window); window_stack_pop_all(true); window_stack_push(mainwindow, true); current_window = 0; break; } }
static void outbox_sent_callback(DictionaryIterator *iterator, void *context) { APP_LOG(APP_LOG_LEVEL_INFO, "Outbox send success!"); window_stack_pop_all(true); }
//******************** Events ********************// static void on_app_done(void* context) { window_stack_pop_all(false); }
void end_run(int index, void* context) { destroy_run_menu_controller(active_controller); window_stack_pop_all(true); }
static void received_data(DictionaryIterator *received, void *context) { app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED); uint8_t destModule = dict_find(received, 0)->value->uint8; uint8_t packetId = dict_find(received, 1)->value->uint8; bool autoSwitch = dict_find(received, 999) != NULL; if (destModule == 0 && packetId == 0) { received_config(received); return; } if (!gotConfig) //Do not react to anything until we got config return; if (destModule == 0) { if (packetId == 1) { closingMode = true; window_stack_pop_all(false); switchWindow(0); return; } if (curWindow != 0) { if (autoSwitch) switchWindow(0); else return; } main_menu_data_received(packetId, received); } else if (destModule == 1) { if (curWindow != 1) { if (autoSwitch) switchWindow(1); else return; } call_window_data_received(destModule, packetId, received); } else if (destModule == 2) { if (curWindow != 2) { if (autoSwitch) switchWindow(2); else return; } call_log_window_data_received(packetId, received); } else if (destModule == 3) { if (curWindow != 3) { if (autoSwitch) switchWindow(3); else return; } contacts_window_data_received(packetId, received); } else if (destModule == 4) { if (curWindow != 4) { if (autoSwitch) switchWindow(4); else return; } number_picker_window_data_received(packetId, received); } else if (destModule == 5) { actions_menu_got_data(packetId, received); } }
static void exit_timeout() { if (auto_exit_enable) window_stack_pop_all(true); }
//Recognizes when user hits back on s_menu_window //IRONICALLY DOES NOT WORK ON S_MENU static void back_handler(ClickRecognizerRef recognizer, void *context) { window_stack_pop_all(true); //Click back at any time to exit app }
static void graph_click_handler(ClickRecognizerRef recognizer, void *context){ window_stack_pop_all(true); }
void success_auto_close(void* context) { exit_reason_set(APP_EXIT_ACTION_PERFORMED_SUCCESSFULLY); window_stack_pop_all(true); }
// Close the app after a period of inactivity (to prevent accidentally operating devices) void inactivity_timeout(void *data) { inactivity_timer = NULL; window_stack_pop_all(true); }
void quitApp() { window_stack_pop_all(true); }