Archive: fix delete from favorites tab (#752)
* archive_delete_file vargs, fix wrong path when deleting item from favorites tab * use string_t for archive vargs funcs * favorites manual sorting Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -76,6 +76,23 @@ void archive_file_array_rm_selected(ArchiveBrowserView* browser) {
|
||||
archive_update_offset(browser);
|
||||
}
|
||||
|
||||
void archive_file_array_swap(ArchiveBrowserView* browser, int8_t d) {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
size_t array_size = files_array_size(model->files) - 1;
|
||||
uint8_t swap_idx = CLAMP(model->idx + d, array_size, 0);
|
||||
|
||||
if(model->idx == 0 && d < 0) {
|
||||
swap_idx = array_size;
|
||||
} else if(model->idx == array_size && d > 0) {
|
||||
swap_idx = 0;
|
||||
}
|
||||
|
||||
files_array_swap_at(model->files, model->idx, swap_idx);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
void archive_file_array_rm_all(ArchiveBrowserView* browser) {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
@@ -95,6 +112,18 @@ ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) {
|
||||
return selected;
|
||||
}
|
||||
|
||||
ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
|
||||
ArchiveFile_t* selected;
|
||||
idx = CLAMP(idx, archive_file_array_size(browser), 0);
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
selected = files_array_size(model->files) ? files_array_get(model->files, idx) : NULL;
|
||||
return false;
|
||||
});
|
||||
return selected;
|
||||
}
|
||||
|
||||
ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) {
|
||||
ArchiveTabEnum tab_id;
|
||||
with_view_model(
|
||||
@@ -179,6 +208,14 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
|
||||
});
|
||||
}
|
||||
|
||||
void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
model->move_fav = active;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void archive_switch_dir(ArchiveBrowserView* browser, const char* path) {
|
||||
furi_assert(browser);
|
||||
furi_assert(path);
|
||||
|
Reference in New Issue
Block a user