[FL-1823, FL-1824] Archive app: refactoring and UI improvements (#711)

* Archive app: skip empty app folders, file menu in favorites tab, looped tab switching
* refactoring
* cleanup
* better filepath trim
* fix excessive view updates, various small optimizations
* better list_offset calculation, favorites vargs)
* revert poor fix

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
its your bedtime
2021-09-21 13:56:33 +03:00
committed by GitHub
parent 0e1922db4d
commit 4c05f67686
14 changed files with 948 additions and 910 deletions

View File

@@ -9,72 +9,20 @@
#include <gui/modules/text_input.h>
#include <loader/loader.h>
#include <m-string.h>
#include <m-array.h>
#include <storage/storage.h>
#include "applications.h"
#include "file-worker.h"
#include "views/archive_main_view.h"
#include "views/archive_browser_view.h"
#include "scenes/archive_scene.h"
#define MAX_FILE_SIZE 128
typedef enum {
ArchiveViewBrowser,
ArchiveViewTextInput,
ArchiveViewTotal,
} ArchiveViewEnum;
static const char* tab_default_paths[] = {
[ArchiveTabFavorites] = "/any/favorites",
[ArchiveTabIButton] = "/any/ibutton",
[ArchiveTabNFC] = "/any/nfc",
[ArchiveTabSubGhz] = "/any/subghz/saved",
[ArchiveTabLFRFID] = "/any/lfrfid",
[ArchiveTabIrda] = "/any/irda",
[ArchiveTabBrowser] = "/any",
};
static inline const char* get_default_path(ArchiveFileTypeEnum type) {
switch(type) {
case ArchiveFileTypeIButton:
return tab_default_paths[ArchiveTabIButton];
case ArchiveFileTypeNFC:
return tab_default_paths[ArchiveTabNFC];
case ArchiveFileTypeSubGhz:
return tab_default_paths[ArchiveTabSubGhz];
case ArchiveFileTypeLFRFID:
return tab_default_paths[ArchiveTabLFRFID];
case ArchiveFileTypeIrda:
return tab_default_paths[ArchiveTabIrda];
default:
return false;
}
}
static inline const char* get_favorites_path() {
return tab_default_paths[ArchiveTabFavorites];
}
typedef enum {
EventTypeTick,
EventTypeKey,
EventTypeExit,
} EventType;
typedef struct {
union {
InputEvent input;
} value;
EventType type;
} AppEvent;
struct ArchiveApp {
Gui* gui;
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
ArchiveMainView* main_view;
ArchiveBrowserView* browser;
TextInput* text_input;
char text_store[MAX_NAME_LEN];
};