evil_portal_scene_rename.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "../evil_portal_app_i.h"
  2. #include "../helpers/evil_portal_storage.h"
  3. void evil_portal_text_input_callback(void* context) {
  4. furi_assert(context);
  5. Evil_PortalApp* app = context;
  6. view_dispatcher_send_custom_event(app->view_dispatcher, Evil_PortalEventTextInput);
  7. }
  8. void evil_portal_scene_rename_on_enter(void *context) {
  9. Evil_PortalApp *app = context;
  10. TextInput* text_input = app->text_input;
  11. size_t enter_name_length = 25;
  12. evil_portal_read_ap_name(app);
  13. text_input_set_header_text(text_input, "AP Name/SSID");
  14. strncpy(app->text_store[0], (char *)app->ap_name, enter_name_length);
  15. text_input_set_result_callback(
  16. text_input,
  17. evil_portal_text_input_callback,
  18. context,
  19. app->text_store[0],
  20. enter_name_length,
  21. false);
  22. view_dispatcher_switch_to_view(app->view_dispatcher, Evil_PortalAppViewTextInput);
  23. }
  24. bool evil_portal_scene_rename_on_event(void *context, SceneManagerEvent event) {
  25. Evil_PortalApp *app = context;
  26. SceneManager* scene_manager = app->scene_manager;
  27. bool consumed = false;
  28. if(event.type == SceneManagerEventTypeCustom) {
  29. evil_portal_write_ap_name(app);
  30. scene_manager_search_and_switch_to_previous_scene(
  31. scene_manager, Evil_PortalSceneStart);
  32. consumed = true;
  33. }
  34. return consumed;
  35. }
  36. void evil_portal_scene_rename_on_exit(void *context) {
  37. Evil_PortalApp *app = context;
  38. variable_item_list_reset(app->var_item_list);
  39. }