evil_portal_scene_rename.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. //(char *)app->ap_name,
  21. enter_name_length,
  22. false);
  23. view_dispatcher_switch_to_view(app->view_dispatcher, Evil_PortalAppViewTextInput);
  24. }
  25. bool evil_portal_scene_rename_on_event(void *context, SceneManagerEvent event) {
  26. Evil_PortalApp *app = context;
  27. SceneManager* scene_manager = app->scene_manager;
  28. bool consumed = false;
  29. if(event.type == SceneManagerEventTypeCustom) {
  30. evil_portal_write_ap_name(app);
  31. scene_manager_search_and_switch_to_previous_scene(
  32. scene_manager, Evil_PortalSceneStart);
  33. consumed = true;
  34. }
  35. return consumed;
  36. }
  37. void evil_portal_scene_rename_on_exit(void *context) {
  38. Evil_PortalApp *app = context;
  39. variable_item_list_reset(app->var_item_list);
  40. }