diff options
author | gornekich <n.gorbadey@gmail.com> | 2021-07-28 17:52:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 17:52:00 +0300 |
commit | 91c1eaf5a8c5e1c87d14755fb99a08e1cfdf72ac (patch) | |
tree | fd392431ea1b894c342a6a6ce2ecde13025c6f1c /applications/nfc | |
parent | 1c58de24f52833e2725f2c5b9b81dfdacfd46936 (diff) |
[FL-1543] Scene manager search scene API (#611)
* scene_manager: search -> search_and_switch_to previous_scene
* scene_manager: add search and switch to another scene API
* scene_manager: Navigation -> Back event
Diffstat (limited to 'applications/nfc')
-rwxr-xr-x[-rw-r--r--] | applications/nfc/nfc.c | 7 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_card_menu.c | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | applications/nfc/scenes/nfc_scene_delete.c | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | applications/nfc/scenes/nfc_scene_delete_success.c | 3 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_file_select.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | applications/nfc/scenes/nfc_scene_mifare_ul_menu.c | 5 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_read_emv_data_success.c | 7 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_save_name.c | 3 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_save_success.c | 14 |
9 files changed, 32 insertions, 17 deletions
diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c index 8815211c..734dade2 100644..100755 --- a/applications/nfc/nfc.c +++ b/applications/nfc/nfc.c @@ -7,10 +7,10 @@ bool nfc_custom_event_callback(void* context, uint32_t event) { return scene_manager_handle_custom_event(nfc->scene_manager, event); } -bool nfc_navigation_event_callback(void* context) { +bool nfc_back_event_callback(void* context) { furi_assert(context); Nfc* nfc = (Nfc*)context; - return scene_manager_handle_navigation_event(nfc->scene_manager); + return scene_manager_handle_back_event(nfc->scene_manager); } void nfc_tick_event_callback(void* context) { @@ -28,8 +28,7 @@ Nfc* nfc_alloc() { view_dispatcher_enable_queue(nfc->view_dispatcher); view_dispatcher_set_event_callback_context(nfc->view_dispatcher, nfc); view_dispatcher_set_custom_event_callback(nfc->view_dispatcher, nfc_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - nfc->view_dispatcher, nfc_navigation_event_callback); + view_dispatcher_set_navigation_event_callback(nfc->view_dispatcher, nfc_back_event_callback); view_dispatcher_set_tick_event_callback(nfc->view_dispatcher, nfc_tick_event_callback, 100); // Open GUI record diff --git a/applications/nfc/scenes/nfc_scene_card_menu.c b/applications/nfc/scenes/nfc_scene_card_menu.c index f69e0838..f58c212e 100755 --- a/applications/nfc/scenes/nfc_scene_card_menu.c +++ b/applications/nfc/scenes/nfc_scene_card_menu.c @@ -70,8 +70,9 @@ const bool nfc_scene_card_menu_on_event(void* context, SceneManagerEvent event) scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName); return true; } - } else if(event.type == SceneManagerEventTypeNavigation) { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + } else if(event.type == SceneManagerEventTypeBack) { + return scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); } return false; diff --git a/applications/nfc/scenes/nfc_scene_delete.c b/applications/nfc/scenes/nfc_scene_delete.c index 84646e05..1e3dc292 100644..100755 --- a/applications/nfc/scenes/nfc_scene_delete.c +++ b/applications/nfc/scenes/nfc_scene_delete.c @@ -75,7 +75,8 @@ const bool nfc_scene_delete_on_event(void* context, SceneManagerEvent event) { if(nfc_device_delete(&nfc->dev)) { scene_manager_next_scene(nfc->scene_manager, NfcSceneDeleteSuccess); } else { - scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); } return true; } diff --git a/applications/nfc/scenes/nfc_scene_delete_success.c b/applications/nfc/scenes/nfc_scene_delete_success.c index 592a16c6..51328a0a 100644..100755 --- a/applications/nfc/scenes/nfc_scene_delete_success.c +++ b/applications/nfc/scenes/nfc_scene_delete_success.c @@ -26,7 +26,8 @@ const bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent ev if(event.type == SceneManagerEventTypeCustom) { if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + return scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); } } return false; diff --git a/applications/nfc/scenes/nfc_scene_file_select.c b/applications/nfc/scenes/nfc_scene_file_select.c index f8af371f..e75872a3 100755 --- a/applications/nfc/scenes/nfc_scene_file_select.c +++ b/applications/nfc/scenes/nfc_scene_file_select.c @@ -6,7 +6,7 @@ const void nfc_scene_file_select_on_enter(void* context) { if(nfc_file_select(&nfc->dev)) { scene_manager_next_scene(nfc->scene_manager, NfcSceneSavedMenu); } else { - scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + scene_manager_search_and_switch_to_previous_scene(nfc->scene_manager, NfcSceneStart); } } diff --git a/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c b/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c index bc639db9..396c393b 100644..100755 --- a/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c +++ b/applications/nfc/scenes/nfc_scene_mifare_ul_menu.c @@ -41,8 +41,9 @@ const bool nfc_scene_mifare_ul_menu_on_event(void* context, SceneManagerEvent ev scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented); return true; } - } else if(event.type == SceneManagerEventTypeNavigation) { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + } else if(event.type == SceneManagerEventTypeBack) { + return scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); } return false; diff --git a/applications/nfc/scenes/nfc_scene_read_emv_data_success.c b/applications/nfc/scenes/nfc_scene_read_emv_data_success.c index fbfca822..74f15a22 100755 --- a/applications/nfc/scenes/nfc_scene_read_emv_data_success.c +++ b/applications/nfc/scenes/nfc_scene_read_emv_data_success.c @@ -68,15 +68,16 @@ const bool nfc_scene_read_emv_data_success_on_event(void* context, SceneManagerE if(event.type == SceneManagerEventTypeCustom) { if(event.event == GuiButtonTypeLeft) { - return scene_manager_search_previous_scene( + return scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneReadEmvAppSuccess); } else if(event.event == GuiButtonTypeRight) { nfc->dev.format = NfcDeviceSaveFormatBankCard; scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName); return true; } - } else if(event.type == SceneManagerEventTypeNavigation) { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess); + } else if(event.type == SceneManagerEventTypeBack) { + return scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneReadEmvAppSuccess); } return false; } diff --git a/applications/nfc/scenes/nfc_scene_save_name.c b/applications/nfc/scenes/nfc_scene_save_name.c index 9de2ac47..4a0041b2 100755 --- a/applications/nfc/scenes/nfc_scene_save_name.c +++ b/applications/nfc/scenes/nfc_scene_save_name.c @@ -45,7 +45,8 @@ const bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess); return true; } else { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + return scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); } } } diff --git a/applications/nfc/scenes/nfc_scene_save_success.c b/applications/nfc/scenes/nfc_scene_save_success.c index cd36871a..058388b6 100755 --- a/applications/nfc/scenes/nfc_scene_save_success.c +++ b/applications/nfc/scenes/nfc_scene_save_success.c @@ -23,13 +23,23 @@ const void nfc_scene_save_success_on_enter(void* context) { const bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) { Nfc* nfc = (Nfc*)context; + bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) { - return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart); + if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneCardMenu); + } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) { + consumed = scene_manager_search_and_switch_to_another_scene( + nfc->scene_manager, NfcSceneFileSelect); + } else { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart); + } } } - return false; + return consumed; } const void nfc_scene_save_success_on_exit(void* context) { |