2022-09-08 16:40:33 +00:00
|
|
|
#include "../lfrfid_i.h"
|
2022-10-28 07:18:41 +00:00
|
|
|
#include <dolphin/dolphin.h>
|
2022-09-08 16:40:33 +00:00
|
|
|
|
|
|
|
static void lfrfid_scene_start_submenu_callback(void* context, uint32_t index) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void lfrfid_scene_start_on_enter(void* context) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
Submenu* submenu = app->submenu;
|
|
|
|
|
|
|
|
submenu_add_item(
|
2024-03-29 03:32:43 +00:00
|
|
|
submenu, "Read", LfRfidMenuIndexRead, lfrfid_scene_start_submenu_callback, app);
|
2022-09-08 16:40:33 +00:00
|
|
|
submenu_add_item(
|
2024-03-29 03:32:43 +00:00
|
|
|
submenu, "Saved", LfRfidMenuIndexSaved, lfrfid_scene_start_submenu_callback, app);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Add Manually",
|
|
|
|
LfRfidMenuIndexAddManually,
|
|
|
|
lfrfid_scene_start_submenu_callback,
|
|
|
|
app);
|
2022-09-08 16:40:33 +00:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Extra Actions",
|
2024-03-29 03:32:43 +00:00
|
|
|
LfRfidMenuIndexExtraActions,
|
2022-09-08 16:40:33 +00:00
|
|
|
lfrfid_scene_start_submenu_callback,
|
|
|
|
app);
|
|
|
|
|
|
|
|
submenu_set_selected_item(
|
|
|
|
submenu, scene_manager_get_scene_state(app->scene_manager, LfRfidSceneStart));
|
|
|
|
|
|
|
|
// clear key
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_reset(app->file_name);
|
2022-09-08 16:40:33 +00:00
|
|
|
app->protocol_id = PROTOCOL_NO;
|
|
|
|
app->read_type = LFRFIDWorkerReadTypeAuto;
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewSubmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool lfrfid_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
2024-03-29 03:32:43 +00:00
|
|
|
if(event.event == LfRfidMenuIndexRead) {
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexRead);
|
2022-09-08 16:40:33 +00:00
|
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneRead);
|
2023-06-09 11:02:47 +00:00
|
|
|
dolphin_deed(DolphinDeedRfidRead);
|
2022-09-08 16:40:33 +00:00
|
|
|
consumed = true;
|
2024-03-29 03:32:43 +00:00
|
|
|
} else if(event.event == LfRfidMenuIndexSaved) {
|
2023-02-08 08:08:50 +00:00
|
|
|
// Like in the other apps, explicitly save the scene state
|
|
|
|
// in each branch in case the user cancels loading a file.
|
2024-03-29 03:32:43 +00:00
|
|
|
scene_manager_set_scene_state(
|
|
|
|
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexSaved);
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_set(app->file_path, LFRFID_APP_FOLDER);
|
2022-09-08 16:40:33 +00:00
|
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneSelectKey);
|
|
|
|
consumed = true;
|
2024-03-29 03:32:43 +00:00
|
|
|
} else if(event.event == LfRfidMenuIndexAddManually) {
|
2023-02-08 08:08:50 +00:00
|
|
|
scene_manager_set_scene_state(
|
2024-03-29 03:32:43 +00:00
|
|
|
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexAddManually);
|
2022-09-08 16:40:33 +00:00
|
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneSaveType);
|
|
|
|
consumed = true;
|
2024-03-29 03:32:43 +00:00
|
|
|
} else if(event.event == LfRfidMenuIndexExtraActions) {
|
2023-02-08 08:08:50 +00:00
|
|
|
scene_manager_set_scene_state(
|
2024-03-29 03:32:43 +00:00
|
|
|
app->scene_manager, LfRfidSceneStart, LfRfidMenuIndexExtraActions);
|
2022-09-08 16:40:33 +00:00
|
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneExtraActions);
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lfrfid_scene_start_on_exit(void* context) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
|
|
|
|
submenu_reset(app->submenu);
|
|
|
|
}
|