2021-09-21 13:56:33 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gui/gui_i.h>
|
|
|
|
#include <gui/view.h>
|
|
|
|
#include <gui/canvas.h>
|
|
|
|
#include <gui/elements.h>
|
|
|
|
#include <furi.h>
|
|
|
|
#include <storage/storage.h>
|
|
|
|
#include "../helpers/archive_files.h"
|
2022-09-15 21:00:51 +03:00
|
|
|
#include "../helpers/archive_menu.h"
|
2021-09-21 13:56:33 +03:00
|
|
|
#include "../helpers/archive_favorites.h"
|
2022-06-09 10:09:52 +03:00
|
|
|
#include "gui/modules/file_browser_worker.h"
|
2021-09-21 13:56:33 +03:00
|
|
|
|
|
|
|
#define MAX_LEN_PX 110
|
|
|
|
#define MAX_NAME_LEN 255
|
2022-01-29 12:39:10 +03:00
|
|
|
#define MAX_EXT_LEN 6
|
2021-09-21 13:56:33 +03:00
|
|
|
#define FRAME_HEIGHT 12
|
2022-05-06 16:37:10 +03:00
|
|
|
#define MENU_ITEMS 4u
|
|
|
|
#define MOVE_OFFSET 5u
|
2021-09-21 13:56:33 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ArchiveTabFavorites,
|
|
|
|
ArchiveTabSubGhz,
|
2021-10-02 19:54:10 +03:00
|
|
|
ArchiveTabLFRFID,
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveTabNFC,
|
2022-02-25 18:22:58 +03:00
|
|
|
ArchiveTabInfrared,
|
2021-10-02 19:54:10 +03:00
|
|
|
ArchiveTabIButton,
|
2022-02-10 16:01:49 +03:00
|
|
|
ArchiveTabBadUsb,
|
|
|
|
ArchiveTabU2f,
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveTabBrowser,
|
|
|
|
ArchiveTabTotal,
|
|
|
|
} ArchiveTabEnum;
|
|
|
|
|
|
|
|
typedef enum {
|
2022-09-15 21:00:51 +03:00
|
|
|
ArchiveBrowserEventFileMenuNone,
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveBrowserEventFileMenuOpen,
|
|
|
|
ArchiveBrowserEventFileMenuRun,
|
|
|
|
ArchiveBrowserEventFileMenuPin,
|
2022-06-09 10:09:52 +03:00
|
|
|
ArchiveBrowserEventFileMenuRename,
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveBrowserEventFileMenuDelete,
|
2022-09-15 21:00:51 +03:00
|
|
|
ArchiveBrowserEventFileMenuInfo,
|
|
|
|
ArchiveBrowserEventFileMenuClose,
|
2022-04-06 20:44:06 +03:00
|
|
|
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveBrowserEventEnterDir,
|
2022-04-06 20:44:06 +03:00
|
|
|
|
2021-10-12 16:09:34 +03:00
|
|
|
ArchiveBrowserEventFavMoveUp,
|
|
|
|
ArchiveBrowserEventFavMoveDown,
|
|
|
|
ArchiveBrowserEventEnterFavMove,
|
|
|
|
ArchiveBrowserEventExitFavMove,
|
|
|
|
ArchiveBrowserEventSaveFavMove,
|
2022-04-06 20:44:06 +03:00
|
|
|
|
|
|
|
ArchiveBrowserEventLoadPrevItems,
|
|
|
|
ArchiveBrowserEventLoadNextItems,
|
|
|
|
|
2022-06-09 10:09:52 +03:00
|
|
|
ArchiveBrowserEventListRefresh,
|
2022-04-27 19:34:37 +03:00
|
|
|
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveBrowserEventExit,
|
|
|
|
} ArchiveBrowserEvent;
|
|
|
|
|
|
|
|
typedef struct ArchiveBrowserView ArchiveBrowserView;
|
|
|
|
|
|
|
|
typedef void (*ArchiveBrowserViewCallback)(ArchiveBrowserEvent event, void* context);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BrowserActionBrowse,
|
|
|
|
BrowserActionItemMenu,
|
|
|
|
BrowserActionTotal,
|
|
|
|
} BrowserActionEnum;
|
|
|
|
|
|
|
|
struct ArchiveBrowserView {
|
|
|
|
View* view;
|
2022-06-09 10:09:52 +03:00
|
|
|
BrowserWorker* worker;
|
2022-08-22 19:19:03 +03:00
|
|
|
bool worker_running;
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveBrowserViewCallback callback;
|
|
|
|
void* context;
|
|
|
|
string_t path;
|
2022-06-09 10:09:52 +03:00
|
|
|
InputKey last_tab_switch_dir;
|
|
|
|
bool is_root;
|
2021-09-21 13:56:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ArchiveTabEnum tab_idx;
|
|
|
|
files_array_t files;
|
|
|
|
|
|
|
|
uint8_t menu_idx;
|
|
|
|
bool menu;
|
2022-09-15 21:00:51 +03:00
|
|
|
menu_array_t context_menu;
|
|
|
|
|
2022-06-09 10:09:52 +03:00
|
|
|
bool move_fav;
|
2022-04-06 20:44:06 +03:00
|
|
|
bool list_loading;
|
2022-06-09 10:09:52 +03:00
|
|
|
bool folder_loading;
|
2021-09-21 13:56:33 +03:00
|
|
|
|
2022-04-06 20:44:06 +03:00
|
|
|
uint32_t item_cnt;
|
|
|
|
int32_t item_idx;
|
|
|
|
int32_t array_offset;
|
|
|
|
int32_t list_offset;
|
2021-09-21 13:56:33 +03:00
|
|
|
} ArchiveBrowserViewModel;
|
|
|
|
|
|
|
|
void archive_browser_set_callback(
|
|
|
|
ArchiveBrowserView* browser,
|
|
|
|
ArchiveBrowserViewCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
View* archive_browser_get_view(ArchiveBrowserView* browser);
|
|
|
|
|
|
|
|
ArchiveBrowserView* browser_alloc();
|
2022-09-15 21:00:51 +03:00
|
|
|
|
2021-09-21 13:56:33 +03:00
|
|
|
void browser_free(ArchiveBrowserView* browser);
|