evil_portal_scene_select_html.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../evil_portal_app_i.h"
  2. #include "../helpers/evil_portal_storage.h"
  3. void evil_portal_show_loading_popup(Evil_PortalApp* app, bool show) {
  4. ViewStack* view_stack = app->view_stack;
  5. Loading* loading = app->loading;
  6. if(show) {
  7. // Raise timer priority so that animations can play
  8. furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
  9. view_stack_add_view(view_stack, loading_get_view(loading));
  10. } else {
  11. view_stack_remove_view(view_stack, loading_get_view(loading));
  12. // Restore default timer priority
  13. furi_timer_set_thread_priority(FuriTimerThreadPriorityNormal);
  14. }
  15. }
  16. void evil_portal_scene_select_html_on_enter(void* context) {
  17. Evil_PortalApp* app = context;
  18. DialogsFileBrowserOptions browser_options;
  19. evil_portal_create_html_folder_if_not_exists();
  20. dialog_file_browser_set_basic_options(&browser_options, HTML_EXTENSION, &I_evil_portal_10px);
  21. browser_options.base_path = HTML_FOLDER;
  22. FuriString* path;
  23. path = furi_string_alloc();
  24. furi_string_set(path, HTML_FOLDER);
  25. bool success = dialog_file_browser_show(app->dialogs, app->file_path, path, &browser_options);
  26. furi_string_free(path);
  27. if(success) {
  28. //Replace HTML File
  29. evil_portal_show_loading_popup(app, true);
  30. evil_portal_replace_index_html(app->file_path);
  31. evil_portal_show_loading_popup(app, false);
  32. }
  33. scene_manager_search_and_switch_to_previous_scene(app->scene_manager, Evil_PortalSceneStart);
  34. }
  35. bool evil_portal_scene_select_html_on_event(void* context, SceneManagerEvent event) {
  36. UNUSED(context);
  37. UNUSED(event);
  38. bool consumed = true;
  39. return consumed;
  40. }
  41. void evil_portal_scene_select_html_on_exit(void* context) {
  42. UNUSED(context);
  43. }