hex_viewer_scene_open.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "../hex_viewer.h"
  2. void hex_viewer_scene_open_on_enter(void* context) {
  3. furi_assert(context);
  4. HexViewer* app = context;
  5. FuriString* initial_path;
  6. initial_path = furi_string_alloc();
  7. furi_string_set(initial_path, HEX_VIEWER_APP_PATH_FOLDER);
  8. DialogsFileBrowserOptions browser_options;
  9. dialog_file_browser_set_basic_options(&browser_options, HEX_VIEWER_APP_EXTENSION, &I_hex_10px);
  10. browser_options.hide_ext = false;
  11. bool success =
  12. dialog_file_browser_show(app->dialogs, app->file_path, initial_path, &browser_options);
  13. furi_string_free(initial_path);
  14. if(success) {
  15. success = hex_viewer_open_file(app, furi_string_get_cstr(app->file_path));
  16. if(success) hex_viewer_read_file(app);
  17. }
  18. if(success) {
  19. scene_manager_search_and_switch_to_previous_scene(
  20. app->scene_manager, HexViewerViewIdStartscreen);
  21. } else {
  22. scene_manager_previous_scene(app->scene_manager);
  23. }
  24. }
  25. bool hex_viewer_scene_open_on_event(void* context, SceneManagerEvent event) {
  26. UNUSED(context);
  27. UNUSED(event);
  28. bool consumed = true;
  29. return consumed;
  30. }
  31. void hex_viewer_scene_open_on_exit(void* context) {
  32. UNUSED(context);
  33. }