mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2025-10-10 15:12:41 +02:00
Archive: Add item count to directory info scene (#378)
* GUI: Add item count to Archive info scene * Update changelog --------- Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
- OFW: BadKB: Mouse control (by @jetrp1)
|
- OFW: BadKB: Mouse control (by @jetrp1)
|
||||||
- OFW: Infrared: Universal IR signal selection (by @portasynthinca3)
|
- OFW: Infrared: Universal IR signal selection (by @portasynthinca3)
|
||||||
- OFW: NFC: Disney Infinity KDF plugin (by @bettse)
|
- OFW: NFC: Disney Infinity KDF plugin (by @bettse)
|
||||||
|
- Archive: Add item count to directory info scene (#378 by @956MB)
|
||||||
- UL: Input: Vibro on Button press option (by @Dmitry422)
|
- UL: Input: Vibro on Button press option (by @Dmitry422)
|
||||||
- Desktop:
|
- Desktop:
|
||||||
- UL: Option to prevent Auto Lock when connected to USB/RPC (by @Dmitry422)
|
- UL: Option to prevent Auto Lock when connected to USB/RPC (by @Dmitry422)
|
||||||
|
@@ -43,7 +43,8 @@ struct ArchiveApp {
|
|||||||
char text_store[MAX_NAME_LEN];
|
char text_store[MAX_NAME_LEN];
|
||||||
FuriString* file_extension;
|
FuriString* file_extension;
|
||||||
|
|
||||||
WidgetElement* element;
|
WidgetElement* size_element;
|
||||||
|
WidgetElement* count_element;
|
||||||
FuriThread* thread;
|
FuriThread* thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -21,16 +21,22 @@ static uint32_t archive_scene_info_dirwalk(void* context) {
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
FileInfo fileinfo;
|
FileInfo fileinfo;
|
||||||
uint64_t total = 0;
|
uint64_t total = 0;
|
||||||
|
uint32_t item_count = 0;
|
||||||
DirWalk* dir_walk = dir_walk_alloc(furi_record_open(RECORD_STORAGE));
|
DirWalk* dir_walk = dir_walk_alloc(furi_record_open(RECORD_STORAGE));
|
||||||
ArchiveFile_t* current = archive_get_current_file(instance->browser);
|
ArchiveFile_t* current = archive_get_current_file(instance->browser);
|
||||||
if(dir_walk_open(dir_walk, furi_string_get_cstr(current->path))) {
|
if(dir_walk_open(dir_walk, furi_string_get_cstr(current->path))) {
|
||||||
while(scene_manager_get_scene_state(instance->scene_manager, ArchiveAppSceneInfo)) {
|
while(scene_manager_get_scene_state(instance->scene_manager, ArchiveAppSceneInfo)) {
|
||||||
DirWalkResult result = dir_walk_read(dir_walk, NULL, &fileinfo);
|
DirWalkResult result = dir_walk_read(dir_walk, NULL, &fileinfo);
|
||||||
if(result == DirWalkError) {
|
if(result == DirWalkError) {
|
||||||
widget_element_text_box_set_text(instance->element, "Size: \e#Error\e#");
|
widget_element_text_box_set_text(instance->size_element, "Size: \e#Error\e#");
|
||||||
|
if(instance->count_element) {
|
||||||
|
widget_element_text_box_set_text(
|
||||||
|
instance->count_element, "Items: \e#Error\e#");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bool is_last = result == DirWalkLast;
|
bool is_last = result == DirWalkLast;
|
||||||
|
if(!is_last) item_count++;
|
||||||
if(!file_info_is_dir(&fileinfo) || is_last) {
|
if(!file_info_is_dir(&fileinfo) || is_last) {
|
||||||
if(!is_last) total += fileinfo.size;
|
if(!is_last) total += fileinfo.size;
|
||||||
double show = total;
|
double show = total;
|
||||||
@@ -46,12 +52,21 @@ static uint32_t archive_scene_info_dirwalk(void* context) {
|
|||||||
is_last ? "" : "... ",
|
is_last ? "" : "... ",
|
||||||
show,
|
show,
|
||||||
units[unit]);
|
units[unit]);
|
||||||
widget_element_text_box_set_text(instance->element, buf);
|
widget_element_text_box_set_text(instance->size_element, buf);
|
||||||
|
|
||||||
|
if(instance->count_element) {
|
||||||
|
snprintf(
|
||||||
|
buf, sizeof(buf), "Items: %s\e#%lu\e#", is_last ? "" : "... ", item_count);
|
||||||
|
widget_element_text_box_set_text(instance->count_element, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(is_last) break;
|
if(is_last) break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
widget_element_text_box_set_text(instance->element, "Size: \e#Error\e#");
|
widget_element_text_box_set_text(instance->size_element, "Size: \e#Error\e#");
|
||||||
|
if(instance->count_element) {
|
||||||
|
widget_element_text_box_set_text(instance->count_element, "Items: \e#Error\e#");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dir_walk_free(dir_walk);
|
dir_walk_free(dir_walk);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
@@ -94,7 +109,7 @@ static uint32_t archive_scene_info_md5sum(void* context) {
|
|||||||
furi_string_cat_printf(md5, "%02x", output[i]);
|
furi_string_cat_printf(md5, "%02x", output[i]);
|
||||||
}
|
}
|
||||||
furi_string_cat(md5, "\e*");
|
furi_string_cat(md5, "\e*");
|
||||||
widget_element_text_box_set_text(instance->element, furi_string_get_cstr(md5));
|
widget_element_text_box_set_text(instance->size_element, furi_string_get_cstr(md5));
|
||||||
}
|
}
|
||||||
free(md5_ctx);
|
free(md5_ctx);
|
||||||
free(data);
|
free(data);
|
||||||
@@ -111,7 +126,7 @@ static uint32_t archive_scene_info_md5sum(void* context) {
|
|||||||
strlcat(buf, " ", sizeof(buf));
|
strlcat(buf, " ", sizeof(buf));
|
||||||
}
|
}
|
||||||
strlcat(buf, "\e*", sizeof(buf));
|
strlcat(buf, "\e*", sizeof(buf));
|
||||||
widget_element_text_box_set_text(instance->element, buf);
|
widget_element_text_box_set_text(instance->size_element, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
|
||||||
@@ -158,7 +173,6 @@ void archive_scene_info_on_enter(void* context) {
|
|||||||
} else if(file_info_is_dir(&fileinfo)) {
|
} else if(file_info_is_dir(&fileinfo)) {
|
||||||
is_dir = true;
|
is_dir = true;
|
||||||
snprintf(buf, sizeof(buf), "Size: ... \e#0\e# %s", units[0]);
|
snprintf(buf, sizeof(buf), "Size: ... \e#0\e# %s", units[0]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
double show = fileinfo.size;
|
double show = fileinfo.size;
|
||||||
size_t unit;
|
size_t unit;
|
||||||
@@ -173,8 +187,15 @@ void archive_scene_info_on_enter(void* context) {
|
|||||||
show,
|
show,
|
||||||
units[unit]);
|
units[unit]);
|
||||||
}
|
}
|
||||||
WidgetElement* element = widget_add_text_box_element(
|
|
||||||
|
WidgetElement* size_element = widget_add_text_box_element(
|
||||||
instance->widget, 1, 31, 126, 13, AlignLeft, AlignTop, buf, true);
|
instance->widget, 1, 31, 126, 13, AlignLeft, AlignTop, buf, true);
|
||||||
|
WidgetElement* count_element = NULL;
|
||||||
|
if(is_dir) {
|
||||||
|
snprintf(buf, sizeof(buf), "Items: ... \e#0\e#");
|
||||||
|
count_element = widget_add_text_box_element(
|
||||||
|
instance->widget, 1, 42, 126, 13, AlignLeft, AlignTop, buf, true);
|
||||||
|
}
|
||||||
|
|
||||||
// MD5 hash
|
// MD5 hash
|
||||||
if(!is_dir) {
|
if(!is_dir) {
|
||||||
@@ -184,11 +205,12 @@ void archive_scene_info_on_enter(void* context) {
|
|||||||
strlcat(buf, " ", sizeof(buf));
|
strlcat(buf, " ", sizeof(buf));
|
||||||
}
|
}
|
||||||
strlcat(buf, "\e*", sizeof(buf));
|
strlcat(buf, "\e*", sizeof(buf));
|
||||||
element = widget_add_text_box_element(
|
size_element = widget_add_text_box_element(
|
||||||
instance->widget, 0, 43, 128, 24, AlignRight, AlignTop, buf, false);
|
instance->widget, 0, 43, 128, 24, AlignRight, AlignTop, buf, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance->element = element;
|
instance->size_element = size_element;
|
||||||
|
instance->count_element = count_element;
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
|
||||||
|
Reference in New Issue
Block a user