2022-05-24 17:00:15 +03:00
|
|
|
#include "../nfc_i.h"
|
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexSave,
|
|
|
|
SubmenuIndexEmulate,
|
|
|
|
};
|
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
void nfc_scene_mf_ultralight_menu_submenu_callback(void* context, uint32_t index) {
|
2022-05-24 17:00:15 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
void nfc_scene_mf_ultralight_menu_on_enter(void* context) {
|
2022-05-24 17:00:15 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
Submenu* submenu = nfc->submenu;
|
|
|
|
|
|
|
|
submenu_add_item(
|
2022-07-26 18:30:49 +03:00
|
|
|
submenu, "Save", SubmenuIndexSave, nfc_scene_mf_ultralight_menu_submenu_callback, nfc);
|
2022-05-24 17:00:15 +03:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Emulate",
|
|
|
|
SubmenuIndexEmulate,
|
2022-07-26 18:30:49 +03:00
|
|
|
nfc_scene_mf_ultralight_menu_submenu_callback,
|
2022-05-24 17:00:15 +03:00
|
|
|
nfc);
|
|
|
|
submenu_set_selected_item(
|
2022-07-26 18:30:49 +03:00
|
|
|
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfUltralightMenu));
|
2022-05-24 17:00:15 +03:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
}
|
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
bool nfc_scene_mf_ultralight_menu_on_event(void* context, SceneManagerEvent event) {
|
2022-05-24 17:00:15 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == SubmenuIndexSave) {
|
|
|
|
scene_manager_set_scene_state(
|
2022-07-26 18:30:49 +03:00
|
|
|
nfc->scene_manager, NfcSceneMfUltralightMenu, SubmenuIndexSave);
|
|
|
|
nfc->dev->format = NfcDeviceSaveFormatMifareUl;
|
2022-05-24 17:00:15 +03:00
|
|
|
// Clear device name
|
|
|
|
nfc_device_set_name(nfc->dev, "");
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
|
|
|
consumed = true;
|
|
|
|
} else if(event.event == SubmenuIndexEmulate) {
|
|
|
|
scene_manager_set_scene_state(
|
2022-07-26 18:30:49 +03:00
|
|
|
nfc->scene_manager, NfcSceneMfUltralightMenu, SubmenuIndexEmulate);
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightEmulate);
|
2022-05-24 17:00:15 +03:00
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
} else if(event.type == SceneManagerEventTypeBack) {
|
2022-07-26 20:28:37 +03:00
|
|
|
consumed = scene_manager_previous_scene(nfc->scene_manager);
|
2022-05-24 17:00:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
void nfc_scene_mf_ultralight_menu_on_exit(void* context) {
|
2022-05-24 17:00:15 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
|
|
|
|
// Clear view
|
|
|
|
submenu_reset(nfc->submenu);
|
|
|
|
}
|