flipperzero-firmware/applications/bad_usb/scenes/bad_usb_scene_error.c
gornekich 8cfd0eab9e
[FL-2198], [FL-2161] NFC emulation refactoring (#968)
* rfal: add state changed callback
* furi_hal_nfc: add NFC-A emulation API
* nfc: add emulation logger, refactor scenes
* elements: fix text_box element
* gui: fix text box module
* nfc: remove unnecessary buffers
* nfc: introduce emulation callback concept
* nfc: format sources
* bt settings: fix incorrect scene switch
* bt settings: format sources
* Debug: fix x2d import for python 3
* Gui: rename method name widget_clear to widget_reset
* nfc: add nfca emulation handler
* nfc: add global custom events enum
* nfc: UID emulation Data -> Log
* furi_hal_nfc: fix incorrect timings
* u2f, badusb: widget_clear() -> widget_reset()

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2022-02-02 22:59:28 +03:00

54 lines
1.5 KiB
C

#include "../bad_usb_app_i.h"
typedef enum {
SubghzCustomEventErrorBack,
} BadUsbCustomEvent;
static void
bad_usb_scene_error_event_callback(GuiButtonType result, InputType type, void* context) {
furi_assert(context);
BadUsbApp* app = context;
if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
view_dispatcher_send_custom_event(app->view_dispatcher, SubghzCustomEventErrorBack);
}
}
void bad_usb_scene_error_on_enter(void* context) {
BadUsbApp* app = context;
widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
widget_add_string_multiline_element(
app->widget,
81,
4,
AlignCenter,
AlignTop,
FontSecondary,
"No SD card or\napp data found.\nThis app will not\nwork without\nrequired files.");
widget_add_button_element(
app->widget, GuiButtonTypeLeft, "Back", bad_usb_scene_error_event_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, BadUsbAppViewError);
}
bool bad_usb_scene_error_on_event(void* context, SceneManagerEvent event) {
BadUsbApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubghzCustomEventErrorBack) {
view_dispatcher_stop(app->view_dispatcher);
consumed = true;
}
}
return consumed;
}
void bad_usb_scene_error_on_exit(void* context) {
BadUsbApp* app = context;
widget_reset(app->widget);
}