diff --git a/firmware/application/apps/ui_fileman.cpp b/firmware/application/apps/ui_fileman.cpp index a4b007fec..9d33be043 100644 --- a/firmware/application/apps/ui_fileman.cpp +++ b/firmware/application/apps/ui_fileman.cpp @@ -450,7 +450,7 @@ void FileManagerView::on_rename(std::string_view hint) { void FileManagerView::on_delete() { if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) { - nav_.display_modal("Delete", "Directory not empty;\nUse \"clean\" button\nto clean it first"); + nav_.display_modal("Delete", " Folder is not empty;\n Use \"Clean\" button to\n empty it first."); return; } @@ -476,48 +476,28 @@ void FileManagerView::on_delete() { } void FileManagerView::on_clean() { - if (is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) { - ////selected a dir, who is not empty, del sub files - nav_.push( - "Delete", "Will delete all sub files\nexclude sub-folders,\nin this folder\nAre you sure?", YESNO, - [this](bool choice) { - if (choice) { - std::vector file_list; - file_list = scan_root_files(get_selected_full_path(), u"*"); - - for (const auto& file_name : file_list) { - std::filesystem::path current_full_path = get_selected_full_path() / file_name; - delete_file(current_full_path); - } - reload_current(); - } - }); - } else if (!is_directory(get_selected_full_path()) && !is_empty_directory(get_selected_full_path())) { - ////selected a file, will del it and all others in this dir - nav_.push( - "Delete", "Will delete all files\nexclude sub-folders\nin this folder,\nAre you sure?", YESNO, - [this](bool choice) { - if (choice) { - std::vector file_list; - file_list = scan_root_files(get_selected_full_path().parent_path(), u"*"); - - for (const auto& file_name : file_list) { - std::filesystem::path current_full_path = get_selected_full_path().parent_path() / file_name; - delete_file(current_full_path); - } - reload_current(); - } - }); - - } else if (is_directory(get_selected_full_path()) && is_empty_directory(get_selected_full_path())) { - ////sel an empty dir, threw - nav_.display_modal("Forbid", "You selected an empty dir;\nUse delete button \ninstead of clean button\nto delete it"); - return; - } else { - ////edge case e.g. probably . or .. (maybe not needed?) - nav_.display_modal("Forbid", "Not able to do that"); + if (is_empty_directory(get_selected_full_path())) { + nav_.display_modal("Clean", "Folder is Empty;\nUse \"Delete\" button instead\nof \"Clean\" button to delete\nit."); return; } + + auto path_name = is_directory(get_selected_full_path()) ? get_selected_full_path() : get_selected_full_path().parent_path(); + + // selected either a single file (delete files in this directory) or a directory that is not empty (del sub files) + nav_.push( + "Clean", " ALL FILES in this folder\n (excluding sub-folders)\n will be DELETED!\n\n Delete all files?", YESNO, + [this, path_name](bool choice) { + if (choice) { + std::vector file_list; + file_list = scan_root_files(path_name, u"*"); + + for (const auto& file_name : file_list) { + std::filesystem::path current_full_path = path_name / file_name; + delete_file(current_full_path); + } + reload_current(); + } + }); } void FileManagerView::on_new_dir() { diff --git a/firmware/application/apps/ui_fileman.hpp b/firmware/application/apps/ui_fileman.hpp index 38017c786..892e2176c 100644 --- a/firmware/application/apps/ui_fileman.hpp +++ b/firmware/application/apps/ui_fileman.hpp @@ -236,7 +236,7 @@ class FileManagerView : public FileManBaseView { NewButton button_clean{ {13 * 8, 34 * 8, 4 * 8, 32}, {}, - &bitmap_icon_scanner, + &bitmap_icon_clean, Color::red()}; NewButton button_cut{ diff --git a/firmware/application/bitmap.hpp b/firmware/application/bitmap.hpp index 9e2b36337..f4b1a2c21 100644 --- a/firmware/application/bitmap.hpp +++ b/firmware/application/bitmap.hpp @@ -5797,6 +5797,44 @@ static constexpr Bitmap bitmap_icon_brightness{ {16, 16}, bitmap_icon_brightness_data}; +static constexpr uint8_t bitmap_icon_clean_data[] = { + 0x00, + 0x00, + 0xC0, + 0x01, + 0x20, + 0x02, + 0xFC, + 0x1F, + 0x00, + 0x00, + 0x08, + 0x08, + 0xE8, + 0x08, + 0xA8, + 0x09, + 0xA8, + 0x0B, + 0x28, + 0x0A, + 0x28, + 0x0A, + 0x28, + 0x0A, + 0xE8, + 0x0B, + 0x08, + 0x08, + 0xF0, + 0x07, + 0x00, + 0x00, +}; +static constexpr Bitmap bitmap_icon_clean{ + {16, 16}, + bitmap_icon_clean_data}; + } /* namespace ui */ #endif /*__BITMAP_HPP__*/ diff --git a/firmware/graphics/icon_clean.png b/firmware/graphics/icon_clean.png new file mode 100644 index 000000000..62908ff97 Binary files /dev/null and b/firmware/graphics/icon_clean.png differ