2021-09-21 13:56:33 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../archive_i.h"
|
2022-07-26 15:21:51 +03:00
|
|
|
#include <storage/storage.h>
|
2021-09-21 13:56:33 +03:00
|
|
|
|
2024-07-15 07:38:49 +03:00
|
|
|
#define TAB_RIGHT InputKeyRight // Default tab switch direction
|
|
|
|
#define TAB_DEFAULT ArchiveTabFavorites // Start tab
|
2022-11-29 03:59:24 +09:00
|
|
|
#define FILE_LIST_BUF_LEN 50
|
2021-09-21 13:56:33 +03:00
|
|
|
|
|
|
|
static const char* tab_default_paths[] = {
|
2022-06-09 10:09:52 +03:00
|
|
|
[ArchiveTabFavorites] = "/app:favorites",
|
2024-08-04 18:54:02 +09:00
|
|
|
[ArchiveTabIButton] = EXT_PATH("ibutton"),
|
|
|
|
[ArchiveTabNFC] = EXT_PATH("nfc"),
|
|
|
|
[ArchiveTabSubGhz] = EXT_PATH("subghz"),
|
|
|
|
[ArchiveTabLFRFID] = EXT_PATH("lfrfid"),
|
|
|
|
[ArchiveTabInfrared] = EXT_PATH("infrared"),
|
|
|
|
[ArchiveTabBadUsb] = EXT_PATH("badusb"),
|
2022-02-10 16:01:49 +03:00
|
|
|
[ArchiveTabU2f] = "/app:u2f",
|
2024-08-04 18:54:02 +09:00
|
|
|
[ArchiveTabApplications] = EXT_PATH("apps"),
|
|
|
|
[ArchiveTabBrowser] = STORAGE_EXT_PATH_PREFIX,
|
2021-09-21 13:56:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* known_ext[] = {
|
|
|
|
[ArchiveFileTypeIButton] = ".ibtn",
|
|
|
|
[ArchiveFileTypeNFC] = ".nfc",
|
|
|
|
[ArchiveFileTypeSubGhz] = ".sub",
|
|
|
|
[ArchiveFileTypeLFRFID] = ".rfid",
|
2022-02-25 19:22:58 +04:00
|
|
|
[ArchiveFileTypeInfrared] = ".ir",
|
2022-02-10 16:01:49 +03:00
|
|
|
[ArchiveFileTypeBadUsb] = ".txt",
|
|
|
|
[ArchiveFileTypeU2f] = "?",
|
2022-10-06 20:37:53 +05:00
|
|
|
[ArchiveFileTypeApplication] = ".fap",
|
[FL-3579, FL-3601, FL-3714] JavaScript runner (#3286)
* FBT: cdefines to env, libs order
* API: strtod, modf, itoa, calloc
* Apps: elk js
* Apps: mjs
* JS: scripts as assets
* mjs: composite resolver
* mjs: stack trace
* ELK JS example removed
* MJS thread, MJS lib modified to support script interruption
* JS console UI
* Module system, BadUSB bindings rework
* JS notifications, simple dialog, BadUSB demo
* Custom dialogs, dialog demo
* MJS as system library, some dirty hacks to make it compile
* Plugin-based js modules
* js_uart(BadUART) module
* js_uart: support for byte array arguments
* Script icon and various fixes
* File browser: multiple extensions filter, running js scripts from app loader
* Running js scripts from archive browser
* JS Runner as system app
* Example scripts moved to /ext/apps/Scripts
* JS bytecode listing generation
* MJS builtin printf cleanup
* JS examples cleanup
* mbedtls version fix
* Unused lib cleanup
* Making PVS happy & TODOs cleanup
* TODOs cleanup #2
* MJS: initial typed arrays support
* JS: fix mem leak in uart destructor
Co-authored-by: SG <who.just.the.doctor@gmail.com>
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2024-02-12 11:54:32 +03:00
|
|
|
[ArchiveFileTypeJS] = ".js",
|
2022-04-13 23:50:25 +03:00
|
|
|
[ArchiveFileTypeUpdateManifest] = ".fuf",
|
2022-02-10 16:01:49 +03:00
|
|
|
[ArchiveFileTypeFolder] = "?",
|
|
|
|
[ArchiveFileTypeUnknown] = "*",
|
2024-02-15 06:53:34 +03:00
|
|
|
[ArchiveFileTypeAppOrJs] = ".fap|.js",
|
2021-09-21 13:56:33 +03:00
|
|
|
};
|
|
|
|
|
2022-02-10 16:01:49 +03:00
|
|
|
static const ArchiveFileTypeEnum known_type[] = {
|
|
|
|
[ArchiveTabFavorites] = ArchiveFileTypeUnknown,
|
|
|
|
[ArchiveTabIButton] = ArchiveFileTypeIButton,
|
|
|
|
[ArchiveTabNFC] = ArchiveFileTypeNFC,
|
|
|
|
[ArchiveTabSubGhz] = ArchiveFileTypeSubGhz,
|
|
|
|
[ArchiveTabLFRFID] = ArchiveFileTypeLFRFID,
|
2022-02-25 19:22:58 +04:00
|
|
|
[ArchiveTabInfrared] = ArchiveFileTypeInfrared,
|
2022-02-10 16:01:49 +03:00
|
|
|
[ArchiveTabBadUsb] = ArchiveFileTypeBadUsb,
|
|
|
|
[ArchiveTabU2f] = ArchiveFileTypeU2f,
|
2024-02-15 06:53:34 +03:00
|
|
|
[ArchiveTabApplications] = ArchiveFileTypeAppOrJs,
|
2022-02-10 16:01:49 +03:00
|
|
|
[ArchiveTabBrowser] = ArchiveFileTypeUnknown,
|
|
|
|
};
|
|
|
|
|
2022-05-06 16:37:10 +03:00
|
|
|
static inline ArchiveFileTypeEnum archive_get_tab_filetype(ArchiveTabEnum tab) {
|
2022-02-10 16:01:49 +03:00
|
|
|
return known_type[tab];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const char* archive_get_tab_ext(ArchiveTabEnum tab) {
|
|
|
|
return known_ext[archive_get_tab_filetype(tab)];
|
2021-09-21 13:56:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline const char* archive_get_default_path(ArchiveTabEnum tab) {
|
|
|
|
return tab_default_paths[tab];
|
|
|
|
}
|
|
|
|
|
2022-02-10 16:01:49 +03:00
|
|
|
inline bool archive_is_known_app(ArchiveFileTypeEnum type) {
|
2024-07-15 07:38:49 +03:00
|
|
|
return type != ArchiveFileTypeFolder && type != ArchiveFileTypeUnknown;
|
2021-09-21 13:56:33 +03:00
|
|
|
}
|
|
|
|
|
2022-04-06 20:44:06 +03:00
|
|
|
bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx);
|
2023-07-12 19:35:11 +03:00
|
|
|
bool archive_is_file_list_load_required(ArchiveBrowserViewModel* model);
|
2021-09-21 13:56:33 +03:00
|
|
|
void archive_update_offset(ArchiveBrowserView* browser);
|
|
|
|
void archive_update_focus(ArchiveBrowserView* browser, const char* target);
|
|
|
|
|
2022-06-09 10:09:52 +03:00
|
|
|
void archive_file_array_load(ArchiveBrowserView* browser, int8_t dir);
|
2022-04-06 20:44:06 +03:00
|
|
|
size_t archive_file_get_array_size(ArchiveBrowserView* browser);
|
2021-09-21 13:56:33 +03:00
|
|
|
void archive_file_array_rm_selected(ArchiveBrowserView* browser);
|
2022-04-06 20:44:06 +03:00
|
|
|
void archive_file_array_swap(ArchiveBrowserView* browser, int8_t dir);
|
2021-09-21 13:56:33 +03:00
|
|
|
void archive_file_array_rm_all(ArchiveBrowserView* browser);
|
|
|
|
|
2022-04-06 20:44:06 +03:00
|
|
|
void archive_set_item_count(ArchiveBrowserView* browser, uint32_t count);
|
|
|
|
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser);
|
2021-10-12 16:09:34 +03:00
|
|
|
ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx);
|
2021-09-21 13:56:33 +03:00
|
|
|
ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser);
|
2022-06-09 10:09:52 +03:00
|
|
|
bool archive_is_home(ArchiveBrowserView* browser);
|
2021-09-21 13:56:33 +03:00
|
|
|
const char* archive_get_name(ArchiveBrowserView* browser);
|
|
|
|
|
2022-02-10 16:01:49 +03:00
|
|
|
void archive_add_app_item(ArchiveBrowserView* browser, const char* name);
|
2022-06-09 10:09:52 +03:00
|
|
|
void archive_add_file_item(ArchiveBrowserView* browser, bool is_folder, const char* name);
|
2021-09-21 13:56:33 +03:00
|
|
|
void archive_show_file_menu(ArchiveBrowserView* browser, bool show);
|
2021-10-12 16:09:34 +03:00
|
|
|
void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active);
|
2021-09-21 13:56:33 +03:00
|
|
|
|
|
|
|
void archive_switch_tab(ArchiveBrowserView* browser, InputKey key);
|
2022-10-06 01:15:23 +10:00
|
|
|
void archive_enter_dir(ArchiveBrowserView* browser, FuriString* name);
|
2021-09-21 13:56:33 +03:00
|
|
|
void archive_leave_dir(ArchiveBrowserView* browser);
|
2022-06-09 10:09:52 +03:00
|
|
|
void archive_refresh_dir(ArchiveBrowserView* browser);
|