[FL-3001] File browser base folder (#2091)

* File browser base folder
* Format sources
* FuriHal: bump api version

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov
2022-12-07 17:17:41 +03:00
committed by GitHub
parent 741ad34b2c
commit 2daf39018b
22 changed files with 38 additions and 9 deletions

View File

@@ -83,6 +83,7 @@ struct FileBrowser {
View* view;
BrowserWorker* worker;
const char* ext_filter;
const char* base_path;
bool skip_assets;
bool hide_dot_files;
bool hide_ext;
@@ -163,6 +164,7 @@ View* file_browser_get_view(FileBrowser* browser) {
void file_browser_configure(
FileBrowser* browser,
const char* extension,
const char* base_path,
bool skip_assets,
bool hide_dot_files,
const Icon* file_icon,
@@ -172,6 +174,7 @@ void file_browser_configure(
browser->ext_filter = extension;
browser->skip_assets = skip_assets;
browser->hide_ext = hide_ext;
browser->base_path = base_path;
browser->hide_dot_files = hide_dot_files;
with_view_model(
@@ -187,7 +190,11 @@ void file_browser_configure(
void file_browser_start(FileBrowser* browser, FuriString* path) {
furi_assert(browser);
browser->worker = file_browser_worker_alloc(
path, browser->ext_filter, browser->skip_assets, browser->hide_dot_files);
path,
browser->base_path,
browser->ext_filter,
browser->skip_assets,
browser->hide_dot_files);
file_browser_worker_set_callback_context(browser->worker, browser);
file_browser_worker_set_folder_callback(browser->worker, browser_folder_open_cb);
file_browser_worker_set_list_callback(browser->worker, browser_list_load_cb);

View File

@@ -29,6 +29,7 @@ View* file_browser_get_view(FileBrowser* browser);
void file_browser_configure(
FileBrowser* browser,
const char* extension,
const char* base_path,
bool skip_assets,
bool hide_dot_files,
const Icon* file_icon,

View File

@@ -371,6 +371,7 @@ static int32_t browser_worker(void* context) {
BrowserWorker* file_browser_worker_alloc(
FuriString* path,
const char* base_path,
const char* filter_ext,
bool skip_assets,
bool hide_dot_files) {
@@ -381,12 +382,13 @@ BrowserWorker* file_browser_worker_alloc(
browser->filter_extension = furi_string_alloc_set(filter_ext);
browser->skip_assets = skip_assets;
browser->hide_dot_files = hide_dot_files;
browser->path_start = furi_string_alloc_set(path);
browser->path_current = furi_string_alloc_set(path);
browser->path_next = furi_string_alloc_set(path);
if(browser_path_is_file(browser->path_start)) {
browser_path_trim(browser->path_start);
browser->path_start = furi_string_alloc();
if(base_path) {
furi_string_set_str(browser->path_start, base_path);
}
browser->thread = furi_thread_alloc_ex("BrowserWorker", 2048, browser_worker, browser);

View File

@@ -23,6 +23,7 @@ typedef void (*BrowserWorkerLongLoadCallback)(void* context);
BrowserWorker* file_browser_worker_alloc(
FuriString* path,
const char* base_path,
const char* filter_ext,
bool skip_assets,
bool hide_dot_files);