-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into gsurkov/2792_ac_universal_…
…remote
- Loading branch information
Showing
54 changed files
with
1,692 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
"SConstruct": "python", | ||
"*.fam": "python", | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
applications/main/nfc/scenes/nfc_scene_mf_classic_keys_delete.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "../nfc_i.h" | ||
|
||
void nfc_scene_mf_classic_keys_delete_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_delete_on_enter(void* context) { | ||
Nfc* nfc = context; | ||
MfClassicDict* dict = mf_classic_dict_alloc(MfClassicDictTypeUser); | ||
uint32_t key_index = | ||
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfClassicKeysDelete); | ||
// Setup Custom Widget view | ||
string_t key_str; | ||
string_init(key_str); | ||
|
||
widget_add_string_element( | ||
nfc->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Delete this key?"); | ||
widget_add_button_element( | ||
nfc->widget, | ||
GuiButtonTypeLeft, | ||
"Cancel", | ||
nfc_scene_mf_classic_keys_delete_widget_callback, | ||
nfc); | ||
widget_add_button_element( | ||
nfc->widget, | ||
GuiButtonTypeRight, | ||
"Delete", | ||
nfc_scene_mf_classic_keys_delete_widget_callback, | ||
nfc); | ||
|
||
mf_classic_dict_get_key_at_index_str(dict, key_str, key_index); | ||
widget_add_string_element( | ||
nfc->widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(key_str)); | ||
|
||
string_clear(key_str); | ||
mf_classic_dict_free(dict); | ||
|
||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); | ||
} | ||
|
||
bool nfc_scene_mf_classic_keys_delete_on_event(void* context, SceneManagerEvent event) { | ||
Nfc* nfc = context; | ||
bool consumed = false; | ||
uint32_t key_index = | ||
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfClassicKeysDelete); | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == GuiButtonTypeLeft) { | ||
consumed = scene_manager_search_and_switch_to_previous_scene( | ||
nfc->scene_manager, NfcSceneMfClassicKeys); | ||
} else if(event.event == GuiButtonTypeRight) { | ||
MfClassicDict* dict = mf_classic_dict_alloc(MfClassicDictTypeUser); | ||
if(mf_classic_dict_delete_index(dict, key_index)) { | ||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDeleteSuccess); | ||
} else { | ||
scene_manager_search_and_switch_to_previous_scene( | ||
nfc->scene_manager, NfcSceneMfClassicKeys); | ||
} | ||
mf_classic_dict_free(dict); | ||
consumed = true; | ||
} | ||
} | ||
|
||
return consumed; | ||
} | ||
|
||
void nfc_scene_mf_classic_keys_delete_on_exit(void* context) { | ||
Nfc* nfc = context; | ||
|
||
widget_reset(nfc->widget); | ||
} |
60 changes: 60 additions & 0 deletions
60
applications/main/nfc/scenes/nfc_scene_mf_classic_keys_list.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "../nfc_i.h" | ||
|
||
void nfc_scene_mf_classic_keys_list_submenu_callback(void* context, uint32_t index) { | ||
Nfc* nfc = context; | ||
|
||
view_dispatcher_send_custom_event(nfc->view_dispatcher, index); | ||
} | ||
|
||
void nfc_scene_mf_classic_keys_list_on_enter(void* context) { | ||
Nfc* nfc = context; | ||
Submenu* submenu = nfc->submenu; | ||
MfClassicDict* dict = mf_classic_dict_alloc(MfClassicDictTypeUser); | ||
uint32_t index = 0; | ||
string_t temp_key; | ||
MfClassicUserKeys_init(nfc->mfc_key_strs); | ||
string_init(temp_key); | ||
if(dict) { | ||
mf_classic_dict_rewind(dict); | ||
while(mf_classic_dict_get_next_key_str(dict, temp_key)) { | ||
char* current_key = (char*)malloc(sizeof(char) * 13); | ||
strncpy(current_key, string_get_cstr(temp_key), 12); | ||
MfClassicUserKeys_push_back(nfc->mfc_key_strs, current_key); | ||
FURI_LOG_D("ListKeys", "Key %d: %s", index, current_key); | ||
submenu_add_item( | ||
submenu, | ||
current_key, | ||
index++, | ||
nfc_scene_mf_classic_keys_list_submenu_callback, | ||
nfc); | ||
} | ||
} | ||
submenu_set_header(submenu, "Select key to delete:"); | ||
mf_classic_dict_free(dict); | ||
string_clear(temp_key); | ||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu); | ||
} | ||
|
||
bool nfc_scene_mf_classic_keys_list_on_event(void* context, SceneManagerEvent event) { | ||
Nfc* nfc = context; | ||
bool consumed = false; | ||
if(event.type == SceneManagerEventTypeCustom) { | ||
scene_manager_set_scene_state( | ||
nfc->scene_manager, NfcSceneMfClassicKeysDelete, event.event); | ||
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicKeysDelete); | ||
consumed = true; | ||
} | ||
return consumed; | ||
} | ||
|
||
void nfc_scene_mf_classic_keys_list_on_exit(void* context) { | ||
Nfc* nfc = context; | ||
|
||
MfClassicUserKeys_it_t it; | ||
for(MfClassicUserKeys_it(it, nfc->mfc_key_strs); !MfClassicUserKeys_end_p(it); | ||
MfClassicUserKeys_next(it)) { | ||
free(*MfClassicUserKeys_ref(it)); | ||
} | ||
MfClassicUserKeys_clear(nfc->mfc_key_strs); | ||
submenu_reset(nfc->submenu); | ||
} |
47 changes: 47 additions & 0 deletions
47
applications/main/nfc/scenes/nfc_scene_mf_classic_keys_warn_duplicate.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "../nfc_i.h" | ||
|
||
void nfc_scene_mf_classic_keys_warn_duplicate_popup_callback(void* context) { | ||
Nfc* nfc = context; | ||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit); | ||
} | ||
|
||
void nfc_scene_mf_classic_keys_warn_duplicate_on_enter(void* context) { | ||
Nfc* nfc = context; | ||
|
||
// Setup view | ||
Popup* popup = nfc->popup; | ||
popup_set_icon(popup, 72, 16, &I_DolphinCommon_56x48); | ||
popup_set_header(popup, "Key already exists!", 64, 3, AlignCenter, AlignTop); | ||
popup_set_text( | ||
popup, | ||
"Please enter a\n" | ||
"different key.", | ||
4, | ||
24, | ||
AlignLeft, | ||
AlignTop); | ||
popup_set_timeout(popup, 5000); | ||
popup_set_context(popup, nfc); | ||
popup_set_callback(popup, nfc_scene_mf_classic_keys_warn_duplicate_popup_callback); | ||
popup_enable_timeout(popup); | ||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup); | ||
} | ||
|
||
bool nfc_scene_mf_classic_keys_warn_duplicate_on_event(void* context, SceneManagerEvent event) { | ||
Nfc* nfc = context; | ||
bool consumed = false; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == NfcCustomEventViewExit) { | ||
consumed = scene_manager_search_and_switch_to_previous_scene( | ||
nfc->scene_manager, NfcSceneMfClassicKeysAdd); | ||
} | ||
} | ||
return consumed; | ||
} | ||
|
||
void nfc_scene_mf_classic_keys_warn_duplicate_on_exit(void* context) { | ||
Nfc* nfc = context; | ||
|
||
popup_reset(nfc->popup); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.