mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-25 03:29:58 -07:00
Fix bugs with new model
This commit is contained in:
@@ -143,8 +143,9 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
|
||||
consumed = true;
|
||||
break;
|
||||
case ArchiveBrowserEventFileMenuInfo:
|
||||
archive_show_file_menu(browser, false);
|
||||
scene_manager_set_scene_state(
|
||||
archive->scene_manager, ArchiveAppSceneBrowser, SCENE_STATE_NEED_REFRESH);
|
||||
archive->scene_manager, ArchiveAppSceneBrowser, SCENE_STATE_DEFAULT);
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneInfo);
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
@@ -13,10 +13,10 @@ void archive_scene_info_widget_callback(GuiButtonType result, InputType type, vo
|
||||
|
||||
void archive_scene_info_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
ArchiveApp* app = (ArchiveApp*)context;
|
||||
ArchiveApp* instance = context;
|
||||
|
||||
widget_add_button_element(
|
||||
app->widget, GuiButtonTypeLeft, "Back", archive_scene_info_widget_callback, app);
|
||||
instance->widget, GuiButtonTypeLeft, "Back", archive_scene_info_widget_callback, instance);
|
||||
|
||||
string_t filename;
|
||||
string_t dirname;
|
||||
@@ -25,7 +25,7 @@ void archive_scene_info_on_enter(void* context) {
|
||||
string_init(dirname);
|
||||
string_init(str_size);
|
||||
|
||||
ArchiveFile_t* current = archive_get_current_file(app->browser);
|
||||
ArchiveFile_t* current = archive_get_current_file(instance->browser);
|
||||
char file_info_message[128];
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -33,7 +33,7 @@ void archive_scene_info_on_enter(void* context) {
|
||||
path_extract_filename(current->path, filename, false);
|
||||
snprintf(file_info_message, sizeof(file_info_message), "\e#%s\e#", string_get_cstr(filename));
|
||||
widget_add_text_box_element(
|
||||
app->widget, 0, 0, 128, 25, AlignLeft, AlignCenter, file_info_message, false);
|
||||
instance->widget, 0, 0, 128, 25, AlignLeft, AlignCenter, file_info_message, false);
|
||||
|
||||
// Directory path
|
||||
path_extract_dirname(string_get_cstr(current->path), dirname);
|
||||
@@ -42,22 +42,35 @@ void archive_scene_info_on_enter(void* context) {
|
||||
// File size
|
||||
FileInfo fileinfo;
|
||||
storage_common_stat(fs_api, string_get_cstr(current->path), &fileinfo);
|
||||
string_printf(str_size, "%d", fileinfo.size / 1024);
|
||||
snprintf(
|
||||
file_info_message,
|
||||
sizeof(file_info_message),
|
||||
"Size: \e#%s\e# Kb.\n%s",
|
||||
string_get_cstr(str_size),
|
||||
string_get_cstr(dirname)
|
||||
);
|
||||
if(fileinfo.size <= 1024) {
|
||||
string_printf(str_size, "%d", fileinfo.size);
|
||||
snprintf(
|
||||
file_info_message,
|
||||
sizeof(file_info_message),
|
||||
"Size: \e#%s\e# bytes\n%s",
|
||||
string_get_cstr(str_size),
|
||||
string_get_cstr(dirname));
|
||||
} else {
|
||||
string_printf(str_size, "%d", fileinfo.size / 1024);
|
||||
snprintf(
|
||||
file_info_message,
|
||||
sizeof(file_info_message),
|
||||
"Size: \e#%s\e# Kb.\n%s",
|
||||
string_get_cstr(str_size),
|
||||
string_get_cstr(dirname));
|
||||
}
|
||||
widget_add_text_box_element(
|
||||
app->widget, 0, 25, 128, 25, AlignLeft, AlignCenter, file_info_message, false);
|
||||
instance->widget, 0, 25, 128, 25, AlignLeft, AlignCenter, file_info_message, false);
|
||||
|
||||
// This one to return and cursor select this file
|
||||
path_extract_filename_no_ext(string_get_cstr(current->path), filename);
|
||||
strlcpy(instance->text_store, string_get_cstr(filename), MAX_NAME_LEN);
|
||||
|
||||
string_clear(filename);
|
||||
string_clear(dirname);
|
||||
string_clear(str_size);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, ArchiveViewWidget);
|
||||
view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget);
|
||||
}
|
||||
|
||||
bool archive_scene_info_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -17,7 +17,7 @@ void archive_scene_rename_text_input_callback(void* context) {
|
||||
}
|
||||
|
||||
void archive_scene_rename_on_enter(void* context) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
ArchiveApp* archive = context;
|
||||
|
||||
TextInput* text_input = archive->text_input;
|
||||
ArchiveFile_t* current = archive_get_current_file(archive->browser);
|
||||
@@ -44,7 +44,7 @@ void archive_scene_rename_on_enter(void* context) {
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
archive_scene_rename_text_input_callback,
|
||||
archive,
|
||||
context,
|
||||
archive->text_store,
|
||||
MAX_TEXT_INPUT_LEN,
|
||||
false);
|
||||
@@ -55,7 +55,7 @@ void archive_scene_rename_on_enter(void* context) {
|
||||
}
|
||||
|
||||
bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
ArchiveApp* archive = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
@@ -80,6 +80,7 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
string_cat_printf(path_dst, "/%s%s", archive->text_store, archive->file_extension);
|
||||
}
|
||||
// Long time process if this is directory
|
||||
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack);
|
||||
archive_show_loading_popup(archive, true);
|
||||
FS_Error error =
|
||||
archive_rename_file_or_dir(archive->browser, path_src, string_get_cstr(path_dst));
|
||||
@@ -88,14 +89,14 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
string_clear(path_dst);
|
||||
|
||||
if(error != FSE_OK) {
|
||||
if(error == FSE_OK || error == FSE_EXIST) {
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
|
||||
} else {
|
||||
string_t dialog_msg;
|
||||
string_init(dialog_msg);
|
||||
string_cat_printf(dialog_msg, "Cannot rename\nCode: %d", error);
|
||||
dialog_message_show_storage_error(archive->dialogs, string_get_cstr(dialog_msg));
|
||||
string_clear(dialog_msg);
|
||||
} else {
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
@@ -104,12 +105,6 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
void archive_scene_rename_on_exit(void* context) {
|
||||
ArchiveApp* archive = (ArchiveApp*)context;
|
||||
|
||||
// Clear view
|
||||
void* validator_context = text_input_get_validator_callback_context(archive->text_input);
|
||||
text_input_set_validator(archive->text_input, NULL, NULL);
|
||||
validator_is_file_free(validator_context);
|
||||
|
||||
ArchiveApp* archive = context;
|
||||
text_input_reset(archive->text_input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user