[FL-2717] Fix unexpected behaviour when opening a remote from outside (#1538)
* Fix unexpected behaviour when opening remote from outside * Same fix for editing button name * Exit application correctly if remote was deleted * Remove duplicate function from ibutton * Use COUNT_OF macro Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
55b4ff8e0c
commit
d147190d61
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user