diff --git a/applications/ibutton/ibutton.c b/applications/ibutton/ibutton.c index 304c057a7..b30a4c61f 100644 --- a/applications/ibutton/ibutton.c +++ b/applications/ibutton/ibutton.c @@ -305,22 +305,6 @@ void ibutton_text_store_clear(iButton* ibutton) { memset(ibutton->text_store, 0, IBUTTON_TEXT_STORE_SIZE); } -void ibutton_switch_to_previous_scene_one_of( - iButton* ibutton, - const uint32_t* scene_ids, - size_t scene_ids_size) { - furi_assert(scene_ids_size); - SceneManager* scene_manager = ibutton->scene_manager; - - for(size_t i = 0; i < scene_ids_size; ++i) { - const uint32_t scene_id = scene_ids[i]; - if(scene_manager_has_previous_scene(scene_manager, scene_id)) { - scene_manager_search_and_switch_to_previous_scene(scene_manager, scene_id); - return; - } - } -} - void ibutton_notification_message(iButton* ibutton, uint32_t message) { furi_assert(message < sizeof(ibutton_notification_sequences) / sizeof(NotificationSequence*)); notification_message(ibutton->notifications, ibutton_notification_sequences[message]); diff --git a/applications/ibutton/ibutton_i.h b/applications/ibutton/ibutton_i.h index 9d4354d02..fd11b8c19 100644 --- a/applications/ibutton/ibutton_i.h +++ b/applications/ibutton/ibutton_i.h @@ -83,8 +83,4 @@ bool ibutton_save_key(iButton* ibutton, const char* key_name); bool ibutton_delete_key(iButton* ibutton); void ibutton_text_store_set(iButton* ibutton, const char* text, ...); void ibutton_text_store_clear(iButton* ibutton); -void ibutton_switch_to_previous_scene_one_of( - iButton* ibutton, - const uint32_t* scene_ids, - size_t scene_ids_size); void ibutton_notification_message(iButton* ibutton, uint32_t message); diff --git a/applications/ibutton/scenes/ibutton_scene_save_name.c b/applications/ibutton/scenes/ibutton_scene_save_name.c index 6caf5d2d5..be6403874 100644 --- a/applications/ibutton/scenes/ibutton_scene_save_name.c +++ b/applications/ibutton/scenes/ibutton_scene_save_name.c @@ -61,8 +61,8 @@ bool ibutton_scene_save_name_on_event(void* context, SceneManagerEvent event) { } else { const uint32_t possible_scenes[] = { iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType}; - ibutton_switch_to_previous_scene_one_of( - ibutton, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + scene_manager_search_and_switch_to_previous_scene_one_of( + ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); } } } diff --git a/applications/ibutton/scenes/ibutton_scene_save_success.c b/applications/ibutton/scenes/ibutton_scene_save_success.c index dffda6a0f..6c24a897c 100644 --- a/applications/ibutton/scenes/ibutton_scene_save_success.c +++ b/applications/ibutton/scenes/ibutton_scene_save_success.c @@ -31,8 +31,8 @@ bool ibutton_scene_save_success_on_event(void* context, SceneManagerEvent event) if(event.event == iButtonCustomEventBack) { const uint32_t possible_scenes[] = { iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType}; - ibutton_switch_to_previous_scene_one_of( - ibutton, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + scene_manager_search_and_switch_to_previous_scene_one_of( + ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); } } diff --git a/applications/ibutton/scenes/ibutton_scene_write_success.c b/applications/ibutton/scenes/ibutton_scene_write_success.c index 6abafbb37..3acb1dea0 100644 --- a/applications/ibutton/scenes/ibutton_scene_write_success.c +++ b/applications/ibutton/scenes/ibutton_scene_write_success.c @@ -31,8 +31,8 @@ bool ibutton_scene_write_success_on_event(void* context, SceneManagerEvent event consumed = true; if(event.event == iButtonCustomEventBack) { const uint32_t possible_scenes[] = {iButtonSceneReadKeyMenu, iButtonSceneStart}; - ibutton_switch_to_previous_scene_one_of( - ibutton, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + scene_manager_search_and_switch_to_previous_scene_one_of( + ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); } } diff --git a/applications/infrared/scenes/infrared_scene_edit_delete.c b/applications/infrared/scenes/infrared_scene_edit_delete.c index e79851486..4dfc054fb 100644 --- a/applications/infrared/scenes/infrared_scene_edit_delete.c +++ b/applications/infrared/scenes/infrared_scene_edit_delete.c @@ -97,7 +97,7 @@ bool infrared_scene_edit_delete_on_event(void* context, SceneManagerEvent event) } else { const uint32_t possible_scenes[] = {InfraredSceneRemoteList, InfraredSceneStart}; scene_manager_search_and_switch_to_previous_scene_one_of( - scene_manager, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + scene_manager, possible_scenes, COUNT_OF(possible_scenes)); } consumed = true; } diff --git a/applications/infrared/scenes/infrared_scene_edit_delete_done.c b/applications/infrared/scenes/infrared_scene_edit_delete_done.c index 4502abbdb..49a299d2a 100644 --- a/applications/infrared/scenes/infrared_scene_edit_delete_done.c +++ b/applications/infrared/scenes/infrared_scene_edit_delete_done.c @@ -28,8 +28,10 @@ bool infrared_scene_edit_delete_done_on_event(void* context, SceneManagerEvent e scene_manager, InfraredSceneRemote); } else if(edit_target == InfraredEditTargetRemote) { const uint32_t possible_scenes[] = {InfraredSceneStart, InfraredSceneRemoteList}; - scene_manager_search_and_switch_to_previous_scene_one_of( - scene_manager, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + if(!scene_manager_search_and_switch_to_previous_scene_one_of( + scene_manager, possible_scenes, COUNT_OF(possible_scenes))) { + view_dispatcher_stop(infrared->view_dispatcher); + } } else { furi_assert(0); } diff --git a/applications/infrared/scenes/infrared_scene_edit_rename_done.c b/applications/infrared/scenes/infrared_scene_edit_rename_done.c index 54b18ab61..6c7096e17 100644 --- a/applications/infrared/scenes/infrared_scene_edit_rename_done.c +++ b/applications/infrared/scenes/infrared_scene_edit_rename_done.c @@ -21,7 +21,10 @@ bool infrared_scene_edit_rename_done_on_event(void* context, SceneManagerEvent e if(event.type == SceneManagerEventTypeCustom) { if(event.event == InfraredCustomEventTypePopupClosed) { - scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote); + if(!scene_manager_search_and_switch_to_previous_scene( + infrared->scene_manager, InfraredSceneRemote)) { + scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote); + } consumed = true; } } diff --git a/applications/infrared/scenes/infrared_scene_learn_done.c b/applications/infrared/scenes/infrared_scene_learn_done.c index eb6cced84..7d3571715 100644 --- a/applications/infrared/scenes/infrared_scene_learn_done.c +++ b/applications/infrared/scenes/infrared_scene_learn_done.c @@ -29,7 +29,10 @@ bool infrared_scene_learn_done_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { if(event.event == InfraredCustomEventTypePopupClosed) { - scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote); + if(!scene_manager_search_and_switch_to_previous_scene( + infrared->scene_manager, InfraredSceneRemote)) { + scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote); + } consumed = true; } } diff --git a/applications/infrared/scenes/infrared_scene_remote.c b/applications/infrared/scenes/infrared_scene_remote.c index 3cd5a9aa4..bcac58819 100644 --- a/applications/infrared/scenes/infrared_scene_remote.c +++ b/applications/infrared/scenes/infrared_scene_remote.c @@ -78,7 +78,7 @@ bool infrared_scene_remote_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeBack) { const uint32_t possible_scenes[] = {InfraredSceneRemoteList, InfraredSceneStart}; consumed = scene_manager_search_and_switch_to_previous_scene_one_of( - scene_manager, possible_scenes, sizeof(possible_scenes) / sizeof(uint32_t)); + scene_manager, possible_scenes, COUNT_OF(possible_scenes)); } else if(event.type == SceneManagerEventTypeCustom) { const uint16_t custom_type = infrared_custom_event_get_type(event.event); const int16_t button_index = infrared_custom_event_get_value(event.event);