mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
FL-3790: fix laggy TextInput by not adding it into a ViewStack
This commit is contained in:
@@ -189,6 +189,10 @@ static InfraredApp* infrared_alloc() {
|
||||
view_dispatcher_add_view(
|
||||
view_dispatcher, InfraredViewMove, infrared_move_view_get_view(infrared->move_view));
|
||||
|
||||
infrared->loading = loading_alloc();
|
||||
view_dispatcher_add_view(
|
||||
view_dispatcher, InfraredViewLoading, loading_get_view(infrared->loading));
|
||||
|
||||
if(app_state->is_debug_enabled) {
|
||||
infrared->debug_view = infrared_debug_view_alloc();
|
||||
view_dispatcher_add_view(
|
||||
@@ -198,7 +202,6 @@ static InfraredApp* infrared_alloc() {
|
||||
}
|
||||
|
||||
infrared->button_panel = button_panel_alloc();
|
||||
infrared->loading = loading_alloc();
|
||||
infrared->progress = infrared_progress_view_alloc();
|
||||
|
||||
return infrared;
|
||||
@@ -240,13 +243,15 @@ static void infrared_free(InfraredApp* infrared) {
|
||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewMove);
|
||||
infrared_move_view_free(infrared->move_view);
|
||||
|
||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewLoading);
|
||||
loading_free(infrared->loading);
|
||||
|
||||
if(app_state->is_debug_enabled) {
|
||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewDebugView);
|
||||
infrared_debug_view_free(infrared->debug_view);
|
||||
}
|
||||
|
||||
button_panel_free(infrared->button_panel);
|
||||
loading_free(infrared->loading);
|
||||
infrared_progress_view_free(infrared->progress);
|
||||
|
||||
view_dispatcher_free(view_dispatcher);
|
||||
@@ -385,14 +390,13 @@ void infrared_tx_stop(InfraredApp* infrared) {
|
||||
}
|
||||
|
||||
void infrared_blocking_task_start(InfraredApp* infrared, FuriThreadCallback callback) {
|
||||
view_stack_add_view(infrared->view_stack, loading_get_view(infrared->loading));
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewLoading);
|
||||
furi_thread_set_callback(infrared->task_thread, callback);
|
||||
furi_thread_start(infrared->task_thread);
|
||||
}
|
||||
|
||||
bool infrared_blocking_task_finalize(InfraredApp* infrared) {
|
||||
furi_thread_join(infrared->task_thread);
|
||||
view_stack_remove_view(infrared->view_stack, loading_get_view(infrared->loading));
|
||||
return furi_thread_get_return_code(infrared->task_thread);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ typedef enum {
|
||||
InfraredViewStack,
|
||||
InfraredViewDebugView,
|
||||
InfraredViewMove,
|
||||
InfraredViewLoading,
|
||||
} InfraredView;
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,6 @@ void infrared_scene_universal_common_on_enter(void* context) {
|
||||
InfraredApp* infrared = context;
|
||||
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationVertical);
|
||||
view_stack_add_view(infrared->view_stack, button_panel_get_view(infrared->button_panel));
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
|
||||
// Load universal remote data in background
|
||||
infrared_blocking_task_start(infrared, infrared_scene_universal_common_task_callback);
|
||||
@@ -98,6 +97,8 @@ bool infrared_scene_universal_common_on_event(void* context, SceneManagerEvent e
|
||||
|
||||
if(!task_success) {
|
||||
scene_manager_next_scene(infrared->scene_manager, InfraredSceneErrorDatabases);
|
||||
} else {
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
}
|
||||
}
|
||||
consumed = true;
|
||||
|
||||
@@ -91,10 +91,7 @@ void infrared_scene_edit_delete_on_enter(void* context) {
|
||||
dialog_ex_set_result_callback(dialog_ex, infrared_scene_edit_delete_dialog_result_callback);
|
||||
dialog_ex_set_context(dialog_ex, context);
|
||||
|
||||
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
|
||||
view_stack_add_view(infrared->view_stack, dialog_ex_get_view(infrared->dialog_ex));
|
||||
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewDialogEx);
|
||||
}
|
||||
|
||||
bool infrared_scene_edit_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -136,5 +133,5 @@ bool infrared_scene_edit_delete_on_event(void* context, SceneManagerEvent event)
|
||||
|
||||
void infrared_scene_edit_delete_on_exit(void* context) {
|
||||
InfraredApp* infrared = context;
|
||||
view_stack_remove_view(infrared->view_stack, dialog_ex_get_view(infrared->dialog_ex));
|
||||
dialog_ex_reset(infrared->dialog_ex);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,7 @@ void infrared_scene_edit_move_on_enter(void* context) {
|
||||
infrared_move_view_set_callback(
|
||||
infrared->move_view, infrared_scene_edit_move_button_callback, infrared);
|
||||
|
||||
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
|
||||
view_stack_add_view(infrared->view_stack, infrared_move_view_get_view(infrared->move_view));
|
||||
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewMove);
|
||||
}
|
||||
|
||||
bool infrared_scene_edit_move_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -62,6 +59,8 @@ bool infrared_scene_edit_move_on_event(void* context, SceneManagerEvent event) {
|
||||
infrared_show_error_message(infrared, "Failed to move\n\"%s\"", signal_name);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
infrared->scene_manager, InfraredSceneRemoteList);
|
||||
} else {
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewMove);
|
||||
}
|
||||
}
|
||||
consumed = true;
|
||||
@@ -72,6 +71,5 @@ bool infrared_scene_edit_move_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void infrared_scene_edit_move_on_exit(void* context) {
|
||||
InfraredApp* infrared = context;
|
||||
view_stack_remove_view(infrared->view_stack, infrared_move_view_get_view(infrared->move_view));
|
||||
infrared_move_view_reset(infrared->move_view);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,7 @@ void infrared_scene_edit_rename_on_enter(void* context) {
|
||||
enter_name_length,
|
||||
false);
|
||||
|
||||
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
|
||||
view_stack_add_view(infrared->view_stack, text_input_get_view(infrared->text_input));
|
||||
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewTextInput);
|
||||
}
|
||||
|
||||
bool infrared_scene_edit_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -117,12 +114,10 @@ void infrared_scene_edit_rename_on_exit(void* context) {
|
||||
InfraredApp* infrared = context;
|
||||
TextInput* text_input = infrared->text_input;
|
||||
|
||||
view_stack_remove_view(infrared->view_stack, text_input_get_view(text_input));
|
||||
|
||||
void* validator_context = text_input_get_validator_callback_context(text_input);
|
||||
text_input_set_validator(text_input, NULL, NULL);
|
||||
|
||||
ValidatorIsFile* validator_context = text_input_get_validator_callback_context(text_input);
|
||||
if(validator_context) {
|
||||
validator_is_file_free((ValidatorIsFile*)validator_context);
|
||||
validator_is_file_free(validator_context);
|
||||
}
|
||||
|
||||
text_input_reset(text_input);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ static void infrared_scene_remote_list_select_and_load(InfraredApp* infrared) {
|
||||
infrared->dialogs, infrared->file_path, infrared->file_path, &browser_options);
|
||||
|
||||
if(file_selected) {
|
||||
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationVertical);
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
|
||||
// Load the remote in a separate thread
|
||||
infrared_blocking_task_start(infrared, infrared_scene_remote_list_task_callback);
|
||||
|
||||
|
||||
@@ -30,11 +30,8 @@ void infrared_scene_rpc_on_enter(void* context) {
|
||||
popup_set_context(popup, context);
|
||||
popup_set_callback(popup, infrared_popup_closed_callback);
|
||||
|
||||
view_stack_add_view(infrared->view_stack, popup_get_view(infrared->popup));
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
||||
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
|
||||
scene_manager_set_scene_state(infrared->scene_manager, InfraredSceneRpc, InfraredRpcStateIdle);
|
||||
|
||||
notification_message(infrared->notifications, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
@@ -69,6 +66,7 @@ bool infrared_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
popup_set_text(
|
||||
infrared->popup, infrared->text_store[0], 89, 44, AlignCenter, AlignTop);
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
|
||||
|
||||
rpc_system_app_confirm(infrared->rpc_ctx, task_success);
|
||||
|
||||
@@ -135,6 +133,5 @@ void infrared_scene_rpc_on_exit(void* context) {
|
||||
infrared_tx_stop(infrared);
|
||||
}
|
||||
|
||||
view_stack_remove_view(infrared->view_stack, popup_get_view(infrared->popup));
|
||||
popup_reset(infrared->popup);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user