// Here we capture when a user selects a menu item void reply_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) { ReplyWindow * rw = (ReplyWindow*)data; #ifndef PBL_PLATFORM_APLITE if (rw->replies==&dictationFailedRL) { window_stack_pop(false); return; } #endif APP_LOG(APP_LOG_LEVEL_DEBUG,"You clicked on %s" , rw->replies->values[cell_index->row]); int row = cell_index->row; if (strcmp(rw->replies->values[row],"Dictate")==0) { #ifndef PBL_PLATFORM_APLITE dictation_session_start(dictsess); #endif } else if (strcmp(rw->replies->values[row],"Emoji")==0) { emojiRL.values=emojiList; emojiRL.num=ARRAY_LENGTH(emojiList); replywindow_create(rw->replyChan,rw->replyTo,&emojiRL); } else { static char msg[100]; snprintf(msg,100,"%s%c%s%s", rw->replyChan->id,0x7f,rw->replyTo,rw->replies->values[row]); sendCommand("MESSAGE",msg); bool pop2 = rw->replies->values==emojiList; window_stack_pop(false); if (pop2) { window_stack_pop(false); } } }
void headingSelected(NumberWindow *window, void * context){; static char msg[20]; snprintf(msg, 20, "%d;%d",selectedIndex,(int) number_window_get_value(window)); send_to_phone( MyTupletCString(105, msg)); //index maps to courseIdx! vibes_short_pulse(); number_window_destroy(degrees_window); window_stack_pop(true); //close this window (number window) window_stack_pop(true); //close this window (course menu) }
static void menu_select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data ) { switch(cell_index->row) { case 0: { window_stack_pop(true); answer_question(QUESTION_ANSWER_SKIP); break; } case 1: { window_stack_pop(true); answer_question(QUESTION_ANSWER_REPORT); break; } } }
void shake_handler(AccelAxisType axis, int32_t direction){ switch(main_settings.shakeAction){ case SHAKE_USE_CHANGE_SWEAR_WORD: app_timer_cancel(animate_word_timer); app_timer_cancel(update_word_timer); animate_word_timer = app_timer_register(50, fire_animation_callback, NULL); update_word_timer = app_timer_register(850, update_word_callback, NULL); break; case SHAKE_USE_LAUNCH_EXTRA_SCREEN: if(!extra_window_is_loaded()){ extra_window_update_settings(main_settings); window_stack_push(extra_window_get_window(), true); } else{ window_stack_pop(true); } break; case SHAKE_USE_SIMPLICITY: if(simplicity_is_loaded()){ simplicity_pop(); tick_timer_service_subscribe(SECOND_UNIT, tick_handler); } else{ tick_timer_service_unsubscribe(); simplicity_push(); } break; } }
static void ease_menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) { if (cell_index->row == 0) { send(KEY_EASE, 1); } switch(s_ease) { case 2: if(cell_index->row == 1) { send(KEY_EASE, 3); } break; case 3: if(cell_index->row == 1) { send(KEY_EASE, 3); } else if(cell_index->row == 2) { send(KEY_EASE, 4); } break; case 4: if(cell_index->row == 1) { send(KEY_EASE, 2); } else if(cell_index->row == 2) { send(KEY_EASE, 3); } else if(cell_index->row == 3) { send(KEY_EASE, 4); } break; } window_stack_pop(true); }
static void inbox_received_callback(DictionaryIterator *iterator, void *context){ Tuple *minutes = dict_find(iterator, VIBE_TIME); if(minutes){ mins = minutes->value->uint8; persist_write_int(KEY_MINUTES, mins); } Tuple *center_t = dict_find(iterator, CENTER); if(center_t){ center = center_t->value->int8; persist_write_bool(CENTER, center); window_stack_pop(false); deinit(); init(); } Tuple *date = dict_find(iterator, SHOW_DATE); if(date){ accel_tap_service_unsubscribe(); if(date->value->int8){ accel_tap_service_subscribe(accel_tap_handler); } } }
static void time_window_pop() { if(window_is_loaded(s_time_window)) { window_stack_pop(true); checktime = time(NULL); update_count(); } }
void out_sent_handler(DictionaryIterator *sent, void *context){ // outgoing message was delivered // go back to the home page and remove all the top layers // successfull call means...nothing should happen, right? // prescreen_deinit(); // this is a test window_stack_pop(true); }
static void select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Got a click for row %d", cell_index->row); if (hint_layer) { text_layer_destroy(hint_layer); hint_layer = NULL; } if (cell_index->row > 0) { app_timer_reschedule(locationtimer, 1000 * (nextcall + 10)); if (cell_index->row == 1) { strcpy(command, "set"); text_layer_set_text(distance_layer, "0"); } else snprintf(command, sizeof(command), "set%d", (cell_index->row)-2); DictionaryIterator *iter; app_message_outbox_begin(&iter); if (iter == NULL) { vibes_short_pulse(); APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send command %s to phone!", command); return; } dict_write_cstring(iter, CMD_KEY, command); const uint32_t final_size = dict_write_end(iter); app_message_outbox_send(); APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent command '%s' to phone! (%d bytes)", command, (int) final_size); } window_stack_pop(animated); }
static void select_long_click_handler(ClickRecognizerRef recognizer, void* context) { if (common_long(MID)) return; // blackout = !blackout; // // if (blackout) // text_layer_set_background_color(text_layer, GColorBlack); // else // text_layer_set_background_color(text_layer, GColorClear); // clear the string /*pos = 0; for (int i=0; i<TEXT_LENGTH; i++) text_buffer[i] = ' '; drawNotepadText(); change_set(cur_set, false); next(); drawSides();*/ strncpy(return_text,text_buffer,DESCRIPTION_LENGTH); window_stack_pop(true); }
void settings_select_single_click_handler(ClickRecognizerRef recognizer, void *context) { // For Select Feature - Set Settings & return to main Window persist_write_int(0, units); send_cmd(); window_stack_pop(true); window_stack_push(window, true); }
void statuswindow_timeout(void *callback_data) { app_timer_cancel(statuswindow_timer); statuswindow_timer = NULL; window_stack_pop(true); }
static void inbox_received_callback(DictionaryIterator *iterator, void *context) { // Read first item Tuple *t = dict_read_first(iterator); text_layer_set_text( title_layer, title ); // For all items while(t != NULL) { // Which key was received? APP_LOG(APP_LOG_LEVEL_DEBUG, "Loop index now %s", t->value->cstring); switch(t->key) { case KEY_ABSTRACT: snprintf(abstract, sizeof(abstract), "%s", t->value->cstring); break; case KEY_TITLE: snprintf(title, sizeof(title), "%s", t->value->cstring); break; default: snprintf( title, sizeof(abstract), "%s", t->value->cstring ); break; } text_layer_set_text( word_layer, abstract );// Look for next item app_timer_register( (200+10*( strlen(abstract) )), (AppTimerCallback) refresh, NULL); psleep(500); t = dict_read_next(iterator); } window_stack_pop(true); }
static void back_click_handler(ClickRecognizerRef recognizer, void *context) { if (s_state == BEGINNING_STATE) { window_stack_pop(true); } else if (s_state == CHECKING_CONTACT_STATE && has_contact) { // contact_try++; // get_contact(); // has_contact = false; } else if (s_state == CREATING_FINAL_MESSAGE_STATE) { reset_all(); snprintf(instruction_text, sizeof(instruction_text), "%s", "Choose recipient"); text_layer_set_text(s_instruction_layer, instruction_text); primary_text[0] = '\0'; text_layer_set_text(s_primary_layer, primary_text); } else if (s_state == CONFIRMING_FINAL_MESSAGE_STATE) { change_state(CREATING_FINAL_MESSAGE_STATE); dictated_message[0] = '\0'; snprintf(instruction_text, sizeof(instruction_text), "%s", "Create message"); snprintf(primary_text, sizeof(primary_text), "%s", contact_name); text_layer_set_text(s_instruction_layer, instruction_text); text_layer_set_text(s_primary_layer, primary_text); // dictated_message[0] = '\0'; // snprintf(primary_text, sizeof(primary_text), "%s", dictated_message); // text_layer_set_text(s_primary_layer, primary_text); // change_state(CREATING_FINAL_MESSAGE_STATE); } }
static void select_single_click_handler(ClickRecognizerRef recognizer, void* context) { if (actions_menu_is_displayed()) { int16_t pickedItem = actions_menu_get_selected_index(); if (pickedItem == 0) { nw_send_reply_text(text_buffer); actions_menu_hide(); window_stack_pop(true); } else { char* copySource = actions_menu_get_action_text(pickedItem); int sourceLength = strlen(copySource); if (sourceLength + pos < MAX_CHARS) { strcpy(&text_buffer[pos], copySource); pos += sourceLength; drawNotepadText(); actions_menu_hide(); } } return; } clickButton(MID); }
static void back_single_click_handler(ClickRecognizerRef recognizer, void* context) { if (actions_menu_is_displayed()) actions_menu_hide(); else window_stack_pop(true); }
void nw_remove_notification(uint8_t id, bool closeAutomatically) { if (numOfNotifications <= 1 && closeAutomatically) { tertiary_text_window_close(); window_stack_pop(true); return; } remove_notification_from_storage(id); bool differentNotification = pickedNotification == id; if (pickedNotification >= id && pickedNotification > 0) { pickedNotification--; } if (differentNotification) { actions_menu_hide(); tertiary_text_window_close(); nw_switch_to_notification(pickedNotification); } }
/** * Handles the Back Button Presses */ static void back_click_handler(ClickRecognizerRef recognizer, void *context) { status.end = true; //free(status.timer); status.timer = NULL; window_stack_pop(true); }
static void prv_goal_reached_wait_timer_handler(void *context) { GoalStarGoalEventWindowData *data = context; if (data) { data->goal_reached_sequence_timer = NULL; } window_stack_pop(true /* animated */); }
static void second_tick(void) { elapsedTime++; if (appIdle && config_timeout > 0 && config_timeout < elapsedTime && main_noMenu) { window_stack_pop(true); return; } if (lightOn && elapsedTime >= config_lightTimeout) { lightOn = false; light_enable(false); } if (periodicVibrationPeriod > 0 && appIdle && elapsedTime > 0 && elapsedTime % periodicVibrationPeriod == 0 && !nw_get_displayed_notification()->inList && canVibrate() && (config_periodicTimeout == 0 || elapsedTime < config_periodicTimeout)) { VibePattern pat = { .durations = config_periodicVibrationPattern, .num_segments = config_periodicVibrationPatternSize / 2, }; nw_vibrate(&pat, config_periodicVibrationTotalDuration); } nw_ui_update_statusbar_clock(); }
// Menu callback void select_menu_callback(int index, void *context) { app_message_outbox_begin(&iter); static char* select_action; if (strcmp(menu_action, "c") == 0) { select_action = "selClient"; } else if(strcmp(menu_action, "t") == 0) { select_action = "selTask"; snprintf(task_title, 40, "Task:\n%s", list_menu_items[index].title); text_layer_set_text(task_layer, task_title); } else if (strcmp(menu_action, "p") == 0) { select_action = "selProj"; snprintf(project_title, 40, "Project:\n%s", list_menu_items[index].title); text_layer_set_text(task_layer, project_title); } else { // strcmp failed to find a match APP_LOG(APP_LOG_LEVEL_DEBUG, "No match on strcmp, value of menu_action follows"); APP_LOG(APP_LOG_LEVEL_DEBUG, menu_action); } Tuplet action_type = TupletCString(0, select_action); dict_write_tuplet(iter, &action_type); Tuplet selected = TupletInteger(1, index); dict_write_tuplet(iter, &selected); app_message_outbox_send(); // this send is causing crash :S //pop the menu off window_stack_pop(true); }
static void game_logic() { // Per-frame game logic here if(get_current_state() == STATE_SPLASH) { psleep(MENUPSLEEPTIME); // Trying to save the battery! } else if(get_current_state() == STATE_SHOWMAINMENU) { main_menu_create(); } else if(get_current_state() == STATE_MARATHON) { race_reset_cars(); race_set_difficulty(DIFFICULTY); track_set_length(14000); main_menu_destroy(); switch_on_light(50000); set_current_state(STATE_BEFORERACE); } else if(get_current_state() == STATE_SPRINT) { race_reset_cars(); race_set_difficulty(DIFFICULTY); track_set_length(7000); main_menu_destroy(); switch_on_light(35000); set_current_state(STATE_BEFORERACE); } else if(get_current_state() == STATE_BEFORERACE) { race_result_create_position_layers(); race_place_cars_on_grid(); race_set_start_time(); set_current_state(STATE_RACING); } else if(get_current_state() == STATE_RACING) { race_frame_update(); } else if(get_current_state() == STATE_AFTERRESULTS) { psleep(MENUPSLEEPTIME); // Trying to save the battery! } else if(get_current_state() == STATE_QUITTING) { APP_LOG(APP_LOG_LEVEL_DEBUG, "!!! QUITTING from horizontalboost !!!!"); window_stack_pop(false); } }
void show_message(char message[]){ window_stack_pop(true); window_stack_push(message_window, true); set_message(message); last_screen = current_screen; current_screen = SCREEN_MESSAGE_KEY; }
void simply_window_stack_pop(SimplyWindowStack *self, SimplyWindow *window) { self->is_hiding = true; if (window->window == window_stack_get_top_window()) { bool animated = true; window_stack_pop(animated); } self->is_hiding = false; }
void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, void *context){ // outgoing message failed // do nothing for now // display some kind of error message that can only be dismissed by pressing a button // then go back to the home page // stack.pop, stack.pop window_stack_pop(true); }
static void select_callback(int index, void *context) { int * pointerToValue = (int*) context; if(* pointerToValue == 0){ send_to_phone( TupletInteger(101, index)); //index maps to courseIdx! vibes_short_pulse(); window_stack_pop(true); //close this window (course menu) } }
// Show window void show_error(char *error_title, char *error_desc) { window_stack_pop(false); initialise_ui(); text_layer_set_text(error_title_text_layer, error_title); text_layer_set_text(error_description_text_layer, error_desc); window_set_window_handlers(s_window, (WindowHandlers) { .unload = handle_window_unload, });
static void resort_unload(Window *resort) { text_layer_destroy(resort_top_text_layer); text_layer_destroy(resort_center_text_layer); text_layer_destroy(resort_bottom_text_layer); action_bar_layer_destroy(resort_action_bar); gbitmap_destroy(right_arrow_icon); window_stack_pop(true); }
void sms_select_callback(int index, void *context) { for(int i=0;i<3;i++){ window_stack_pop(false); } //window_stack_pop_all(false); }
void out_sent_handler(DictionaryIterator *sent, void *context) { // outgoing message was delivered // When the application returns an ACK of OK, // Pop the window and exit the applicaiton. window_stack_pop(true); }