mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-07 19:01:54 -07:00
Archive fix favorites, u2f and app tabs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "archive_files.h"
|
||||
#include "archive_apps.h"
|
||||
#include "archive_browser.h"
|
||||
#include <applications/main/u2f/u2f_data.h>
|
||||
|
||||
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")) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user