unleashed-firmware/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c
Georgii Surkov f11df49468
[FL-2828] Dolphin score update take 2 (#1929)
* Move DolphinDeedNfcRead
* Move DolphinDeedNfcReadSuccess
* Move DolphinDeedNfcSave
* Move DolphinDeedNfcDetectReader
* Move DolphinDeedNfcEmulate
* Count DolphinDeedNfcEmulate when launched from file browser
* Implement most of the score accounting for NFC
* Fully update Nfc icounter handling
* Move DolphinDeedSubGhzFrequencyAnalyzer
* Update the rest of icounter in SubGHz
* Adjust SubGHz icounter handling
* Adjust LFRFID icounter handling
* Adjust Infrared icounter handling
* Don't count renaming RFID tags as saving
* Don't count renaming SubGHz signals as saving
* Don't count renaming NFC tags as saving
* Adjust iButton icounter handling
* Minor code refactoring
* Correct formatting
* Account for emulating iButton keys from file manager/rpc

Co-authored-by: あく <alleteam@gmail.com>
2022-10-28 16:18:41 +09:00

49 lines
1.8 KiB
C

#include "../lfrfid_i.h"
void lfrfid_scene_save_data_on_enter(void* context) {
LfRfid* app = context;
ByteInput* byte_input = app->byte_input;
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
bool need_restore = scene_manager_get_scene_state(app->scene_manager, LfRfidSceneSaveData);
if(!need_restore) {
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
protocol_dict_get_data(app->dict, app->protocol_id, app->new_key_data, size);
}
byte_input_set_header_text(byte_input, "Enter the data in hex");
byte_input_set_result_callback(
byte_input, lfrfid_text_input_callback, NULL, app, app->new_key_data, size);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewByteInput);
}
bool lfrfid_scene_save_data_on_event(void* context, SceneManagerEvent event) {
LfRfid* app = context;
SceneManager* scene_manager = app->scene_manager;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == LfRfidEventNext) {
consumed = true;
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
protocol_dict_set_data(app->dict, app->protocol_id, app->new_key_data, size);
scene_manager_next_scene(scene_manager, LfRfidSceneSaveName);
scene_manager_set_scene_state(scene_manager, LfRfidSceneSaveData, 1);
}
} else if(event.type == SceneManagerEventTypeBack) {
scene_manager_set_scene_state(scene_manager, LfRfidSceneSaveData, 0);
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
}
return consumed;
}
void lfrfid_scene_save_data_on_exit(void* context) {
UNUSED(context);
}