mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-29 21:52:03 -07:00
Archive, fix rename, show message to user
This commit is contained in:
@@ -22,17 +22,21 @@ void archive_scene_rename_on_enter(void* context) {
|
||||
TextInput* text_input = archive->text_input;
|
||||
ArchiveFile_t* current = archive_get_current_file(archive->browser);
|
||||
|
||||
FuriString* path_name;
|
||||
path_name = furi_string_alloc();
|
||||
FuriString* path_name = furi_string_alloc();
|
||||
FuriString* path_folder = furi_string_alloc();
|
||||
|
||||
if(current->type == ArchiveFileTypeFolder) {
|
||||
// Set file ext to empty since we need to see folder name here
|
||||
strcpy(archive->file_extension, "");
|
||||
// Extract folder name and copy into text_store
|
||||
path_extract_basename(furi_string_get_cstr(current->path), path_name);
|
||||
strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN);
|
||||
text_input_set_header_text(text_input, "Rename directory:");
|
||||
} else /*if(current->type != ArchiveFileTypeUnknown) */ {
|
||||
// Extract file name and copy into text_store
|
||||
path_extract_filename(current->path, path_name, true);
|
||||
strlcpy(archive->text_store, furi_string_get_cstr(path_name), MAX_NAME_LEN);
|
||||
|
||||
// Extract file extension for validator and rename func
|
||||
path_extract_extension(current->path, archive->file_extension, MAX_EXT_LEN);
|
||||
text_input_set_header_text(text_input, "Rename file:");
|
||||
} /*else {
|
||||
@@ -41,6 +45,9 @@ void archive_scene_rename_on_enter(void* context) {
|
||||
text_input_set_header_text(text_input, "Rename unknown file:");
|
||||
}*/
|
||||
|
||||
// Get current folder (for file) or previous folder (for folder) for validator
|
||||
path_extract_dirname(furi_string_get_cstr(current->path), path_folder);
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
archive_scene_rename_text_input_callback,
|
||||
@@ -49,7 +56,13 @@ void archive_scene_rename_on_enter(void* context) {
|
||||
MAX_TEXT_INPUT_LEN,
|
||||
false);
|
||||
|
||||
// Init validator to show message to user that name already exist
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
furi_string_get_cstr(path_folder), archive->file_extension, archive->text_store);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
furi_string_free(path_name);
|
||||
furi_string_free(path_folder);
|
||||
|
||||
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewTextInput);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user