mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-15 04:19:26 -07:00
Merge pull request #389 from Dig03/file-browser-ordering
File browser ordering
This commit is contained in:
@@ -64,7 +64,13 @@ static void
|
|||||||
archive_add_file_item(browser, is_folder, furi_string_get_cstr(item_path));
|
archive_add_file_item(browser, is_folder, furi_string_get_cstr(item_path));
|
||||||
} else {
|
} else {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
browser->view, ArchiveBrowserViewModel * model, { model->list_loading = false; }, true);
|
browser->view,
|
||||||
|
ArchiveBrowserViewModel * model,
|
||||||
|
{
|
||||||
|
files_array_sort(model->files);
|
||||||
|
model->list_loading = false;
|
||||||
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <m-array.h>
|
#include <m-array.h>
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
|
#include <m-algo.h>
|
||||||
|
#include <m-string.h>
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
#include "toolbox/path.h"
|
#include "toolbox/path.h"
|
||||||
|
|
||||||
@@ -81,13 +83,26 @@ static void ArchiveFile_t_clear(ArchiveFile_t* obj) {
|
|||||||
furi_string_free(obj->custom_name);
|
furi_string_free(obj->custom_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARRAY_DEF(
|
static int ArchiveFile_t_cmp(const ArchiveFile_t* a, const ArchiveFile_t* b) {
|
||||||
files_array,
|
if(a->type == ArchiveFileTypeFolder && b->type != ArchiveFileTypeFolder) {
|
||||||
ArchiveFile_t,
|
return -1;
|
||||||
(INIT(API_2(ArchiveFile_t_init)),
|
}
|
||||||
SET(API_6(ArchiveFile_t_set)),
|
|
||||||
INIT_SET(API_6(ArchiveFile_t_init_set)),
|
return furi_string_cmp(a->path, b->path);
|
||||||
CLEAR(API_2(ArchiveFile_t_clear))))
|
}
|
||||||
|
|
||||||
|
#define M_OPL_ArchiveFile_t() \
|
||||||
|
(INIT(API_2(ArchiveFile_t_init)), \
|
||||||
|
SET(API_6(ArchiveFile_t_set)), \
|
||||||
|
INIT_SET(API_6(ArchiveFile_t_init_set)), \
|
||||||
|
CLEAR(API_2(ArchiveFile_t_clear)), \
|
||||||
|
CMP(API_6(ArchiveFile_t_cmp)), \
|
||||||
|
SWAP(M_SWAP_DEFAULT), \
|
||||||
|
EQUAL(API_6(M_EQUAL_DEFAULT)))
|
||||||
|
|
||||||
|
ARRAY_DEF(files_array, ArchiveFile_t)
|
||||||
|
|
||||||
|
ALGO_DEF(files_array, ARRAY_OPLIST(files_array, M_OPL_ArchiveFile_t()))
|
||||||
|
|
||||||
void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder, bool is_app);
|
void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder, bool is_app);
|
||||||
bool archive_get_items(void* context, const char* path);
|
bool archive_get_items(void* context, const char* path);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <core/common_defines.h>
|
#include <core/common_defines.h>
|
||||||
#include <core/log.h>
|
#include <core/log.h>
|
||||||
#include "furi_hal_resources.h"
|
#include "furi_hal_resources.h"
|
||||||
|
#include "m-string.h"
|
||||||
|
#include "m-algo.h"
|
||||||
#include <m-array.h>
|
#include <m-array.h>
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
@@ -71,13 +73,29 @@ static void BrowserItem_t_clear(BrowserItem_t* obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ARRAY_DEF(
|
static int BrowserItem_t_cmp(const BrowserItem_t* a, const BrowserItem_t* b) {
|
||||||
items_array,
|
// Back indicator comes before everything, then folders, then all other files.
|
||||||
BrowserItem_t,
|
if((a->type == BrowserItemTypeBack) ||
|
||||||
(INIT(API_2(BrowserItem_t_init)),
|
(a->type == BrowserItemTypeFolder && b->type != BrowserItemTypeFolder &&
|
||||||
SET(API_6(BrowserItem_t_set)),
|
b->type != BrowserItemTypeBack)) {
|
||||||
INIT_SET(API_6(BrowserItem_t_init_set)),
|
return -1;
|
||||||
CLEAR(API_2(BrowserItem_t_clear))))
|
}
|
||||||
|
|
||||||
|
return furi_string_cmp(a->path, b->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define M_OPL_BrowserItem_t() \
|
||||||
|
(INIT(API_2(BrowserItem_t_init)), \
|
||||||
|
SET(API_6(BrowserItem_t_set)), \
|
||||||
|
INIT_SET(API_6(BrowserItem_t_init_set)), \
|
||||||
|
CLEAR(API_2(BrowserItem_t_clear)), \
|
||||||
|
CMP(API_6(BrowserItem_t_cmp)), \
|
||||||
|
SWAP(M_SWAP_DEFAULT), \
|
||||||
|
EQUAL(API_6(M_EQUAL_DEFAULT)))
|
||||||
|
|
||||||
|
ARRAY_DEF(items_array, BrowserItem_t)
|
||||||
|
|
||||||
|
ALGO_DEF(items_array, ARRAY_OPLIST(items_array, M_OPL_BrowserItem_t()))
|
||||||
|
|
||||||
struct FileBrowser {
|
struct FileBrowser {
|
||||||
View* view;
|
View* view;
|
||||||
@@ -388,7 +406,13 @@ static void
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
with_view_model(
|
with_view_model(
|
||||||
browser->view, FileBrowserModel * model, { model->list_loading = false; }, true);
|
browser->view,
|
||||||
|
FileBrowserModel * model,
|
||||||
|
{
|
||||||
|
items_array_sort(model->items);
|
||||||
|
model->list_loading = false;
|
||||||
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user