2021-09-21 10:56:33 +00: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"
|
|
|
|
#include "../helpers/archive_favorites.h"
|
|
|
|
|
|
|
|
#define MAX_LEN_PX 110
|
|
|
|
#define MAX_NAME_LEN 255
|
2022-01-29 09:39:10 +00:00
|
|
|
#define MAX_EXT_LEN 6
|
2021-09-21 10:56:33 +00:00
|
|
|
#define FRAME_HEIGHT 12
|
2022-05-06 13:37:10 +00:00
|
|
|
#define MENU_ITEMS 4u
|
|
|
|
#define MOVE_OFFSET 5u
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ArchiveTabFavorites,
|
|
|
|
ArchiveTabSubGhz,
|
2021-10-02 16:54:10 +00:00
|
|
|
ArchiveTabLFRFID,
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveTabNFC,
|
2022-02-25 15:22:58 +00:00
|
|
|
ArchiveTabInfrared,
|
2021-10-02 16:54:10 +00:00
|
|
|
ArchiveTabIButton,
|
2022-02-10 13:01:49 +00:00
|
|
|
ArchiveTabBadUsb,
|
|
|
|
ArchiveTabU2f,
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveTabBrowser,
|
|
|
|
ArchiveTabTotal,
|
|
|
|
} ArchiveTabEnum;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ArchiveBrowserEventFileMenuOpen,
|
|
|
|
ArchiveBrowserEventFileMenuClose,
|
|
|
|
ArchiveBrowserEventFileMenuRun,
|
|
|
|
ArchiveBrowserEventFileMenuPin,
|
2021-10-12 13:09:34 +00:00
|
|
|
ArchiveBrowserEventFileMenuAction,
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveBrowserEventFileMenuDelete,
|
2022-04-06 17:44:06 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveBrowserEventEnterDir,
|
2022-04-06 17:44:06 +00:00
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
ArchiveBrowserEventFavMoveUp,
|
|
|
|
ArchiveBrowserEventFavMoveDown,
|
|
|
|
ArchiveBrowserEventEnterFavMove,
|
|
|
|
ArchiveBrowserEventExitFavMove,
|
|
|
|
ArchiveBrowserEventSaveFavMove,
|
2022-04-06 17:44:06 +00:00
|
|
|
|
|
|
|
ArchiveBrowserEventLoadPrevItems,
|
|
|
|
ArchiveBrowserEventLoadNextItems,
|
|
|
|
|
2022-04-27 16:34:37 +00:00
|
|
|
ArchiveBrowserEventLoaderAppExit,
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveBrowserEventExit,
|
|
|
|
} ArchiveBrowserEvent;
|
|
|
|
|
|
|
|
static const uint8_t file_menu_actions[MENU_ITEMS] = {
|
|
|
|
[0] = ArchiveBrowserEventFileMenuRun,
|
|
|
|
[1] = ArchiveBrowserEventFileMenuPin,
|
2021-10-12 13:09:34 +00:00
|
|
|
[2] = ArchiveBrowserEventFileMenuAction,
|
2021-09-21 10:56:33 +00:00
|
|
|
[3] = ArchiveBrowserEventFileMenuDelete,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct ArchiveBrowserView ArchiveBrowserView;
|
|
|
|
|
|
|
|
typedef void (*ArchiveBrowserViewCallback)(ArchiveBrowserEvent event, void* context);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BrowserActionBrowse,
|
|
|
|
BrowserActionItemMenu,
|
|
|
|
BrowserActionTotal,
|
|
|
|
} BrowserActionEnum;
|
|
|
|
|
|
|
|
struct ArchiveBrowserView {
|
|
|
|
View* view;
|
|
|
|
ArchiveBrowserViewCallback callback;
|
|
|
|
void* context;
|
|
|
|
string_t path;
|
|
|
|
};
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
ARRAY_DEF(idx_last_array, int32_t)
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
typedef struct {
|
|
|
|
ArchiveTabEnum tab_idx;
|
|
|
|
ArchiveTabEnum last_tab;
|
|
|
|
files_array_t files;
|
2022-04-06 17:44:06 +00:00
|
|
|
idx_last_array_t idx_last;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
uint8_t menu_idx;
|
2021-10-12 13:09:34 +00:00
|
|
|
bool move_fav;
|
2021-09-21 10:56:33 +00:00
|
|
|
bool menu;
|
2022-04-06 17:44:06 +00:00
|
|
|
bool list_loading;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
uint32_t item_cnt;
|
|
|
|
int32_t item_idx;
|
|
|
|
int32_t array_offset;
|
|
|
|
int32_t list_offset;
|
2021-09-21 10:56:33 +00:00
|
|
|
} ArchiveBrowserViewModel;
|
|
|
|
|
|
|
|
void archive_browser_set_callback(
|
|
|
|
ArchiveBrowserView* browser,
|
|
|
|
ArchiveBrowserViewCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
View* archive_browser_get_view(ArchiveBrowserView* browser);
|
|
|
|
|
|
|
|
ArchiveBrowserView* browser_alloc();
|
|
|
|
void browser_free(ArchiveBrowserView* browser);
|