From 2b2708e635fae366f99d3958ff0b71199dda7c68 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 4 Jun 2023 17:28:41 +0100 Subject: [PATCH] Archive fix favorites, u2f and app tabs --- .../main/archive/helpers/archive_apps.c | 13 +++---- .../main/archive/helpers/archive_browser.c | 8 ++--- .../main/archive/views/archive_browser_view.c | 34 ++++++++++--------- .../main/archive/views/archive_browser_view.h | 1 + 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/applications/main/archive/helpers/archive_apps.c b/applications/main/archive/helpers/archive_apps.c index c8ad67625..b7037e6b7 100644 --- a/applications/main/archive/helpers/archive_apps.c +++ b/applications/main/archive/helpers/archive_apps.c @@ -1,6 +1,7 @@ #include "archive_files.h" #include "archive_apps.h" #include "archive_browser.h" +#include static const char* known_apps[] = { [ArchiveAppTypeU2f] = "u2f", @@ -28,13 +29,9 @@ bool archive_app_is_available(void* context, const char* path) { ArchiveAppTypeEnum app = archive_get_app_type(path); if(app == ArchiveAppTypeU2f) { - bool file_exists = false; Storage* storage = furi_record_open(RECORD_STORAGE); - - if(storage_file_exists(storage, ANY_PATH("u2f/key.u2f"))) { - file_exists = storage_file_exists(storage, ANY_PATH("u2f/cnt.u2f")); - } - + bool file_exists = storage_file_exists(storage, U2F_KEY_FILE) && + storage_file_exists(storage, U2F_CNT_FILE); furi_record_close(RECORD_STORAGE); return file_exists; } else { @@ -69,8 +66,8 @@ void archive_app_delete_file(void* context, const char* path) { if(app == ArchiveAppTypeU2f) { Storage* fs_api = furi_record_open(RECORD_STORAGE); - res = (storage_common_remove(fs_api, ANY_PATH("u2f/key.u2f")) == FSE_OK); - res |= (storage_common_remove(fs_api, ANY_PATH("u2f/cnt.u2f")) == FSE_OK); + res = (storage_common_remove(fs_api, U2F_KEY_FILE) == FSE_OK); + res |= (storage_common_remove(fs_api, U2F_CNT_FILE) == FSE_OK); furi_record_close(RECORD_STORAGE); if(archive_is_favorite("/app:u2f/U2F Token")) { diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c index 57219e05b..b0781d843 100644 --- a/applications/main/archive/helpers/archive_browser.c +++ b/applications/main/archive/helpers/archive_browser.c @@ -482,11 +482,10 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) { furi_string_set(browser->path, archive_get_default_path(tab)); bool tab_empty = true; + bool is_app_tab = furi_string_start_with_str(browser->path, "/app:"); if(tab == ArchiveTabFavorites) { - if(archive_favorites_count(browser) > 0) { - tab_empty = false; - } - } else if(furi_string_start_with_str(browser->path, "/app:")) { + tab_empty = false; + } else if(is_app_tab) { char* app_name = strchr(furi_string_get_cstr(browser->path), ':'); if(app_name != NULL) { if(archive_app_is_available(browser, furi_string_get_cstr(browser->path))) { @@ -518,6 +517,7 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) { { model->item_idx = 0; model->array_offset = 0; + model->is_app_tab = is_app_tab; }, false); archive_get_items(browser, furi_string_get_cstr(browser->path)); diff --git a/applications/main/archive/views/archive_browser_view.c b/applications/main/archive/views/archive_browser_view.c index d4a52ba9e..33e1eace6 100644 --- a/applications/main/archive/views/archive_browser_view.c +++ b/applications/main/archive/views/archive_browser_view.c @@ -64,25 +64,27 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) { FuriString* item_new_dir = furi_string_alloc_set("New Dir"); FuriString* item_rename = furi_string_alloc_set("Rename"); FuriString* item_delete = furi_string_alloc_set("Delete"); - if(model->clipboard != NULL) { + if(!model->is_app_tab) { + if(model->clipboard != NULL) { + archive_menu_add_item( + menu_array_push_raw(model->context_menu), + item_paste, + ArchiveBrowserEventFileMenuPaste); + } else if(selected) { + archive_menu_add_item( + menu_array_push_raw(model->context_menu), + item_cut, + ArchiveBrowserEventFileMenuCut); + archive_menu_add_item( + menu_array_push_raw(model->context_menu), + item_copy, + ArchiveBrowserEventFileMenuCopy); + } archive_menu_add_item( menu_array_push_raw(model->context_menu), - item_paste, - ArchiveBrowserEventFileMenuPaste); - } else if(selected) { - archive_menu_add_item( - menu_array_push_raw(model->context_menu), - item_cut, - ArchiveBrowserEventFileMenuCut); - archive_menu_add_item( - menu_array_push_raw(model->context_menu), - item_copy, - ArchiveBrowserEventFileMenuCopy); + item_new_dir, + ArchiveBrowserEventFileMenuNewDir); } - archive_menu_add_item( - menu_array_push_raw(model->context_menu), - item_new_dir, - ArchiveBrowserEventFileMenuNewDir); if(selected) { if(!selected->is_app) { archive_menu_add_item( diff --git a/applications/main/archive/views/archive_browser_view.h b/applications/main/archive/views/archive_browser_view.h index 1b4c0f525..ed18df387 100644 --- a/applications/main/archive/views/archive_browser_view.h +++ b/applications/main/archive/views/archive_browser_view.h @@ -101,6 +101,7 @@ typedef struct { bool clipboard_copy; menu_array_t context_menu; + bool is_app_tab; bool move_fav; bool list_loading; bool folder_loading;