seader_scene_formats.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../seader_i.h"
  2. #include <dolphin/dolphin.h>
  3. void seader_scene_formats_on_enter(void* context) {
  4. Seader* seader = context;
  5. PluginWiegand* plugin = seader->plugin_wiegand;
  6. SeaderCredential* credential = seader->credential;
  7. FuriString* str = seader->text_box_store;
  8. furi_string_reset(str);
  9. if(plugin) {
  10. FuriString* description = furi_string_alloc();
  11. size_t format_count = plugin->count(credential->bit_length, credential->credential);
  12. for(size_t i = 0; i < format_count; i++) {
  13. plugin->description(credential->bit_length, credential->credential, i, description);
  14. furi_string_cat_printf(str, "%s\n", furi_string_get_cstr(description));
  15. }
  16. furi_string_free(description);
  17. }
  18. text_box_set_font(seader->text_box, TextBoxFontHex);
  19. text_box_set_text(seader->text_box, furi_string_get_cstr(seader->text_box_store));
  20. view_dispatcher_switch_to_view(seader->view_dispatcher, SeaderViewTextBox);
  21. }
  22. bool seader_scene_formats_on_event(void* context, SceneManagerEvent event) {
  23. Seader* seader = context;
  24. bool consumed = false;
  25. if(event.type == SceneManagerEventTypeCustom) {
  26. if(event.event == GuiButtonTypeLeft) {
  27. consumed = scene_manager_previous_scene(seader->scene_manager);
  28. }
  29. } else if(event.type == SceneManagerEventTypeBack) {
  30. consumed = scene_manager_previous_scene(seader->scene_manager);
  31. }
  32. return consumed;
  33. }
  34. void seader_scene_formats_on_exit(void* context) {
  35. Seader* seader = context;
  36. // Clear views
  37. text_box_reset(seader->text_box);
  38. }