2022-06-09 07:09:52 +00:00
|
|
|
#include "assets_icons.h"
|
|
|
|
#include "toolbox/path.h"
|
2021-09-21 10:56:33 +00:00
|
|
|
#include <furi.h>
|
|
|
|
#include "../archive_i.h"
|
|
|
|
#include "archive_browser_view.h"
|
|
|
|
#include "../helpers/archive_browser.h"
|
|
|
|
|
2022-09-15 18:00:51 +00:00
|
|
|
#define TAG "Archive"
|
2022-12-20 11:11:52 +00:00
|
|
|
#define SCROLL_INTERVAL (333)
|
|
|
|
#define SCROLL_DELAY (2)
|
2022-09-15 18:00:51 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
static const char* ArchiveTabNames[] = {
|
|
|
|
[ArchiveTabFavorites] = "Favorites",
|
|
|
|
[ArchiveTabIButton] = "iButton",
|
|
|
|
[ArchiveTabNFC] = "NFC",
|
|
|
|
[ArchiveTabSubGhz] = "Sub-GHz",
|
2023-07-14 11:16:37 +00:00
|
|
|
[ArchiveTabSubGhzRemote] = "SubRem",
|
2021-09-21 10:56:33 +00:00
|
|
|
[ArchiveTabLFRFID] = "RFID LF",
|
2022-02-25 15:22:58 +00:00
|
|
|
[ArchiveTabInfrared] = "Infrared",
|
2022-02-10 13:01:49 +00:00
|
|
|
[ArchiveTabBadUsb] = "Bad USB",
|
|
|
|
[ArchiveTabU2f] = "U2F",
|
2022-10-06 15:37:53 +00:00
|
|
|
[ArchiveTabApplications] = "Apps",
|
2023-02-11 14:40:46 +00:00
|
|
|
[ArchiveTabInternal] = "Internal",
|
2022-04-13 20:50:25 +00:00
|
|
|
[ArchiveTabBrowser] = "Browser",
|
|
|
|
};
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
static const Icon* ArchiveItemIcons[] = {
|
|
|
|
[ArchiveFileTypeIButton] = &I_ibutt_10px,
|
|
|
|
[ArchiveFileTypeNFC] = &I_Nfc_10px,
|
|
|
|
[ArchiveFileTypeSubGhz] = &I_sub1_10px,
|
2023-07-14 11:16:37 +00:00
|
|
|
[ArchiveFileTypeSubGhzRemote] = &I_subrem_10px,
|
2021-09-21 10:56:33 +00:00
|
|
|
[ArchiveFileTypeLFRFID] = &I_125_10px,
|
2022-02-25 15:22:58 +00:00
|
|
|
[ArchiveFileTypeInfrared] = &I_ir_10px,
|
2022-02-10 13:01:49 +00:00
|
|
|
[ArchiveFileTypeBadUsb] = &I_badusb_10px,
|
|
|
|
[ArchiveFileTypeU2f] = &I_u2f_10px,
|
2022-10-06 15:42:59 +00:00
|
|
|
[ArchiveFileTypeApplication] = &I_Apps_10px,
|
2022-04-13 20:50:25 +00:00
|
|
|
[ArchiveFileTypeUpdateManifest] = &I_update_10px,
|
2021-09-21 10:56:33 +00:00
|
|
|
[ArchiveFileTypeFolder] = &I_dir_10px,
|
|
|
|
[ArchiveFileTypeUnknown] = &I_unknown_10px,
|
2022-06-09 07:09:52 +00:00
|
|
|
[ArchiveFileTypeLoading] = &I_loading_10px,
|
2021-09-21 10:56:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void archive_browser_set_callback(
|
|
|
|
ArchiveBrowserView* browser,
|
|
|
|
ArchiveBrowserViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(callback);
|
|
|
|
browser->callback = callback;
|
|
|
|
browser->context = context;
|
|
|
|
}
|
|
|
|
|
2023-07-18 20:46:28 +00:00
|
|
|
static void contex_menu_filemanager_init(ArchiveBrowserViewModel* model) {
|
|
|
|
if(model->item_cnt > 0) {
|
|
|
|
if(model->clipboard_mode == CLIPBOARD_MODE_OFF) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "Cut", ArchiveBrowserEventFileMenuCut);
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "Copy", ArchiveBrowserEventFileMenuCopy);
|
|
|
|
} else if(model->clipboard_mode == CLIPBOARD_MODE_CUT) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Past",
|
|
|
|
ArchiveBrowserEventFileMenuPast_Cut);
|
|
|
|
} else if(model->clipboard_mode == CLIPBOARD_MODE_COPY) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Past",
|
|
|
|
ArchiveBrowserEventFileMenuPast_Copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "NewDir", ArchiveBrowserEventFileMenuNewDir);
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "Rename", ArchiveBrowserEventFileMenuRename);
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "Delete", ArchiveBrowserEventFileMenuDelete);
|
|
|
|
} else {
|
|
|
|
if(model->clipboard_mode == CLIPBOARD_MODE_CUT) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Past",
|
|
|
|
ArchiveBrowserEventFileMenuPast_Cut);
|
|
|
|
} else if(model->clipboard_mode == CLIPBOARD_MODE_COPY) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Past",
|
|
|
|
ArchiveBrowserEventFileMenuPast_Copy);
|
|
|
|
}
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu), "NewDir", ArchiveBrowserEventFileMenuNewDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
|
2022-09-15 18:00:51 +00:00
|
|
|
if(menu_array_size(model->context_menu) == 0) {
|
|
|
|
// Context menu is empty, init array
|
2023-07-16 17:28:15 +00:00
|
|
|
const char* item_pin = "Pin";
|
2022-09-15 18:00:51 +00:00
|
|
|
|
|
|
|
// Need init context menu
|
|
|
|
ArchiveFile_t* selected =
|
|
|
|
files_array_get(model->files, model->item_idx - model->array_offset);
|
|
|
|
|
|
|
|
if((selected->fav) || (model->tab_idx == ArchiveTabFavorites)) {
|
2023-07-16 17:28:15 +00:00
|
|
|
item_pin = "Unpin";
|
2022-09-15 18:00:51 +00:00
|
|
|
}
|
2022-04-14 11:28:59 +00:00
|
|
|
|
2022-09-15 19:33:43 +00:00
|
|
|
if(selected->type == ArchiveFileTypeFolder) {
|
2023-07-16 17:28:15 +00:00
|
|
|
// Folder
|
2022-09-15 23:52:43 +00:00
|
|
|
//FURI_LOG_D(TAG, "Directory type");
|
2023-07-18 20:46:28 +00:00
|
|
|
|
|
|
|
// { Copy/Cut, Past } NewDir, Rename, Delete
|
|
|
|
model->menu_file_manage = true;
|
|
|
|
model->menu_can_switch = false;
|
|
|
|
|
|
|
|
contex_menu_filemanager_init(model);
|
2022-09-15 18:00:51 +00:00
|
|
|
} else if(!archive_is_known_app(selected->type)) {
|
2023-07-16 17:28:15 +00:00
|
|
|
// UnKnown app type
|
2022-09-15 23:52:43 +00:00
|
|
|
//FURI_LOG_D(TAG, "Unknown type");
|
2023-07-18 20:46:28 +00:00
|
|
|
model->menu_can_switch = true;
|
|
|
|
if(model->menu_file_manage) {
|
|
|
|
// { Copy/Cut, Past } NewDir, Rename, Delete
|
|
|
|
contex_menu_filemanager_init(model);
|
2023-07-16 17:28:15 +00:00
|
|
|
} else {
|
|
|
|
// Info, [Show],
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Info",
|
|
|
|
ArchiveBrowserEventFileMenuInfo);
|
|
|
|
if(selected->is_text_file) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Show",
|
|
|
|
ArchiveBrowserEventFileMenuShow);
|
|
|
|
}
|
2022-10-28 13:05:17 +00:00
|
|
|
}
|
2022-09-15 18:00:51 +00:00
|
|
|
|
2023-07-16 17:28:15 +00:00
|
|
|
} else if(model->tab_idx == ArchiveTabFavorites) {
|
|
|
|
// Favorites tab
|
|
|
|
// Run, Unpin, [Show], Move
|
2022-09-15 18:00:51 +00:00
|
|
|
|
2023-07-16 17:28:15 +00:00
|
|
|
//FURI_LOG_D(TAG, "ArchiveTabFavorites");
|
2023-07-18 20:46:28 +00:00
|
|
|
|
|
|
|
model->menu_can_switch = false;
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
2023-07-16 17:28:15 +00:00
|
|
|
menu_array_push_raw(model->context_menu), "Run", ArchiveBrowserEventFileMenuRun);
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
item_pin,
|
|
|
|
ArchiveBrowserEventFileMenuPin);
|
2022-10-28 13:05:17 +00:00
|
|
|
if(selected->type <= ArchiveFileTypeBadUsb) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
2023-07-16 17:28:15 +00:00
|
|
|
"Show",
|
2022-10-28 13:05:17 +00:00
|
|
|
ArchiveBrowserEventFileMenuShow);
|
|
|
|
}
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
2023-07-16 17:28:15 +00:00
|
|
|
menu_array_push_raw(model->context_menu), "Move", ArchiveBrowserEventEnterFavMove);
|
2022-02-10 13:01:49 +00:00
|
|
|
} else if(selected->is_app) {
|
2023-07-16 17:28:15 +00:00
|
|
|
// Only U2F?
|
|
|
|
// Run, Info, [Show], Pin, Delete
|
2023-07-18 20:46:28 +00:00
|
|
|
model->menu_file_manage = false;
|
2023-07-16 17:28:15 +00:00
|
|
|
|
2022-09-15 23:52:43 +00:00
|
|
|
//FURI_LOG_D(TAG, "3 types");
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
2023-07-16 17:28:15 +00:00
|
|
|
menu_array_push_raw(model->context_menu), "Run", ArchiveBrowserEventFileMenuRun);
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
2023-07-16 17:28:15 +00:00
|
|
|
menu_array_push_raw(model->context_menu), "Info", ArchiveBrowserEventFileMenuInfo);
|
2022-10-28 13:05:17 +00:00
|
|
|
if(selected->type <= ArchiveFileTypeBadUsb) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
2023-07-16 17:28:15 +00:00
|
|
|
"Show",
|
2022-10-28 13:05:17 +00:00
|
|
|
ArchiveBrowserEventFileMenuShow);
|
|
|
|
}
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
item_pin,
|
|
|
|
ArchiveBrowserEventFileMenuPin);
|
2023-07-16 17:28:15 +00:00
|
|
|
|
2022-09-15 18:00:51 +00:00
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
2023-07-16 17:28:15 +00:00
|
|
|
"Delete",
|
2022-09-15 18:00:51 +00:00
|
|
|
ArchiveBrowserEventFileMenuDelete);
|
|
|
|
} else {
|
2023-07-16 17:28:15 +00:00
|
|
|
// Other
|
2022-09-15 23:52:43 +00:00
|
|
|
//FURI_LOG_D(TAG, "All menu");
|
2023-07-16 17:28:15 +00:00
|
|
|
|
2023-07-18 20:46:28 +00:00
|
|
|
model->menu_can_switch = true;
|
|
|
|
if(model->menu_file_manage) {
|
|
|
|
// { Copy/Cut, Past } NewDir, Rename, Delete
|
|
|
|
contex_menu_filemanager_init(model);
|
2023-07-16 17:28:15 +00:00
|
|
|
} else {
|
|
|
|
// Run, Pin, Info, [Show]
|
|
|
|
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Run",
|
|
|
|
ArchiveBrowserEventFileMenuRun);
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
item_pin,
|
|
|
|
ArchiveBrowserEventFileMenuPin);
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Info",
|
|
|
|
ArchiveBrowserEventFileMenuInfo);
|
|
|
|
if(selected->type <= ArchiveFileTypeBadUsb) {
|
|
|
|
archive_menu_add_item(
|
|
|
|
menu_array_push_raw(model->context_menu),
|
|
|
|
"Show",
|
|
|
|
ArchiveBrowserEventFileMenuShow);
|
|
|
|
}
|
2022-10-28 13:05:17 +00:00
|
|
|
}
|
2022-02-10 13:01:49 +00:00
|
|
|
}
|
2022-09-15 23:52:43 +00:00
|
|
|
} /*else {
|
2022-09-15 19:33:43 +00:00
|
|
|
FURI_LOG_D(TAG, "menu_array_size already set: %d", menu_array_size(model->context_menu));
|
2022-09-15 23:52:43 +00:00
|
|
|
}*/
|
2022-09-15 18:00:51 +00:00
|
|
|
size_t size_menu = menu_array_size(model->context_menu);
|
2023-07-18 20:46:28 +00:00
|
|
|
|
|
|
|
const uint8_t menu_y = 0;
|
2022-09-15 19:33:43 +00:00
|
|
|
const uint8_t menu_height = 48;
|
|
|
|
const uint8_t line_height = 10;
|
2022-02-10 13:01:49 +00:00
|
|
|
|
2022-09-15 18:00:51 +00:00
|
|
|
canvas_set_color(canvas, ColorWhite);
|
2023-07-16 17:28:15 +00:00
|
|
|
uint8_t calc_height = menu_height - ((MENU_ITEMS - size_menu - 1) * line_height);
|
2023-07-18 20:46:28 +00:00
|
|
|
canvas_draw_box(canvas, 71, menu_y, 57, calc_height + 4 + 2);
|
2022-09-15 18:00:51 +00:00
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
2023-07-18 20:46:28 +00:00
|
|
|
elements_slightly_rounded_frame(canvas, 70, menu_y, 58, calc_height + 5 + 1);
|
|
|
|
canvas_draw_line(canvas, 70, menu_y + 1 + line_height, 128, menu_y + 1 + line_height);
|
2022-09-15 23:52:43 +00:00
|
|
|
/*FURI_LOG_D(
|
2022-09-15 18:00:51 +00:00
|
|
|
TAG,
|
|
|
|
"size_menu: %d, calc_height: %d, menu_idx: %d",
|
|
|
|
size_menu,
|
|
|
|
calc_height,
|
2022-09-15 23:52:43 +00:00
|
|
|
model->menu_idx);*/
|
2023-07-18 20:46:28 +00:00
|
|
|
if(model->menu_file_manage) {
|
|
|
|
canvas_draw_str(canvas, 82, menu_y + line_height - 1, "Manage");
|
2023-07-16 17:28:15 +00:00
|
|
|
} else {
|
2023-07-18 20:46:28 +00:00
|
|
|
canvas_draw_str(canvas, 82, menu_y + line_height - 1, "Actions");
|
|
|
|
}
|
|
|
|
if(model->menu_can_switch) {
|
|
|
|
canvas_draw_icon(canvas, 74, menu_y + 2, &I_ButtonLeft_4x7);
|
|
|
|
canvas_draw_icon(canvas, 120, menu_y + 2, &I_ButtonRight_4x7);
|
2023-07-16 17:28:15 +00:00
|
|
|
}
|
2022-09-15 18:00:51 +00:00
|
|
|
for(size_t i = 0; i < size_menu; i++) {
|
|
|
|
ArchiveContextMenuItem_t* current = menu_array_get(model->context_menu, i);
|
2023-07-16 17:28:15 +00:00
|
|
|
canvas_draw_str(
|
2023-07-18 20:46:28 +00:00
|
|
|
canvas,
|
|
|
|
82,
|
|
|
|
menu_y + 1 + line_height + (i + 1) * line_height,
|
|
|
|
furi_string_get_cstr(current->text));
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
2023-07-18 20:46:28 +00:00
|
|
|
canvas_draw_icon(
|
|
|
|
canvas, 74, menu_y + 4 + (model->menu_idx + 1) * line_height, &I_ButtonRight_4x7);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar, bool moving) {
|
|
|
|
uint8_t x_offset = moving ? MOVE_OFFSET : 0;
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2021-10-12 13:09:34 +00:00
|
|
|
canvas_draw_box(
|
|
|
|
canvas,
|
|
|
|
0 + x_offset,
|
|
|
|
15 + idx * FRAME_HEIGHT,
|
|
|
|
(scrollbar ? 122 : 127) - x_offset,
|
|
|
|
FRAME_HEIGHT);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
2021-10-12 13:09:34 +00:00
|
|
|
canvas_draw_dot(canvas, 0 + x_offset, 15 + idx * FRAME_HEIGHT);
|
|
|
|
canvas_draw_dot(canvas, 1 + x_offset, 15 + idx * FRAME_HEIGHT);
|
|
|
|
canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 1);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 11);
|
2021-09-21 10:56:33 +00:00
|
|
|
canvas_draw_dot(canvas, scrollbar ? 121 : 126, 15 + idx * FRAME_HEIGHT);
|
|
|
|
canvas_draw_dot(canvas, scrollbar ? 121 : 126, (15 + idx * FRAME_HEIGHT) + 11);
|
|
|
|
}
|
|
|
|
|
2022-06-09 07:09:52 +00:00
|
|
|
static void archive_draw_loading(Canvas* canvas, ArchiveBrowserViewModel* model) {
|
|
|
|
furi_assert(model);
|
|
|
|
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
uint8_t x = 128 / 2 - 24 / 2;
|
|
|
|
uint8_t y = 64 / 2 - 24 / 2;
|
2022-06-09 07:09:52 +00:00
|
|
|
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
canvas_draw_icon(canvas, x, y, &A_Loading_24);
|
2022-06-09 07:09:52 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
|
|
|
|
furi_assert(model);
|
|
|
|
|
|
|
|
size_t array_size = files_array_size(model->files);
|
2022-04-06 17:44:06 +00:00
|
|
|
bool scrollbar = model->item_cnt > 4;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-05-06 13:37:10 +00:00
|
|
|
for(uint32_t i = 0; i < MIN(model->item_cnt, MENU_ITEMS); ++i) {
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* str_buf;
|
|
|
|
str_buf = furi_string_alloc();
|
2022-05-06 13:37:10 +00:00
|
|
|
int32_t idx = CLAMP((uint32_t)(i + model->list_offset), model->item_cnt, 0u);
|
2022-04-06 17:44:06 +00:00
|
|
|
uint8_t x_offset = (model->move_fav && model->item_idx == idx) ? MOVE_OFFSET : 0;
|
|
|
|
|
|
|
|
ArchiveFileTypeEnum file_type = ArchiveFileTypeLoading;
|
2022-10-06 15:37:53 +00:00
|
|
|
uint8_t* custom_icon_data = NULL;
|
2022-04-06 17:44:06 +00:00
|
|
|
|
|
|
|
if(archive_is_item_in_array(model, idx)) {
|
2022-05-06 13:37:10 +00:00
|
|
|
ArchiveFile_t* file = files_array_get(
|
|
|
|
model->files, CLAMP(idx - model->array_offset, (int32_t)(array_size - 1), 0));
|
2022-04-06 17:44:06 +00:00
|
|
|
file_type = file->type;
|
2022-10-06 15:37:53 +00:00
|
|
|
if(file_type == ArchiveFileTypeApplication) {
|
|
|
|
if(file->custom_icon_data) {
|
|
|
|
custom_icon_data = file->custom_icon_data;
|
|
|
|
furi_string_set(str_buf, file->custom_name);
|
|
|
|
} else {
|
|
|
|
file_type = ArchiveFileTypeUnknown;
|
|
|
|
path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
path_extract_filename(file->path, str_buf, archive_is_known_app(file->type));
|
|
|
|
}
|
2022-04-06 17:44:06 +00:00
|
|
|
} else {
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_set(str_buf, "---");
|
2022-04-06 17:44:06 +00:00
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-12-20 11:11:52 +00:00
|
|
|
size_t scroll_counter = model->scroll_counter;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if(model->item_idx == idx) {
|
2021-10-12 13:09:34 +00:00
|
|
|
archive_draw_frame(canvas, i, scrollbar, model->move_fav);
|
2022-12-20 11:11:52 +00:00
|
|
|
if(scroll_counter < SCROLL_DELAY) {
|
|
|
|
scroll_counter = 0;
|
|
|
|
} else {
|
|
|
|
scroll_counter -= SCROLL_DELAY;
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
} else {
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2022-12-20 11:11:52 +00:00
|
|
|
scroll_counter = 0;
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
2022-10-06 15:37:53 +00:00
|
|
|
if(custom_icon_data) {
|
|
|
|
canvas_draw_bitmap(
|
|
|
|
canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, 11, 10, custom_icon_data);
|
|
|
|
} else {
|
|
|
|
canvas_draw_icon(
|
|
|
|
canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file_type]);
|
|
|
|
}
|
2022-12-20 11:11:52 +00:00
|
|
|
|
|
|
|
elements_scrollable_text_line(
|
|
|
|
canvas,
|
|
|
|
15 + x_offset,
|
|
|
|
24 + i * FRAME_HEIGHT,
|
|
|
|
((scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX) - x_offset),
|
|
|
|
str_buf,
|
|
|
|
scroll_counter,
|
|
|
|
(model->item_idx != idx));
|
2022-04-06 17:44:06 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(str_buf);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(scrollbar) {
|
2022-04-06 17:44:06 +00:00
|
|
|
elements_scrollbar_pos(canvas, 126, 15, 49, model->item_idx, model->item_cnt);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(model->menu) {
|
|
|
|
render_item_menu(canvas, model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void archive_render_status_bar(Canvas* canvas, ArchiveBrowserViewModel* model) {
|
|
|
|
furi_assert(model);
|
|
|
|
|
|
|
|
const char* tab_name = ArchiveTabNames[model->tab_idx];
|
2023-07-18 20:46:28 +00:00
|
|
|
bool clip = model->clipboard_mode != CLIPBOARD_MODE_OFF;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_Background_128x11);
|
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
canvas_draw_box(canvas, 0, 0, 50, 13);
|
|
|
|
canvas_draw_box(canvas, 107, 0, 20, 13);
|
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2022-05-06 17:35:52 +00:00
|
|
|
canvas_draw_rframe(canvas, 0, 0, 51, 13, 1); // frame
|
|
|
|
canvas_draw_line(canvas, 49, 1, 49, 11); // shadow right
|
|
|
|
canvas_draw_line(canvas, 1, 11, 49, 11); // shadow bottom
|
|
|
|
canvas_draw_str_aligned(canvas, 25, 9, AlignCenter, AlignBottom, tab_name);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-05-06 17:35:52 +00:00
|
|
|
canvas_draw_rframe(canvas, 107, 0, 21, 13, 1);
|
|
|
|
canvas_draw_line(canvas, 126, 1, 126, 11);
|
|
|
|
canvas_draw_line(canvas, 108, 11, 126, 11);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
if(model->move_fav) {
|
2022-05-06 17:35:52 +00:00
|
|
|
canvas_draw_icon(canvas, 110, 4, &I_ButtonUp_7x4);
|
|
|
|
canvas_draw_icon(canvas, 117, 4, &I_ButtonDown_7x4);
|
2021-10-12 13:09:34 +00:00
|
|
|
} else {
|
2022-05-06 17:35:52 +00:00
|
|
|
canvas_draw_icon(canvas, 111, 2, &I_ButtonLeft_4x7);
|
|
|
|
canvas_draw_icon(canvas, 119, 2, &I_ButtonRight_4x7);
|
2021-10-12 13:09:34 +00:00
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
canvas_draw_dot(canvas, 50, 0);
|
|
|
|
canvas_draw_dot(canvas, 127, 0);
|
|
|
|
|
2023-07-18 20:46:28 +00:00
|
|
|
if(clip) {
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
canvas_draw_box(canvas, 69, 0, 24, 13);
|
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
canvas_draw_rframe(canvas, 69, 0, 25, 13, 1);
|
|
|
|
canvas_draw_line(canvas, 92, 1, 92, 11);
|
|
|
|
canvas_draw_line(canvas, 70, 11, 92, 11);
|
|
|
|
canvas_draw_str_aligned(
|
|
|
|
canvas,
|
|
|
|
81,
|
|
|
|
9,
|
|
|
|
AlignCenter,
|
|
|
|
AlignBottom,
|
|
|
|
(model->clipboard_mode == CLIPBOARD_MODE_COPY) ? "Copy" : "Cut");
|
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
canvas_draw_dot(canvas, 93, 0);
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
}
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
static void archive_view_render(Canvas* canvas, void* mdl) {
|
2022-04-06 17:44:06 +00:00
|
|
|
ArchiveBrowserViewModel* model = mdl;
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
archive_render_status_bar(canvas, mdl);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-06-09 07:09:52 +00:00
|
|
|
if(model->folder_loading) {
|
|
|
|
archive_draw_loading(canvas, model);
|
|
|
|
} else if(model->item_cnt > 0) {
|
2022-04-06 17:44:06 +00:00
|
|
|
draw_list(canvas, model);
|
2021-09-21 10:56:33 +00:00
|
|
|
} else {
|
|
|
|
canvas_draw_str_aligned(
|
|
|
|
canvas, GUI_DISPLAY_WIDTH / 2, 40, AlignCenter, AlignCenter, "Empty");
|
2023-07-18 20:46:28 +00:00
|
|
|
if(model->menu) {
|
|
|
|
render_item_menu(canvas, model);
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
View* archive_browser_get_view(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
|
|
|
return browser->view;
|
|
|
|
}
|
|
|
|
|
2023-07-14 01:40:22 +00:00
|
|
|
static bool is_file_list_load_required(ArchiveBrowserViewModel* model) {
|
|
|
|
size_t array_size = files_array_size(model->files);
|
|
|
|
|
|
|
|
if((model->list_loading) || (array_size >= model->item_cnt)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((model->array_offset > 0) &&
|
|
|
|
(model->item_idx < (model->array_offset + FILE_LIST_BUF_LEN / 4))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(((model->array_offset + array_size) < model->item_cnt) &&
|
|
|
|
(model->item_idx > (int32_t)(model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) {
|
|
|
|
return true;
|
2022-04-06 17:44:06 +00:00
|
|
|
}
|
2023-07-14 01:40:22 +00:00
|
|
|
|
|
|
|
return false;
|
2022-04-06 17:44:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-16 17:28:15 +00:00
|
|
|
static inline void
|
|
|
|
archive_view_menu_input_processing(ArchiveBrowserView* browser, InputEvent* event) {
|
|
|
|
// only InputShort type
|
|
|
|
if(event->key == InputKeyUp || event->key == InputKeyDown) {
|
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
|
|
|
size_t size_menu = menu_array_size(model->context_menu);
|
|
|
|
if(event->key == InputKeyUp) {
|
|
|
|
model->menu_idx = ((model->menu_idx - 1) + size_menu) % size_menu;
|
|
|
|
} else if(event->key == InputKeyDown) {
|
|
|
|
model->menu_idx = (model->menu_idx + 1) % size_menu;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true);
|
|
|
|
} else if(event->key == InputKeyLeft || event->key == InputKeyRight) {
|
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
|
|
|
ArchiveFile_t* selected =
|
|
|
|
files_array_get(model->files, model->item_idx - model->array_offset);
|
|
|
|
|
|
|
|
if(selected->type != ArchiveFileTypeFolder &&
|
|
|
|
model->tab_idx != ArchiveTabFavorites) {
|
2023-07-18 20:46:28 +00:00
|
|
|
model->menu_file_manage = !model->menu_file_manage;
|
2023-07-16 17:28:15 +00:00
|
|
|
model->menu_idx = 0;
|
|
|
|
menu_array_reset(model->context_menu);
|
|
|
|
selected->fav =
|
|
|
|
archive_is_favorite("%s", furi_string_get_cstr(selected->path));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true);
|
|
|
|
} else if(event->key == InputKeyOk) {
|
|
|
|
uint32_t idx;
|
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
|
|
|
ArchiveContextMenuItem_t* current =
|
|
|
|
menu_array_get(model->context_menu, model->menu_idx);
|
|
|
|
idx = current->event;
|
|
|
|
},
|
|
|
|
false);
|
|
|
|
browser->callback(idx, browser->context);
|
|
|
|
} else if(event->key == InputKeyBack) {
|
|
|
|
browser->callback(ArchiveBrowserEventFileMenuClose, browser->context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
static bool archive_view_input(InputEvent* event, void* context) {
|
2021-09-21 10:56:33 +00:00
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
ArchiveBrowserView* browser = context;
|
|
|
|
|
|
|
|
bool in_menu;
|
2021-10-12 13:09:34 +00:00
|
|
|
bool move_fav_mode;
|
2023-02-13 04:57:44 +00:00
|
|
|
bool is_loading;
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
2021-09-21 10:56:33 +00:00
|
|
|
in_menu = model->menu;
|
2021-10-12 13:09:34 +00:00
|
|
|
move_fav_mode = model->move_fav;
|
2023-02-13 04:57:44 +00:00
|
|
|
is_loading = model->folder_loading || model->list_loading;
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
false);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2023-02-13 04:57:44 +00:00
|
|
|
if(is_loading) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
if(in_menu) {
|
2022-09-15 18:00:51 +00:00
|
|
|
if(event->type != InputTypeShort) {
|
|
|
|
return true; // RETURN
|
|
|
|
}
|
2023-07-16 17:28:15 +00:00
|
|
|
archive_view_menu_input_processing(browser, event);
|
2021-09-21 10:56:33 +00:00
|
|
|
} else {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyLeft || event->key == InputKeyRight) {
|
2021-10-12 13:09:34 +00:00
|
|
|
if(move_fav_mode) return false;
|
2023-07-18 20:46:28 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{ model->clipboard_mode = CLIPBOARD_MODE_OFF; },
|
|
|
|
false);
|
2021-09-21 10:56:33 +00:00
|
|
|
archive_switch_tab(browser, event->key);
|
2023-07-18 20:46:28 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
} else if(event->key == InputKeyBack) {
|
2021-10-12 13:09:34 +00:00
|
|
|
if(move_fav_mode) {
|
|
|
|
browser->callback(ArchiveBrowserEventExitFavMove, browser->context);
|
|
|
|
} else {
|
|
|
|
browser->callback(ArchiveBrowserEventExit, browser->context);
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-12 13:09:34 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if((event->key == InputKeyUp || event->key == InputKeyDown) &&
|
|
|
|
(event->type == InputTypeShort || event->type == InputTypeRepeat)) {
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
2023-06-27 09:22:35 +00:00
|
|
|
int32_t scroll_speed = 1;
|
|
|
|
if(model->button_held_for_ticks > 5) {
|
|
|
|
if(model->button_held_for_ticks % 2) {
|
|
|
|
scroll_speed = 0;
|
|
|
|
} else {
|
|
|
|
scroll_speed = model->button_held_for_ticks > 9 ? 4 : 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if(event->key == InputKeyUp) {
|
2023-06-27 09:22:35 +00:00
|
|
|
if(model->item_idx < scroll_speed) {
|
2023-06-28 11:46:42 +00:00
|
|
|
model->button_held_for_ticks = 0;
|
|
|
|
model->item_idx = model->item_cnt - 1;
|
|
|
|
} else {
|
|
|
|
model->item_idx =
|
|
|
|
((model->item_idx - scroll_speed) + model->item_cnt) %
|
|
|
|
model->item_cnt;
|
2023-06-27 09:22:35 +00:00
|
|
|
}
|
2023-07-14 01:40:22 +00:00
|
|
|
if(is_file_list_load_required(model)) {
|
2022-04-06 17:44:06 +00:00
|
|
|
model->list_loading = true;
|
|
|
|
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context);
|
|
|
|
}
|
|
|
|
if(move_fav_mode) {
|
|
|
|
browser->callback(ArchiveBrowserEventFavMoveUp, browser->context);
|
|
|
|
}
|
2022-12-20 11:11:52 +00:00
|
|
|
model->scroll_counter = 0;
|
2023-06-27 09:22:35 +00:00
|
|
|
model->button_held_for_ticks += 1;
|
2022-04-06 17:44:06 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2023-06-27 09:22:35 +00:00
|
|
|
int32_t count = model->item_cnt;
|
2023-06-28 11:46:42 +00:00
|
|
|
if(model->item_idx + scroll_speed >= count) {
|
|
|
|
model->button_held_for_ticks = 0;
|
|
|
|
model->item_idx = 0;
|
|
|
|
} else {
|
|
|
|
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
2023-06-27 09:22:35 +00:00
|
|
|
}
|
2023-07-14 01:40:22 +00:00
|
|
|
if(is_file_list_load_required(model)) {
|
2022-04-06 17:44:06 +00:00
|
|
|
model->list_loading = true;
|
|
|
|
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context);
|
|
|
|
}
|
|
|
|
if(move_fav_mode) {
|
|
|
|
browser->callback(ArchiveBrowserEventFavMoveDown, browser->context);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
2022-12-20 11:11:52 +00:00
|
|
|
model->scroll_counter = 0;
|
2023-06-27 09:22:35 +00:00
|
|
|
model->button_held_for_ticks += 1;
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
2023-02-12 11:16:12 +00:00
|
|
|
false);
|
2021-09-21 10:56:33 +00:00
|
|
|
archive_update_offset(browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyOk) {
|
|
|
|
ArchiveFile_t* selected = archive_get_current_file(browser);
|
|
|
|
|
|
|
|
if(selected) {
|
|
|
|
bool favorites = archive_get_tab(browser) == ArchiveTabFavorites;
|
|
|
|
bool folder = selected->type == ArchiveFileTypeFolder;
|
|
|
|
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(favorites) {
|
2021-10-12 13:09:34 +00:00
|
|
|
if(move_fav_mode) {
|
|
|
|
browser->callback(ArchiveBrowserEventSaveFavMove, browser->context);
|
|
|
|
} else {
|
|
|
|
browser->callback(ArchiveBrowserEventFileMenuRun, browser->context);
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
} else if(folder) {
|
|
|
|
browser->callback(ArchiveBrowserEventEnterDir, browser->context);
|
|
|
|
} else {
|
|
|
|
browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
|
|
|
|
}
|
|
|
|
} else if(event->type == InputTypeLong) {
|
2021-10-12 13:09:34 +00:00
|
|
|
if(move_fav_mode) {
|
|
|
|
browser->callback(ArchiveBrowserEventSaveFavMove, browser->context);
|
|
|
|
} else if(folder || favorites) {
|
2021-09-21 10:56:33 +00:00
|
|
|
browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
|
|
|
|
}
|
|
|
|
}
|
2023-07-18 20:46:28 +00:00
|
|
|
} else if(event->type == InputTypeLong) {
|
|
|
|
browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 09:22:35 +00:00
|
|
|
if(event->type == InputTypeRelease) {
|
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{ model->button_held_for_ticks = 0; },
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:11:52 +00:00
|
|
|
static void browser_scroll_timer(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
ArchiveBrowserView* browser = context;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, ArchiveBrowserViewModel * model, { model->scroll_counter++; }, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void browser_view_enter(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
ArchiveBrowserView* browser = context;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, ArchiveBrowserViewModel * model, { model->scroll_counter = 0; }, true);
|
|
|
|
furi_timer_start(browser->scroll_timer, SCROLL_INTERVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void browser_view_exit(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
ArchiveBrowserView* browser = context;
|
|
|
|
furi_timer_stop(browser->scroll_timer);
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveBrowserView* browser_alloc() {
|
2022-02-18 19:53:46 +00:00
|
|
|
ArchiveBrowserView* browser = malloc(sizeof(ArchiveBrowserView));
|
2021-09-21 10:56:33 +00:00
|
|
|
browser->view = view_alloc();
|
|
|
|
view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(ArchiveBrowserViewModel));
|
|
|
|
view_set_context(browser->view, browser);
|
2022-05-06 17:35:52 +00:00
|
|
|
view_set_draw_callback(browser->view, archive_view_render);
|
2021-09-21 10:56:33 +00:00
|
|
|
view_set_input_callback(browser->view, archive_view_input);
|
2022-12-20 11:11:52 +00:00
|
|
|
view_set_enter_callback(browser->view, browser_view_enter);
|
|
|
|
view_set_exit_callback(browser->view, browser_view_exit);
|
|
|
|
|
|
|
|
browser->scroll_timer = furi_timer_alloc(browser_scroll_timer, FuriTimerTypePeriodic, browser);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
browser->path = furi_string_alloc_set(archive_get_default_path(TAB_DEFAULT));
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
2021-09-21 10:56:33 +00:00
|
|
|
files_array_init(model->files);
|
2022-09-15 18:00:51 +00:00
|
|
|
menu_array_init(model->context_menu);
|
2022-06-09 07:09:52 +00:00
|
|
|
model->tab_idx = TAB_DEFAULT;
|
2023-07-18 20:46:28 +00:00
|
|
|
model->clipboard_mode = CLIPBOARD_MODE_OFF;
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
return browser;
|
|
|
|
}
|
|
|
|
|
|
|
|
void browser_free(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
2022-12-20 11:11:52 +00:00
|
|
|
furi_timer_free(browser->scroll_timer);
|
|
|
|
|
2022-08-22 16:19:03 +00:00
|
|
|
if(browser->worker_running) {
|
|
|
|
file_browser_worker_free(browser->worker);
|
|
|
|
}
|
2022-06-09 07:09:52 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
2022-10-08 21:37:22 +00:00
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{
|
2021-09-21 10:56:33 +00:00
|
|
|
files_array_clear(model->files);
|
2022-09-15 18:00:51 +00:00
|
|
|
menu_array_clear(model->context_menu);
|
2022-10-08 21:37:22 +00:00
|
|
|
},
|
|
|
|
false);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(browser->path);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
view_free(browser->view);
|
|
|
|
free(browser);
|
2023-07-18 20:46:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void archive_browser_clipboard_set_mode(ArchiveBrowserView* browser, uint8_t mode) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, ArchiveBrowserViewModel * model, { model->clipboard_mode = mode; }, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_browser_clipboard_reset(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view,
|
|
|
|
ArchiveBrowserViewModel * model,
|
|
|
|
{ model->clipboard_mode = CLIPBOARD_MODE_OFF; },
|
|
|
|
true);
|
2023-02-11 14:49:00 +00:00
|
|
|
}
|