mag_i.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <gui/gui.h>
  5. #include <gui/view.h>
  6. #include <assets_icons.h>
  7. #include <gui/view_dispatcher.h>
  8. #include <gui/scene_manager.h>
  9. #include <notification/notification_messages.h>
  10. #include <gui/modules/submenu.h>
  11. #include <gui/modules/dialog_ex.h>
  12. #include <gui/modules/popup.h>
  13. #include <gui/modules/text_input.h>
  14. #include <gui/modules/byte_input.h>
  15. #include <gui/modules/widget.h>
  16. #include <notification/notification_messages.h>
  17. #include <dialogs/dialogs.h>
  18. #include <storage/storage.h>
  19. #include <flipper_format/flipper_format.h>
  20. #include <toolbox/path.h>
  21. #include "scenes/mag_scene.h"
  22. #define MAG_KEY_NAME_SIZE 22
  23. #define MAG_TEXT_STORE_SIZE 40
  24. #define MAG_APP_FOLDER ANY_PATH("mag")
  25. #define MAG_SD_FOLDER EXT_PATH("mag")
  26. #define MAG_APP_EXTENSION ".mag"
  27. #define MAG_APP_SHADOW_EXTENSION ".shd"
  28. enum MagCustomEvent {
  29. MagEventNext = 100,
  30. MagEventExit,
  31. MagEventPopupClosed,
  32. };
  33. typedef struct Mag Mag;
  34. struct Mag {
  35. ViewDispatcher* view_dispatcher;
  36. Gui* gui;
  37. NotificationApp* notifications;
  38. SceneManager* scene_manager;
  39. Storage* storage;
  40. DialogsApp* dialogs;
  41. Widget* widget;
  42. char text_store[MAG_TEXT_STORE_SIZE + 1];
  43. FuriString* file_path;
  44. FuriString* file_name;
  45. // Common views
  46. Submenu* submenu;
  47. DialogEx* dialog_ex;
  48. Popup* popup;
  49. TextInput* text_input;
  50. ByteInput* byte_input;
  51. // Custom views?
  52. };
  53. typedef enum {
  54. MagViewSubmenu,
  55. MagViewDialogEx,
  56. MagViewPopup,
  57. MagViewWidget,
  58. MagViewTextInput,
  59. MagViewByteInput,
  60. } MagView;
  61. bool mag_save_key(Mag* mag);
  62. bool mag_load_key_from_file_select(Mag* mag);
  63. bool mag_delete_key(Mag* mag);
  64. bool mag_load_key_data(Mag* mag, FuriString* path, bool show_dialog);
  65. bool mag_save_key_data(Mag* mag, FuriString* path);
  66. void mag_make_app_folder(Mag* mag);
  67. void mag_text_store_set(Mag* mag, const char* text, ...);
  68. void mag_text_store_clear(Mag* mag);
  69. void mag_popup_timeout_callback(void* context);
  70. void mag_widget_callback(GuiButtonType result, InputType type, void* context);
  71. void mag_text_input_callback(void* context);