From e0005d53365fb19362bffbdb8fa12c8b509faed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Fri, 10 Jun 2022 19:49:25 +0900 Subject: [PATCH] [FL-2534] Correct scene navigation UX in storage app #1308 --- .../scenes/storage_settings_scene_benchmark.c | 15 ++++++++++++--- .../storage_settings_scene_format_confirm.c | 14 +++++++++++--- .../scenes/storage_settings_scene_sd_info.c | 13 ++++++++++++- .../storage_settings_scene_unmount_confirm.c | 9 +++++---- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/applications/storage_settings/scenes/storage_settings_scene_benchmark.c b/applications/storage_settings/scenes/storage_settings_scene_benchmark.c index 45fbce8f..707891df 100644 --- a/applications/storage_settings/scenes/storage_settings_scene_benchmark.c +++ b/applications/storage_settings/scenes/storage_settings_scene_benchmark.c @@ -113,11 +113,14 @@ void storage_settings_scene_benchmark_on_enter(void* context) { StorageSettings* app = context; DialogEx* dialog_ex = app->dialog_ex; + FS_Error sd_status = storage_sd_status(app->fs_api); + scene_manager_set_scene_state(app->scene_manager, StorageSettingsBenchmark, sd_status); + dialog_ex_set_context(dialog_ex, app); dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_benchmark_dialog_callback); view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx); - if(storage_sd_status(app->fs_api) != FSE_OK) { + if(sd_status != FSE_OK) { dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text( dialog_ex, @@ -126,7 +129,7 @@ void storage_settings_scene_benchmark_on_enter(void* context) { 32, AlignCenter, AlignCenter); - dialog_ex_set_left_button_text(dialog_ex, "Back"); + dialog_ex_set_center_button_text(dialog_ex, "Ok"); } else { storage_settings_scene_benchmark(app); notification_message(app->notification, &sequence_blink_green_100); @@ -137,13 +140,19 @@ bool storage_settings_scene_benchmark_on_event(void* context, SceneManagerEvent StorageSettings* app = context; bool consumed = false; + FS_Error sd_status = + scene_manager_get_scene_state(app->scene_manager, StorageSettingsBenchmark); + if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case DialogExResultLeft: + case DialogExResultCenter: consumed = scene_manager_previous_scene(app->scene_manager); break; } + } else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) { + consumed = true; } + return consumed; } diff --git a/applications/storage_settings/scenes/storage_settings_scene_format_confirm.c b/applications/storage_settings/scenes/storage_settings_scene_format_confirm.c index 4a83bd51..1ebe8dfb 100644 --- a/applications/storage_settings/scenes/storage_settings_scene_format_confirm.c +++ b/applications/storage_settings/scenes/storage_settings_scene_format_confirm.c @@ -9,9 +9,9 @@ static void void storage_settings_scene_format_confirm_on_enter(void* context) { StorageSettings* app = context; - FS_Error sd_status = storage_sd_status(app->fs_api); DialogEx* dialog_ex = app->dialog_ex; - dialog_ex_set_left_button_text(dialog_ex, "Cancel"); + + FS_Error sd_status = storage_sd_status(app->fs_api); if(sd_status == FSE_NOT_READY) { dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); @@ -22,10 +22,12 @@ void storage_settings_scene_format_confirm_on_enter(void* context) { 32, AlignCenter, AlignCenter); + dialog_ex_set_center_button_text(dialog_ex, "Ok"); } else { - dialog_ex_set_right_button_text(dialog_ex, "Format"); dialog_ex_set_header(dialog_ex, "Format SD card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text(dialog_ex, "All data will be lost", 64, 32, AlignCenter, AlignCenter); + dialog_ex_set_left_button_text(dialog_ex, "Cancel"); + dialog_ex_set_right_button_text(dialog_ex, "Format"); } dialog_ex_set_context(dialog_ex, app); @@ -44,12 +46,18 @@ bool storage_settings_scene_format_confirm_on_event(void* context, SceneManagerE case DialogExResultLeft: consumed = scene_manager_previous_scene(app->scene_manager); break; + case DialogExResultCenter: + consumed = scene_manager_previous_scene(app->scene_manager); + break; case DialogExResultRight: scene_manager_next_scene(app->scene_manager, StorageSettingsFormatting); consumed = true; break; } + } else if(event.type == SceneManagerEventTypeBack) { + consumed = true; } + return consumed; } diff --git a/applications/storage_settings/scenes/storage_settings_scene_sd_info.c b/applications/storage_settings/scenes/storage_settings_scene_sd_info.c index b64caeb2..69ad1ea5 100644 --- a/applications/storage_settings/scenes/storage_settings_scene_sd_info.c +++ b/applications/storage_settings/scenes/storage_settings_scene_sd_info.c @@ -8,9 +8,11 @@ static void storage_settings_scene_sd_info_dialog_callback(DialogExResult result void storage_settings_scene_sd_info_on_enter(void* context) { StorageSettings* app = context; + DialogEx* dialog_ex = app->dialog_ex; + SDInfo sd_info; FS_Error sd_status = storage_sd_info(app->fs_api, &sd_info); - DialogEx* dialog_ex = app->dialog_ex; + scene_manager_set_scene_state(app->scene_manager, StorageSettingsSDInfo, sd_status); dialog_ex_set_context(dialog_ex, app); dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_sd_info_dialog_callback); @@ -24,6 +26,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) { 32, AlignCenter, AlignCenter); + dialog_ex_set_center_button_text(dialog_ex, "Ok"); } else { string_printf( app->text_string, @@ -43,17 +46,25 @@ bool storage_settings_scene_sd_info_on_event(void* context, SceneManagerEvent ev StorageSettings* app = context; bool consumed = false; + FS_Error sd_status = scene_manager_get_scene_state(app->scene_manager, StorageSettingsSDInfo); + if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { case DialogExResultLeft: consumed = scene_manager_previous_scene(app->scene_manager); break; + case DialogExResultCenter: + consumed = scene_manager_previous_scene(app->scene_manager); + break; case DialogExResultRight: scene_manager_next_scene(app->scene_manager, StorageSettingsUnmounted); consumed = true; break; } + } else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) { + consumed = true; } + return consumed; } diff --git a/applications/storage_settings/scenes/storage_settings_scene_unmount_confirm.c b/applications/storage_settings/scenes/storage_settings_scene_unmount_confirm.c index f9499322..001ce768 100644 --- a/applications/storage_settings/scenes/storage_settings_scene_unmount_confirm.c +++ b/applications/storage_settings/scenes/storage_settings_scene_unmount_confirm.c @@ -9,11 +9,11 @@ static void void storage_settings_scene_unmount_confirm_on_enter(void* context) { StorageSettings* app = context; - FS_Error sd_status = storage_sd_status(app->fs_api); DialogEx* dialog_ex = app->dialog_ex; + FS_Error sd_status = storage_sd_status(app->fs_api); + if(sd_status == FSE_NOT_READY) { - dialog_ex_set_center_button_text(dialog_ex, "OK"); dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text( dialog_ex, @@ -22,12 +22,13 @@ void storage_settings_scene_unmount_confirm_on_enter(void* context) { 32, AlignCenter, AlignCenter); + dialog_ex_set_center_button_text(dialog_ex, "OK"); } else { - dialog_ex_set_left_button_text(dialog_ex, "Cancel"); - dialog_ex_set_right_button_text(dialog_ex, "Unmount"); dialog_ex_set_header(dialog_ex, "Unmount SD card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_text( dialog_ex, "SD card will be\nunavailable", 64, 32, AlignCenter, AlignCenter); + dialog_ex_set_left_button_text(dialog_ex, "Cancel"); + dialog_ex_set_right_button_text(dialog_ex, "Unmount"); } dialog_ex_set_context(dialog_ex, app);