unleashed-firmware/applications/nfc/scenes/nfc_scene_mf_classic_keys.c
gornekich 560ea5f995
[FL-2714] New NFC info screens (#1605)
* nfc: add scroll element for info
* widget: format lines for scroll text element
* widget: fix new line generation
* widget: finish element text scroll
* nfc: rework ultralight and NTAG info scenes
* nfc: rework mf classic info screens
* nfc: rework nfca info scenes
* nfc: fix mf ultralight navigation
* widget: add documentation
* nfc: rework bank card infO
* nfc: rework device info scene
* nfc: fix incorrect atqa order
* mf ultralight: remove unused function
* widget: add mutex for model protection
* widget: fix memory leak
* nfc: rework delete scene
* nfc: fix selected item in saved menu scene
* widget: fix naming in text scroll element
* nfc: fix navigation from delete success
* nfc: add dictionary icon
* widget: fix memory leak
2022-08-18 00:08:13 +09:00

60 lines
2.1 KiB
C

#include "../nfc_i.h"
void nfc_scene_mf_classic_keys_widget_callback(GuiButtonType result, InputType type, void* context) {
Nfc* nfc = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
}
}
void nfc_scene_mf_classic_keys_on_enter(void* context) {
Nfc* nfc = context;
// Load flipper dict keys total
uint32_t flipper_dict_keys_total = 0;
MfClassicDict* dict = mf_classic_dict_alloc(MfClassicDictTypeFlipper);
if(dict) {
flipper_dict_keys_total = mf_classic_dict_get_total_keys(dict);
mf_classic_dict_free(dict);
}
// Load user dict keys total
uint32_t user_dict_keys_total = 0;
dict = mf_classic_dict_alloc(MfClassicDictTypeUser);
if(dict) {
user_dict_keys_total = mf_classic_dict_get_total_keys(dict);
mf_classic_dict_free(dict);
}
widget_add_string_element(
nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "MF Classic Keys");
char temp_str[32];
snprintf(temp_str, sizeof(temp_str), "Flipper dict: %ld", flipper_dict_keys_total);
widget_add_string_element(nfc->widget, 0, 20, AlignLeft, AlignTop, FontSecondary, temp_str);
snprintf(temp_str, sizeof(temp_str), "User dict: %ld", user_dict_keys_total);
widget_add_string_element(nfc->widget, 0, 32, AlignLeft, AlignTop, FontSecondary, temp_str);
widget_add_button_element(
nfc->widget, GuiButtonTypeCenter, "Add", nfc_scene_mf_classic_keys_widget_callback, nfc);
widget_add_icon_element(nfc->widget, 90, 12, &I_Keychain);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
}
bool nfc_scene_mf_classic_keys_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeCenter) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicKeysAdd);
consumed = true;
}
}
return consumed;
}
void nfc_scene_mf_classic_keys_on_exit(void* context) {
Nfc* nfc = context;
widget_reset(nfc->widget);
}