2022-02-10 13:01:49 +00:00
|
|
|
#include "archive_files.h"
|
|
|
|
#include "archive_apps.h"
|
2021-09-21 10:56:33 +00:00
|
|
|
#include "archive_browser.h"
|
2022-02-10 13:01:49 +00:00
|
|
|
#include <math.h>
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx) {
|
|
|
|
size_t array_size = files_array_size(model->files);
|
|
|
|
|
2022-05-06 13:37:10 +00:00
|
|
|
if((idx >= (uint32_t)model->array_offset + array_size) ||
|
|
|
|
(idx < (uint32_t)model->array_offset)) {
|
2022-04-06 17:44:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
void archive_update_offset(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
2022-04-06 17:44:06 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-04-06 17:44:06 +00:00
|
|
|
uint16_t bounds = model->item_cnt > 3 ? 2 : model->item_cnt;
|
|
|
|
|
2022-05-06 16:26:25 +00:00
|
|
|
if((model->item_cnt > 3u) && (model->item_idx >= ((int32_t)model->item_cnt - 1))) {
|
2022-04-06 17:44:06 +00:00
|
|
|
model->list_offset = model->item_idx - 3;
|
|
|
|
} else if(model->list_offset < model->item_idx - bounds) {
|
2022-05-06 13:37:10 +00:00
|
|
|
model->list_offset =
|
2022-05-06 16:26:25 +00:00
|
|
|
CLAMP(model->item_idx - 2, (int32_t)model->item_cnt - bounds, 0);
|
2022-04-06 17:44:06 +00:00
|
|
|
} else if(model->list_offset > model->item_idx - bounds) {
|
2022-05-06 13:37:10 +00:00
|
|
|
model->list_offset =
|
2022-05-06 16:26:25 +00:00
|
|
|
CLAMP(model->item_idx - 1, (int32_t)model->item_cnt - bounds, 0);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
2022-04-06 17:44:06 +00:00
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_update_focus(ArchiveBrowserView* browser, const char* target) {
|
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(target);
|
|
|
|
|
|
|
|
archive_get_filenames(browser, string_get_cstr(browser->path));
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if(!archive_file_get_array_size(browser) && !archive_get_depth(browser)) {
|
|
|
|
archive_switch_tab(browser, TAB_RIGHT);
|
2021-09-21 10:56:33 +00:00
|
|
|
} else {
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
uint16_t idx = 0;
|
|
|
|
while(idx < files_array_size(model->files)) {
|
|
|
|
ArchiveFile_t* current = files_array_get(model->files, idx);
|
|
|
|
if(!string_search(current->name, target)) {
|
2022-04-06 17:44:06 +00:00
|
|
|
model->item_idx = idx + model->array_offset;
|
2021-09-21 10:56:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
archive_update_offset(browser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
size_t archive_file_get_array_size(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
uint16_t size = 0;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
size = files_array_size(model->files);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
void archive_set_item_count(ArchiveBrowserView* browser, uint32_t count) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
model->item_cnt = count;
|
2022-05-06 16:26:25 +00:00
|
|
|
model->item_idx = CLAMP(model->item_idx, (int32_t)model->item_cnt - 1, 0);
|
2022-04-06 17:44:06 +00:00
|
|
|
return false;
|
|
|
|
});
|
2022-05-04 22:51:45 +00:00
|
|
|
archive_update_offset(browser);
|
2022-04-06 17:44:06 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
void archive_file_array_rm_selected(ArchiveBrowserView* browser) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
uint32_t items_cnt = 0;
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-04-06 17:44:06 +00:00
|
|
|
files_array_remove_v(
|
|
|
|
model->files,
|
|
|
|
model->item_idx - model->array_offset,
|
|
|
|
model->item_idx - model->array_offset + 1);
|
|
|
|
model->item_cnt--;
|
2022-05-06 16:26:25 +00:00
|
|
|
model->item_idx = CLAMP(model->item_idx, (int32_t)model->item_cnt - 1, 0);
|
2022-04-06 17:44:06 +00:00
|
|
|
items_cnt = model->item_cnt;
|
2021-09-21 10:56:33 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if((items_cnt == 0) && (archive_get_depth(browser) == 0)) {
|
|
|
|
archive_switch_tab(browser, TAB_RIGHT);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
archive_update_offset(browser);
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
void archive_file_array_swap(ArchiveBrowserView* browser, int8_t dir) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2021-10-13 09:53:58 +00:00
|
|
|
ArchiveFile_t temp;
|
2021-10-12 13:09:34 +00:00
|
|
|
size_t array_size = files_array_size(model->files) - 1;
|
2022-05-06 13:37:10 +00:00
|
|
|
uint8_t swap_idx = CLAMP((size_t)(model->item_idx + dir), array_size, 0u);
|
2021-10-12 13:09:34 +00:00
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if(model->item_idx == 0 && dir < 0) {
|
2021-10-13 09:53:58 +00:00
|
|
|
ArchiveFile_t_init(&temp);
|
|
|
|
files_array_pop_at(&temp, model->files, array_size);
|
2022-04-06 17:44:06 +00:00
|
|
|
files_array_push_at(model->files, model->item_idx, temp);
|
2021-10-13 09:53:58 +00:00
|
|
|
ArchiveFile_t_clear(&temp);
|
2022-05-06 13:37:10 +00:00
|
|
|
} else if(((uint32_t)model->item_idx == array_size) && (dir > 0)) {
|
2021-10-13 09:53:58 +00:00
|
|
|
ArchiveFile_t_init(&temp);
|
2022-04-14 17:02:16 +00:00
|
|
|
files_array_pop_at(&temp, model->files, 0);
|
2021-10-13 09:53:58 +00:00
|
|
|
files_array_push_at(model->files, array_size, temp);
|
|
|
|
ArchiveFile_t_clear(&temp);
|
|
|
|
} else {
|
2022-04-06 17:44:06 +00:00
|
|
|
files_array_swap_at(model->files, model->item_idx, swap_idx);
|
2021-10-12 13:09:34 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
void archive_file_array_rm_all(ArchiveBrowserView* browser) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2021-11-15 17:09:40 +00:00
|
|
|
files_array_reset(model->files);
|
2021-09-21 10:56:33 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
bool archive_file_array_load(ArchiveBrowserView* browser, int8_t dir) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
|
|
|
int32_t offset_new = 0;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
if(model->item_cnt > FILE_LIST_BUF_LEN) {
|
|
|
|
if(dir < 0) {
|
|
|
|
offset_new = model->item_idx - FILE_LIST_BUF_LEN / 4 * 3;
|
|
|
|
} else if(dir == 0) {
|
|
|
|
offset_new = model->item_idx - FILE_LIST_BUF_LEN / 4 * 2;
|
|
|
|
} else {
|
|
|
|
offset_new = model->item_idx - FILE_LIST_BUF_LEN / 4 * 1;
|
|
|
|
}
|
2022-05-06 16:26:25 +00:00
|
|
|
offset_new = CLAMP(offset_new, (int32_t)model->item_cnt - FILE_LIST_BUF_LEN, 0);
|
2022-04-06 17:44:06 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
bool res = archive_dir_read_items(
|
|
|
|
browser, string_get_cstr(browser->path), offset_new, FILE_LIST_BUF_LEN);
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
model->array_offset = offset_new;
|
|
|
|
model->list_loading = false;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveFile_t* selected;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-04-06 17:44:06 +00:00
|
|
|
selected = files_array_size(model->files) ?
|
|
|
|
files_array_get(model->files, model->item_idx - model->array_offset) :
|
|
|
|
NULL;
|
2021-09-21 10:56:33 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return selected;
|
|
|
|
}
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
ArchiveFile_t* selected;
|
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-05-06 13:37:10 +00:00
|
|
|
idx = CLAMP(idx - model->array_offset, files_array_size(model->files), 0u);
|
2021-10-12 13:09:34 +00:00
|
|
|
selected = files_array_size(model->files) ? files_array_get(model->files, idx) : NULL;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return selected;
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveTabEnum tab_id;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
tab_id = model->tab_idx;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return tab_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t archive_get_depth(ArchiveBrowserView* browser) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
uint8_t depth;
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-04-06 17:44:06 +00:00
|
|
|
depth = idx_last_array_size(model->idx_last);
|
2021-09-21 10:56:33 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* archive_get_path(ArchiveBrowserView* browser) {
|
|
|
|
return string_get_cstr(browser->path);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* archive_get_name(ArchiveBrowserView* browser) {
|
|
|
|
ArchiveFile_t* selected = archive_get_current_file(browser);
|
|
|
|
return string_get_cstr(selected->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_set_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
model->tab_idx = tab;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
void archive_set_last_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
2022-05-06 13:37:10 +00:00
|
|
|
UNUSED(tab); // FIXME?
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
model->last_tab = model->tab_idx;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-10 13:01:49 +00:00
|
|
|
void archive_add_app_item(ArchiveBrowserView* browser, const char* name) {
|
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(name);
|
|
|
|
|
|
|
|
ArchiveFile_t item;
|
|
|
|
|
|
|
|
string_t full_name;
|
|
|
|
|
|
|
|
string_init_set(full_name, browser->path);
|
|
|
|
string_cat_printf(full_name, "/%s", name);
|
|
|
|
|
|
|
|
char* app_name = strchr(string_get_cstr(full_name), ':');
|
|
|
|
if(app_name == NULL) {
|
|
|
|
string_clear(full_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArchiveFile_t_init(&item);
|
|
|
|
string_init_set_str(item.name, name);
|
2022-04-06 17:44:06 +00:00
|
|
|
archive_set_file_type(&item, NULL, app_name + 1, true);
|
2022-02-10 13:01:49 +00:00
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
files_array_push_back(model->files, item);
|
2022-04-06 17:44:06 +00:00
|
|
|
model->item_cnt = files_array_size(model->files);
|
2022-02-10 13:01:49 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
ArchiveFile_t_clear(&item);
|
|
|
|
string_clear(full_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_add_file_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name) {
|
2021-09-21 10:56:33 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(file_info);
|
|
|
|
furi_assert(name);
|
|
|
|
|
|
|
|
ArchiveFile_t item;
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
if(archive_filter_by_extension(
|
|
|
|
file_info, archive_get_tab_ext(archive_get_tab(browser)), name)) {
|
2021-09-21 10:56:33 +00:00
|
|
|
ArchiveFile_t_init(&item);
|
|
|
|
string_init_set_str(item.name, name);
|
2022-04-06 17:44:06 +00:00
|
|
|
archive_set_file_type(&item, file_info, archive_get_path(browser), false);
|
2021-09-21 10:56:33 +00:00
|
|
|
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
files_array_push_back(model->files, item);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
ArchiveFile_t_clear(&item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
|
|
|
|
furi_assert(browser);
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
if(show) {
|
2022-04-06 17:44:06 +00:00
|
|
|
if(archive_is_item_in_array(model, model->item_idx)) {
|
|
|
|
model->menu = true;
|
|
|
|
model->menu_idx = 0;
|
|
|
|
ArchiveFile_t* selected =
|
|
|
|
files_array_get(model->files, model->item_idx - model->array_offset);
|
|
|
|
selected->fav = archive_is_favorite("%s", string_get_cstr(selected->name));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model->menu = false;
|
|
|
|
model->menu_idx = 0;
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) {
|
2022-04-06 17:44:06 +00:00
|
|
|
furi_assert(browser);
|
|
|
|
|
2021-10-12 13:09:34 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
model->move_fav = active;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
void archive_switch_dir(ArchiveBrowserView* browser, const char* path) {
|
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(path);
|
|
|
|
|
|
|
|
string_set(browser->path, path);
|
|
|
|
archive_get_filenames(browser, string_get_cstr(browser->path));
|
|
|
|
archive_update_offset(browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
|
|
|
|
furi_assert(browser);
|
|
|
|
ArchiveTabEnum tab = archive_get_tab(browser);
|
|
|
|
|
|
|
|
if(key == InputKeyLeft) {
|
|
|
|
tab = ((tab - 1) + ArchiveTabTotal) % ArchiveTabTotal;
|
|
|
|
} else if(key == InputKeyRight) {
|
|
|
|
tab = (tab + 1) % ArchiveTabTotal;
|
|
|
|
}
|
|
|
|
|
|
|
|
archive_set_tab(browser, tab);
|
|
|
|
|
2022-02-10 13:01:49 +00:00
|
|
|
const char* path = archive_get_default_path(tab);
|
|
|
|
bool tab_empty = true;
|
|
|
|
if(tab == ArchiveTabFavorites) {
|
|
|
|
if(archive_favorites_count(browser) > 0) tab_empty = false;
|
|
|
|
} else if(strncmp(path, "/app:", 5) == 0) {
|
|
|
|
if(archive_app_is_available(browser, path)) tab_empty = false;
|
|
|
|
} else {
|
2022-04-06 17:44:06 +00:00
|
|
|
uint32_t files_cnt = archive_dir_count_items(browser, archive_get_default_path(tab));
|
|
|
|
if(files_cnt > 0) tab_empty = false;
|
2022-02-10 13:01:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((tab_empty) && (tab != ArchiveTabBrowser)) {
|
|
|
|
archive_switch_tab(browser, key);
|
2021-09-21 10:56:33 +00:00
|
|
|
} else {
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
if(model->last_tab != model->tab_idx) {
|
2022-04-06 17:44:06 +00:00
|
|
|
model->item_idx = 0;
|
|
|
|
model->array_offset = 0;
|
|
|
|
idx_last_array_reset(model->idx_last);
|
2021-09-21 10:56:33 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
archive_switch_dir(browser, archive_get_default_path(tab));
|
|
|
|
}
|
|
|
|
archive_set_last_tab(browser, tab);
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_enter_dir(ArchiveBrowserView* browser, string_t name) {
|
|
|
|
furi_assert(browser);
|
|
|
|
furi_assert(name);
|
2021-09-24 12:03:04 +00:00
|
|
|
|
2022-04-21 12:33:03 +00:00
|
|
|
if(string_size(name) >= (MAX_NAME_LEN - 1)) {
|
2022-04-14 11:28:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-27 16:34:37 +00:00
|
|
|
if(string_cmp(browser->path, name) != 0) {
|
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
|
|
|
idx_last_array_push_back(model->idx_last, model->item_idx);
|
|
|
|
model->array_offset = 0;
|
|
|
|
model->item_idx = 0;
|
|
|
|
return false;
|
|
|
|
});
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-04-27 16:34:37 +00:00
|
|
|
string_set(browser->path, name);
|
|
|
|
}
|
2021-09-21 10:56:33 +00:00
|
|
|
|
2022-05-04 22:51:45 +00:00
|
|
|
archive_dir_count_items(browser, string_get_cstr(name));
|
2021-09-21 10:56:33 +00:00
|
|
|
archive_switch_dir(browser, string_get_cstr(browser->path));
|
|
|
|
}
|
|
|
|
|
|
|
|
void archive_leave_dir(ArchiveBrowserView* browser) {
|
|
|
|
furi_assert(browser);
|
|
|
|
|
|
|
|
const char* path = archive_get_path(browser);
|
|
|
|
char* last_char_ptr = strrchr(path, '/');
|
|
|
|
|
|
|
|
if(last_char_ptr) {
|
|
|
|
size_t pos = last_char_ptr - path;
|
|
|
|
string_left(browser->path, pos);
|
|
|
|
}
|
|
|
|
|
2022-04-06 17:44:06 +00:00
|
|
|
archive_dir_count_items(browser, path);
|
|
|
|
|
2021-09-21 10:56:33 +00:00
|
|
|
with_view_model(
|
|
|
|
browser->view, (ArchiveBrowserViewModel * model) {
|
2022-04-06 17:44:06 +00:00
|
|
|
idx_last_array_pop_back(&model->item_idx, model->idx_last);
|
2021-09-21 10:56:33 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
archive_switch_dir(browser, path);
|
|
|
|
}
|