Просмотр исходного кода

Archive: fix delete from favorites tab (#752)

* archive_delete_file vargs, fix wrong path when deleting item from favorites tab
* use string_t for archive vargs funcs
* favorites manual sorting

Co-authored-by: あく <alleteam@gmail.com>
its your bedtime 4 лет назад
Родитель
Сommit
5cb5d15376

+ 37 - 0
applications/archive/helpers/archive_browser.c

@@ -76,6 +76,23 @@ void archive_file_array_rm_selected(ArchiveBrowserView* browser) {
     archive_update_offset(browser);
     archive_update_offset(browser);
 }
 }
 
 
+void archive_file_array_swap(ArchiveBrowserView* browser, int8_t d) {
+    with_view_model(
+        browser->view, (ArchiveBrowserViewModel * model) {
+            size_t array_size = files_array_size(model->files) - 1;
+            uint8_t swap_idx = CLAMP(model->idx + d, array_size, 0);
+
+            if(model->idx == 0 && d < 0) {
+                swap_idx = array_size;
+            } else if(model->idx == array_size && d > 0) {
+                swap_idx = 0;
+            }
+
+            files_array_swap_at(model->files, model->idx, swap_idx);
+            return false;
+        });
+}
+
 void archive_file_array_rm_all(ArchiveBrowserView* browser) {
 void archive_file_array_rm_all(ArchiveBrowserView* browser) {
     with_view_model(
     with_view_model(
         browser->view, (ArchiveBrowserViewModel * model) {
         browser->view, (ArchiveBrowserViewModel * model) {
@@ -95,6 +112,18 @@ ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser) {
     return selected;
     return selected;
 }
 }
 
 
+ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
+    ArchiveFile_t* selected;
+    idx = CLAMP(idx, archive_file_array_size(browser), 0);
+
+    with_view_model(
+        browser->view, (ArchiveBrowserViewModel * model) {
+            selected = files_array_size(model->files) ? files_array_get(model->files, idx) : NULL;
+            return false;
+        });
+    return selected;
+}
+
 ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) {
 ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser) {
     ArchiveTabEnum tab_id;
     ArchiveTabEnum tab_id;
     with_view_model(
     with_view_model(
@@ -179,6 +208,14 @@ void archive_show_file_menu(ArchiveBrowserView* browser, bool show) {
         });
         });
 }
 }
 
 
+void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active) {
+    with_view_model(
+        browser->view, (ArchiveBrowserViewModel * model) {
+            model->move_fav = active;
+            return true;
+        });
+}
+
 void archive_switch_dir(ArchiveBrowserView* browser, const char* path) {
 void archive_switch_dir(ArchiveBrowserView* browser, const char* path) {
     furi_assert(browser);
     furi_assert(browser);
     furi_assert(path);
     furi_assert(path);

+ 3 - 0
applications/archive/helpers/archive_browser.h

@@ -52,9 +52,11 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target);
 
 
 size_t archive_file_array_size(ArchiveBrowserView* browser);
 size_t archive_file_array_size(ArchiveBrowserView* browser);
 void archive_file_array_rm_selected(ArchiveBrowserView* browser);
 void archive_file_array_rm_selected(ArchiveBrowserView* browser);
+void archive_file_array_swap(ArchiveBrowserView* browser, int8_t d);
 void archive_file_array_rm_all(ArchiveBrowserView* browser);
 void archive_file_array_rm_all(ArchiveBrowserView* browser);
 
 
 ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser);
 ArchiveFile_t* archive_get_current_file(ArchiveBrowserView* browser);
+ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx);
 ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser);
 ArchiveTabEnum archive_get_tab(ArchiveBrowserView* browser);
 uint8_t archive_get_depth(ArchiveBrowserView* browser);
 uint8_t archive_get_depth(ArchiveBrowserView* browser);
 const char* archive_get_path(ArchiveBrowserView* browser);
 const char* archive_get_path(ArchiveBrowserView* browser);
@@ -62,6 +64,7 @@ const char* archive_get_name(ArchiveBrowserView* browser);
 
 
 void archive_add_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name);
 void archive_add_item(ArchiveBrowserView* browser, FileInfo* file_info, const char* name);
 void archive_show_file_menu(ArchiveBrowserView* browser, bool show);
 void archive_show_file_menu(ArchiveBrowserView* browser, bool show);
+void archive_favorites_move_mode(ArchiveBrowserView* browser, bool active);
 
 
 void archive_switch_tab(ArchiveBrowserView* browser, InputKey key);
 void archive_switch_tab(ArchiveBrowserView* browser, InputKey key);
 void archive_enter_dir(ArchiveBrowserView* browser, string_t name);
 void archive_enter_dir(ArchiveBrowserView* browser, string_t name);

+ 34 - 18
applications/archive/helpers/archive_favorites.c

@@ -34,7 +34,7 @@ uint16_t archive_favorites_count(void* context) {
 bool archive_favorites_read(void* context) {
 bool archive_favorites_read(void* context) {
     furi_assert(context);
     furi_assert(context);
 
 
-    ArchiveBrowserView* archive_view = context;
+    ArchiveBrowserView* browser = context;
     FileWorker* file_worker = file_worker_alloc(true);
     FileWorker* file_worker = file_worker_alloc(true);
 
 
     string_t buffer;
     string_t buffer;
@@ -52,7 +52,7 @@ bool archive_favorites_read(void* context) {
                 break;
                 break;
             }
             }
 
 
-            archive_add_item(archive_view, &file_info, string_get_cstr(buffer));
+            archive_add_item(browser, &file_info, string_get_cstr(buffer));
             string_clean(buffer);
             string_clean(buffer);
         }
         }
     }
     }
@@ -63,17 +63,15 @@ bool archive_favorites_read(void* context) {
 }
 }
 
 
 bool archive_favorites_delete(const char* format, ...) {
 bool archive_favorites_delete(const char* format, ...) {
+    string_t buffer;
+    string_t filename;
     va_list args;
     va_list args;
     va_start(args, format);
     va_start(args, format);
-    uint8_t len = vsnprintf(NULL, 0, format, args);
-    char filename[len + 1];
-    vsnprintf(filename, len + 1, format, args);
+    string_init_vprintf(filename, format, args);
     va_end(args);
     va_end(args);
 
 
-    FileWorker* file_worker = file_worker_alloc(true);
-
-    string_t buffer;
     string_init(buffer);
     string_init(buffer);
+    FileWorker* file_worker = file_worker_alloc(true);
 
 
     bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
     bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
     if(result) {
     if(result) {
@@ -85,13 +83,14 @@ bool archive_favorites_delete(const char* format, ...) {
                 break;
                 break;
             }
             }
 
 
-            if(string_search_str(buffer, filename)) {
-                archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\r\n", string_get_cstr(buffer));
+            if(string_search(buffer, filename)) {
+                archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
             }
             }
         }
         }
     }
     }
 
 
     string_clear(buffer);
     string_clear(buffer);
+    string_clear(filename);
 
 
     file_worker_close(file_worker);
     file_worker_close(file_worker);
     file_worker_remove(file_worker, ARCHIVE_FAV_PATH);
     file_worker_remove(file_worker, ARCHIVE_FAV_PATH);
@@ -103,16 +102,15 @@ bool archive_favorites_delete(const char* format, ...) {
 }
 }
 
 
 bool archive_is_favorite(const char* format, ...) {
 bool archive_is_favorite(const char* format, ...) {
+    string_t buffer;
+    string_t filename;
     va_list args;
     va_list args;
     va_start(args, format);
     va_start(args, format);
-    uint8_t len = vsnprintf(NULL, 0, format, args);
-    char filename[len + 1];
-    vsnprintf(filename, len + 1, format, args);
+    string_init_vprintf(filename, format, args);
     va_end(args);
     va_end(args);
 
 
-    FileWorker* file_worker = file_worker_alloc(true);
-    string_t buffer;
     string_init(buffer);
     string_init(buffer);
+    FileWorker* file_worker = file_worker_alloc(true);
 
 
     bool found = false;
     bool found = false;
     bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
     bool result = file_worker_open(file_worker, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
@@ -125,7 +123,7 @@ bool archive_is_favorite(const char* format, ...) {
             if(!string_size(buffer)) {
             if(!string_size(buffer)) {
                 break;
                 break;
             }
             }
-            if(!string_search_str(buffer, filename)) {
+            if(!string_search(buffer, filename)) {
                 found = true;
                 found = true;
                 break;
                 break;
             }
             }
@@ -133,6 +131,7 @@ bool archive_is_favorite(const char* format, ...) {
     }
     }
 
 
     string_clear(buffer);
     string_clear(buffer);
+    string_clear(filename);
     file_worker_close(file_worker);
     file_worker_close(file_worker);
     file_worker_free(file_worker);
     file_worker_free(file_worker);
 
 
@@ -166,7 +165,7 @@ bool archive_favorites_rename(const char* file_path, const char* src, const char
 
 
             archive_file_append(
             archive_file_append(
                 ARCHIVE_FAV_TEMP_PATH,
                 ARCHIVE_FAV_TEMP_PATH,
-                "%s\r\n",
+                "%s\n",
                 string_search(buffer, path) ? string_get_cstr(buffer) : dst);
                 string_search(buffer, path) ? string_get_cstr(buffer) : dst);
         }
         }
     }
     }
@@ -186,5 +185,22 @@ bool archive_favorites_rename(const char* file_path, const char* src, const char
 void archive_add_to_favorites(const char* file_path) {
 void archive_add_to_favorites(const char* file_path) {
     furi_assert(file_path);
     furi_assert(file_path);
 
 
-    archive_file_append(ARCHIVE_FAV_PATH, "%s\r\n", file_path);
+    archive_file_append(ARCHIVE_FAV_PATH, "%s\n", file_path);
 }
 }
+
+void archive_favorites_save(void* context) {
+    furi_assert(context);
+
+    ArchiveBrowserView* browser = context;
+    FileWorker* file_worker = file_worker_alloc(true);
+
+    for(size_t i = 0; i < archive_file_array_size(browser); i++) {
+        ArchiveFile_t* item = archive_get_file_at(browser, i);
+        archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(item->name));
+    }
+
+    file_worker_remove(file_worker, ARCHIVE_FAV_PATH);
+    file_worker_rename(file_worker, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
+
+    file_worker_free(file_worker);
+}

+ 2 - 1
applications/archive/helpers/archive_favorites.h

@@ -9,4 +9,5 @@ bool archive_favorites_read(void* context);
 bool archive_favorites_delete(const char* format, ...);
 bool archive_favorites_delete(const char* format, ...);
 bool archive_is_favorite(const char* format, ...);
 bool archive_is_favorite(const char* format, ...);
 bool archive_favorites_rename(const char* file_path, const char* src, const char* dst);
 bool archive_favorites_rename(const char* file_path, const char* src, const char* dst);
-void archive_add_to_favorites(const char* file_path);
+void archive_add_to_favorites(const char* file_path);
+void archive_favorites_save(void* context);

+ 16 - 15
applications/archive/helpers/archive_files.c

@@ -138,11 +138,10 @@ bool archive_read_dir(void* context, const char* path) {
 void archive_file_append(const char* path, const char* format, ...) {
 void archive_file_append(const char* path, const char* format, ...) {
     furi_assert(path);
     furi_assert(path);
 
 
+    string_t string;
     va_list args;
     va_list args;
     va_start(args, format);
     va_start(args, format);
-    uint8_t len = vsnprintf(NULL, 0, format, args);
-    char cstr_buff[len + 1];
-    vsnprintf(cstr_buff, len + 1, format, args);
+    string_init_vprintf(string, format, args);
     va_end(args);
     va_end(args);
 
 
     FileWorker* file_worker = file_worker_alloc(false);
     FileWorker* file_worker = file_worker_alloc(false);
@@ -151,7 +150,7 @@ void archive_file_append(const char* path, const char* format, ...) {
         FURI_LOG_E("Archive", "Append open error");
         FURI_LOG_E("Archive", "Append open error");
     }
     }
 
 
-    if(!file_worker_write(file_worker, cstr_buff, strlen(cstr_buff))) {
+    if(!file_worker_write(file_worker, string_get_cstr(string), string_size(string))) {
         FURI_LOG_E("Archive", "Append write error");
         FURI_LOG_E("Archive", "Append write error");
     }
     }
 
 
@@ -159,26 +158,28 @@ void archive_file_append(const char* path, const char* format, ...) {
     file_worker_free(file_worker);
     file_worker_free(file_worker);
 }
 }
 
 
-void archive_delete_file(void* context, string_t path, string_t name) {
+void archive_delete_file(void* context, const char* format, ...) {
     furi_assert(context);
     furi_assert(context);
-    furi_assert(path);
-    furi_assert(name);
+
+    string_t filename;
+    va_list args;
+    va_start(args, format);
+    string_init_vprintf(filename, format, args);
+    va_end(args);
+
     ArchiveBrowserView* browser = context;
     ArchiveBrowserView* browser = context;
     FileWorker* file_worker = file_worker_alloc(true);
     FileWorker* file_worker = file_worker_alloc(true);
 
 
-    string_t full_path;
-    string_init_printf(full_path, "%s/%s", string_get_cstr(path), string_get_cstr(name));
-
-    bool res = file_worker_remove(file_worker, string_get_cstr(full_path));
+    bool res = file_worker_remove(file_worker, string_get_cstr(filename));
     file_worker_free(file_worker);
     file_worker_free(file_worker);
 
 
-    if(archive_is_favorite(string_get_cstr(full_path))) {
-        archive_favorites_delete(string_get_cstr(full_path));
+    if(archive_is_favorite("%s", string_get_cstr(filename))) {
+        archive_favorites_delete("%s", string_get_cstr(filename));
     }
     }
 
 
     if(res) {
     if(res) {
         archive_file_array_rm_selected(browser);
         archive_file_array_rm_selected(browser);
     }
     }
 
 
-    string_clear(full_path);
-}
+    string_clear(filename);
+}

+ 1 - 1
applications/archive/helpers/archive_files.h

@@ -54,4 +54,4 @@ bool archive_get_filenames(void* context, const char* path);
 bool archive_dir_empty(void* context, const char* path);
 bool archive_dir_empty(void* context, const char* path);
 bool archive_read_dir(void* context, const char* path);
 bool archive_read_dir(void* context, const char* path);
 void archive_file_append(const char* path, const char* format, ...);
 void archive_file_append(const char* path, const char* format, ...);
-void archive_delete_file(void* context, string_t path, string_t name);
+void archive_delete_file(void* context, const char* format, ...);

+ 36 - 5
applications/archive/scenes/archive_scene_browser.c

@@ -76,25 +76,32 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
             if(favorites) {
             if(favorites) {
                 archive_favorites_delete(name);
                 archive_favorites_delete(name);
                 archive_file_array_rm_selected(browser);
                 archive_file_array_rm_selected(browser);
+                archive_show_file_menu(browser, false);
             } else if(known_app) {
             } else if(known_app) {
                 if(archive_is_favorite("%s/%s", path, name)) {
                 if(archive_is_favorite("%s/%s", path, name)) {
                     archive_favorites_delete("%s/%s", path, name);
                     archive_favorites_delete("%s/%s", path, name);
                 } else {
                 } else {
-                    archive_file_append(ARCHIVE_FAV_PATH, "%s/%s\r\n", path, name);
+                    archive_file_append(ARCHIVE_FAV_PATH, "%s/%s\n", path, name);
                 }
                 }
+                archive_show_file_menu(browser, false);
             }
             }
-            archive_show_file_menu(browser, false);
             consumed = true;
             consumed = true;
             break;
             break;
 
 
-        case ArchiveBrowserEventFileMenuRename:
-            if(known_app && !favorites) {
+        case ArchiveBrowserEventFileMenuAction:
+            if(favorites) {
+                browser->callback(ArchiveBrowserEventEnterFavMove, browser->context);
+            } else if(known_app) {
                 scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneRename);
                 scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneRename);
             }
             }
             consumed = true;
             consumed = true;
             break;
             break;
         case ArchiveBrowserEventFileMenuDelete:
         case ArchiveBrowserEventFileMenuDelete:
-            archive_delete_file(browser, browser->path, selected->name);
+            if(favorites) {
+                archive_delete_file(browser, "%s", name);
+            } else {
+                archive_delete_file(browser, "%s/%s", path, name);
+            }
             archive_show_file_menu(browser, false);
             archive_show_file_menu(browser, false);
             consumed = true;
             consumed = true;
             break;
             break;
@@ -102,6 +109,30 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
             archive_enter_dir(browser, selected->name);
             archive_enter_dir(browser, selected->name);
             consumed = true;
             consumed = true;
             break;
             break;
+        case ArchiveBrowserEventFavMoveUp:
+            archive_file_array_swap(browser, 1);
+            consumed = true;
+            break;
+        case ArchiveBrowserEventFavMoveDown:
+            archive_file_array_swap(browser, -1);
+            consumed = true;
+            break;
+        case ArchiveBrowserEventEnterFavMove:
+            strlcpy(archive->text_store, archive_get_name(browser), MAX_NAME_LEN);
+            archive_show_file_menu(browser, false);
+            archive_favorites_move_mode(archive->browser, true);
+            consumed = true;
+            break;
+        case ArchiveBrowserEventExitFavMove:
+            archive_update_focus(browser, archive->text_store);
+            archive_favorites_move_mode(archive->browser, false);
+            consumed = true;
+            break;
+        case ArchiveBrowserEventSaveFavMove:
+            archive_favorites_move_mode(archive->browser, false);
+            archive_favorites_save(archive->browser);
+            consumed = true;
+            break;
 
 
         case ArchiveBrowserEventExit:
         case ArchiveBrowserEventExit:
             if(archive_get_depth(browser)) {
             if(archive_get_depth(browser)) {

+ 53 - 17
applications/archive/views/archive_browser_view.c

@@ -55,7 +55,7 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
         string_set_str(menu[1], "Unpin");
         string_set_str(menu[1], "Unpin");
     } else if(model->tab_idx == ArchiveTabFavorites) {
     } else if(model->tab_idx == ArchiveTabFavorites) {
         string_set_str(menu[1], "Unpin");
         string_set_str(menu[1], "Unpin");
-        string_set_str(menu[2], "---");
+        string_set_str(menu[2], "Move");
     }
     }
 
 
     for(size_t i = 0; i < MENU_ITEMS; i++) {
     for(size_t i = 0; i < MENU_ITEMS; i++) {
@@ -66,16 +66,23 @@ static void render_item_menu(Canvas* canvas, ArchiveBrowserViewModel* model) {
     canvas_draw_icon(canvas, 74, 20 + model->menu_idx * 11, &I_ButtonRight_4x7);
     canvas_draw_icon(canvas, 74, 20 + model->menu_idx * 11, &I_ButtonRight_4x7);
 }
 }
 
 
-static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
+static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar, bool moving) {
+    uint8_t x_offset = moving ? MOVE_OFFSET : 0;
+
     canvas_set_color(canvas, ColorBlack);
     canvas_set_color(canvas, ColorBlack);
-    canvas_draw_box(canvas, 0, 15 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT);
+    canvas_draw_box(
+        canvas,
+        0 + x_offset,
+        15 + idx * FRAME_HEIGHT,
+        (scrollbar ? 122 : 127) - x_offset,
+        FRAME_HEIGHT);
 
 
     canvas_set_color(canvas, ColorWhite);
     canvas_set_color(canvas, ColorWhite);
-    canvas_draw_dot(canvas, 0, 15 + idx * FRAME_HEIGHT);
-    canvas_draw_dot(canvas, 1, 15 + idx * FRAME_HEIGHT);
-    canvas_draw_dot(canvas, 0, (15 + idx * FRAME_HEIGHT) + 1);
+    canvas_draw_dot(canvas, 0 + x_offset, 15 + idx * FRAME_HEIGHT);
+    canvas_draw_dot(canvas, 1 + x_offset, 15 + idx * FRAME_HEIGHT);
+    canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 1);
 
 
-    canvas_draw_dot(canvas, 0, (15 + idx * FRAME_HEIGHT) + 11);
+    canvas_draw_dot(canvas, 0 + x_offset, (15 + idx * FRAME_HEIGHT) + 11);
     canvas_draw_dot(canvas, scrollbar ? 121 : 126, 15 + idx * FRAME_HEIGHT);
     canvas_draw_dot(canvas, scrollbar ? 121 : 126, 15 + idx * FRAME_HEIGHT);
     canvas_draw_dot(canvas, scrollbar ? 121 : 126, (15 + idx * FRAME_HEIGHT) + 11);
     canvas_draw_dot(canvas, scrollbar ? 121 : 126, (15 + idx * FRAME_HEIGHT) + 11);
 }
 }
@@ -89,23 +96,26 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
     for(size_t i = 0; i < MIN(array_size, MENU_ITEMS); ++i) {
     for(size_t i = 0; i < MIN(array_size, MENU_ITEMS); ++i) {
         string_t str_buff;
         string_t str_buff;
         char cstr_buff[MAX_NAME_LEN];
         char cstr_buff[MAX_NAME_LEN];
-
         size_t idx = CLAMP(i + model->list_offset, array_size, 0);
         size_t idx = CLAMP(i + model->list_offset, array_size, 0);
+        uint8_t x_offset = (model->move_fav && model->idx == idx) ? MOVE_OFFSET : 0;
+
         ArchiveFile_t* file = files_array_get(model->files, CLAMP(idx, array_size - 1, 0));
         ArchiveFile_t* file = files_array_get(model->files, CLAMP(idx, array_size - 1, 0));
 
 
         strlcpy(cstr_buff, string_get_cstr(file->name), string_size(file->name) + 1);
         strlcpy(cstr_buff, string_get_cstr(file->name), string_size(file->name) + 1);
         archive_trim_file_path(cstr_buff, is_known_app(file->type));
         archive_trim_file_path(cstr_buff, is_known_app(file->type));
         string_init_set_str(str_buff, cstr_buff);
         string_init_set_str(str_buff, cstr_buff);
-        elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX);
+        elements_string_fit_width(
+            canvas, str_buff, (scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX) - x_offset);
 
 
         if(model->idx == idx) {
         if(model->idx == idx) {
-            archive_draw_frame(canvas, i, scrollbar);
+            archive_draw_frame(canvas, i, scrollbar, model->move_fav);
         } else {
         } else {
             canvas_set_color(canvas, ColorBlack);
             canvas_set_color(canvas, ColorBlack);
         }
         }
 
 
-        canvas_draw_icon(canvas, 2, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file->type]);
-        canvas_draw_str(canvas, 15, 24 + i * FRAME_HEIGHT, string_get_cstr(str_buff));
+        canvas_draw_icon(
+            canvas, 2 + x_offset, 16 + i * FRAME_HEIGHT, ArchiveItemIcons[file->type]);
+        canvas_draw_str(canvas, 15 + x_offset, 24 + i * FRAME_HEIGHT, string_get_cstr(str_buff));
         string_clear(str_buff);
         string_clear(str_buff);
     }
     }
 
 
@@ -139,8 +149,13 @@ static void archive_render_status_bar(Canvas* canvas, ArchiveBrowserViewModel* m
     canvas_draw_line(canvas, 107, 1, 107, 11);
     canvas_draw_line(canvas, 107, 1, 107, 11);
     canvas_draw_line(canvas, 108, 12, 126, 12);
     canvas_draw_line(canvas, 108, 12, 126, 12);
 
 
-    canvas_draw_icon(canvas, 112, 2, &I_ButtonLeft_4x7);
-    canvas_draw_icon(canvas, 120, 2, &I_ButtonRight_4x7);
+    if(model->move_fav) {
+        canvas_draw_icon(canvas, 111, 4, &I_ButtonUp_7x4);
+        canvas_draw_icon(canvas, 118, 4, &I_ButtonDown_7x4);
+    } else {
+        canvas_draw_icon(canvas, 112, 2, &I_ButtonLeft_4x7);
+        canvas_draw_icon(canvas, 120, 2, &I_ButtonRight_4x7);
+    }
 
 
     canvas_set_color(canvas, ColorWhite);
     canvas_set_color(canvas, ColorWhite);
     canvas_draw_dot(canvas, 50, 0);
     canvas_draw_dot(canvas, 50, 0);
@@ -174,9 +189,11 @@ bool archive_view_input(InputEvent* event, void* context) {
     ArchiveBrowserView* browser = context;
     ArchiveBrowserView* browser = context;
 
 
     bool in_menu;
     bool in_menu;
+    bool move_fav_mode;
     with_view_model(
     with_view_model(
         browser->view, (ArchiveBrowserViewModel * model) {
         browser->view, (ArchiveBrowserViewModel * model) {
             in_menu = model->menu;
             in_menu = model->menu;
+            move_fav_mode = model->move_fav;
             return false;
             return false;
         });
         });
 
 
@@ -210,11 +227,17 @@ bool archive_view_input(InputEvent* event, void* context) {
     } else {
     } else {
         if(event->type == InputTypeShort) {
         if(event->type == InputTypeShort) {
             if(event->key == InputKeyLeft || event->key == InputKeyRight) {
             if(event->key == InputKeyLeft || event->key == InputKeyRight) {
+                if(move_fav_mode) return false;
                 archive_switch_tab(browser, event->key);
                 archive_switch_tab(browser, event->key);
             } else if(event->key == InputKeyBack) {
             } else if(event->key == InputKeyBack) {
-                browser->callback(ArchiveBrowserEventExit, browser->context);
+                if(move_fav_mode) {
+                    browser->callback(ArchiveBrowserEventExitFavMove, browser->context);
+                } else {
+                    browser->callback(ArchiveBrowserEventExit, browser->context);
+                }
             }
             }
         }
         }
+
         if(event->key == InputKeyUp || event->key == InputKeyDown) {
         if(event->key == InputKeyUp || event->key == InputKeyDown) {
             with_view_model(
             with_view_model(
                 browser->view, (ArchiveBrowserViewModel * model) {
                 browser->view, (ArchiveBrowserViewModel * model) {
@@ -222,8 +245,15 @@ bool archive_view_input(InputEvent* event, void* context) {
                     if((event->type == InputTypeShort || event->type == InputTypeRepeat)) {
                     if((event->type == InputTypeShort || event->type == InputTypeRepeat)) {
                         if(event->key == InputKeyUp) {
                         if(event->key == InputKeyUp) {
                             model->idx = ((model->idx - 1) + num_elements) % num_elements;
                             model->idx = ((model->idx - 1) + num_elements) % num_elements;
+                            if(move_fav_mode) {
+                                browser->callback(ArchiveBrowserEventFavMoveUp, browser->context);
+                            }
                         } else if(event->key == InputKeyDown) {
                         } else if(event->key == InputKeyDown) {
                             model->idx = (model->idx + 1) % num_elements;
                             model->idx = (model->idx + 1) % num_elements;
+                            if(move_fav_mode) {
+                                browser->callback(
+                                    ArchiveBrowserEventFavMoveDown, browser->context);
+                            }
                         }
                         }
                     }
                     }
 
 
@@ -241,14 +271,20 @@ bool archive_view_input(InputEvent* event, void* context) {
 
 
                 if(event->type == InputTypeShort) {
                 if(event->type == InputTypeShort) {
                     if(favorites) {
                     if(favorites) {
-                        browser->callback(ArchiveBrowserEventFileMenuRun, browser->context);
+                        if(move_fav_mode) {
+                            browser->callback(ArchiveBrowserEventSaveFavMove, browser->context);
+                        } else {
+                            browser->callback(ArchiveBrowserEventFileMenuRun, browser->context);
+                        }
                     } else if(folder) {
                     } else if(folder) {
                         browser->callback(ArchiveBrowserEventEnterDir, browser->context);
                         browser->callback(ArchiveBrowserEventEnterDir, browser->context);
                     } else {
                     } else {
                         browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
                         browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
                     }
                     }
                 } else if(event->type == InputTypeLong) {
                 } else if(event->type == InputTypeLong) {
-                    if(folder || favorites) {
+                    if(move_fav_mode) {
+                        browser->callback(ArchiveBrowserEventSaveFavMove, browser->context);
+                    } else if(folder || favorites) {
                         browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
                         browser->callback(ArchiveBrowserEventFileMenuOpen, browser->context);
                     }
                     }
                 }
                 }

+ 9 - 2
applications/archive/views/archive_browser_view.h

@@ -14,6 +14,7 @@
 #define FRAME_HEIGHT 12
 #define FRAME_HEIGHT 12
 #define MENU_ITEMS 4
 #define MENU_ITEMS 4
 #define MAX_DEPTH 32
 #define MAX_DEPTH 32
+#define MOVE_OFFSET 5
 
 
 typedef enum {
 typedef enum {
     ArchiveTabFavorites,
     ArchiveTabFavorites,
@@ -31,16 +32,21 @@ typedef enum {
     ArchiveBrowserEventFileMenuClose,
     ArchiveBrowserEventFileMenuClose,
     ArchiveBrowserEventFileMenuRun,
     ArchiveBrowserEventFileMenuRun,
     ArchiveBrowserEventFileMenuPin,
     ArchiveBrowserEventFileMenuPin,
-    ArchiveBrowserEventFileMenuRename,
+    ArchiveBrowserEventFileMenuAction,
     ArchiveBrowserEventFileMenuDelete,
     ArchiveBrowserEventFileMenuDelete,
     ArchiveBrowserEventEnterDir,
     ArchiveBrowserEventEnterDir,
+    ArchiveBrowserEventFavMoveUp,
+    ArchiveBrowserEventFavMoveDown,
+    ArchiveBrowserEventEnterFavMove,
+    ArchiveBrowserEventExitFavMove,
+    ArchiveBrowserEventSaveFavMove,
     ArchiveBrowserEventExit,
     ArchiveBrowserEventExit,
 } ArchiveBrowserEvent;
 } ArchiveBrowserEvent;
 
 
 static const uint8_t file_menu_actions[MENU_ITEMS] = {
 static const uint8_t file_menu_actions[MENU_ITEMS] = {
     [0] = ArchiveBrowserEventFileMenuRun,
     [0] = ArchiveBrowserEventFileMenuRun,
     [1] = ArchiveBrowserEventFileMenuPin,
     [1] = ArchiveBrowserEventFileMenuPin,
-    [2] = ArchiveBrowserEventFileMenuRename,
+    [2] = ArchiveBrowserEventFileMenuAction,
     [3] = ArchiveBrowserEventFileMenuDelete,
     [3] = ArchiveBrowserEventFileMenuDelete,
 };
 };
 
 
@@ -68,6 +74,7 @@ typedef struct {
     files_array_t files;
     files_array_t files;
 
 
     uint8_t menu_idx;
     uint8_t menu_idx;
+    bool move_fav;
     bool menu;
     bool menu;
 
 
     uint16_t idx;
     uint16_t idx;

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
assets/compiled/assets_icons.c


+ 57 - 57
assets/compiled/assets_icons.h

@@ -5,64 +5,64 @@ extern const Icon I_Certification1_103x23;
 extern const Icon I_Certification2_119x30;
 extern const Icon I_Certification2_119x30;
 extern const Icon A_WatchingTV_128x64;
 extern const Icon A_WatchingTV_128x64;
 extern const Icon A_Wink_128x64;
 extern const Icon A_Wink_128x64;
-extern const Icon I_125_10px;
-extern const Icon I_ble_10px;
 extern const Icon I_dir_10px;
 extern const Icon I_dir_10px;
-extern const Icon I_ibutt_10px;
-extern const Icon I_ir_10px;
 extern const Icon I_Nfc_10px;
 extern const Icon I_Nfc_10px;
 extern const Icon I_sub1_10px;
 extern const Icon I_sub1_10px;
+extern const Icon I_ir_10px;
+extern const Icon I_ibutt_10px;
 extern const Icon I_unknown_10px;
 extern const Icon I_unknown_10px;
-extern const Icon I_ButtonCenter_7x7;
-extern const Icon I_ButtonLeftSmall_3x5;
-extern const Icon I_ButtonLeft_4x7;
+extern const Icon I_ble_10px;
+extern const Icon I_125_10px;
 extern const Icon I_ButtonRightSmall_3x5;
 extern const Icon I_ButtonRightSmall_3x5;
-extern const Icon I_ButtonRight_4x7;
+extern const Icon I_ButtonLeft_4x7;
+extern const Icon I_ButtonLeftSmall_3x5;
 extern const Icon I_DFU_128x50;
 extern const Icon I_DFU_128x50;
 extern const Icon I_Warning_30x23;
 extern const Icon I_Warning_30x23;
-extern const Icon I_DolphinFirstStart0_70x53;
-extern const Icon I_DolphinFirstStart1_59x53;
-extern const Icon I_DolphinFirstStart2_59x51;
-extern const Icon I_DolphinFirstStart3_57x48;
+extern const Icon I_ButtonDown_7x4;
+extern const Icon I_ButtonRight_4x7;
+extern const Icon I_ButtonCenter_7x7;
+extern const Icon I_ButtonUp_7x4;
+extern const Icon I_DolphinOkay_41x43;
 extern const Icon I_DolphinFirstStart4_67x53;
 extern const Icon I_DolphinFirstStart4_67x53;
+extern const Icon I_DolphinFirstStart2_59x51;
 extern const Icon I_DolphinFirstStart5_54x49;
 extern const Icon I_DolphinFirstStart5_54x49;
+extern const Icon I_DolphinFirstStart0_70x53;
 extern const Icon I_DolphinFirstStart6_58x54;
 extern const Icon I_DolphinFirstStart6_58x54;
-extern const Icon I_DolphinFirstStart7_61x51;
+extern const Icon I_DolphinFirstStart1_59x53;
 extern const Icon I_DolphinFirstStart8_56x51;
 extern const Icon I_DolphinFirstStart8_56x51;
-extern const Icon I_DolphinOkay_41x43;
+extern const Icon I_DolphinFirstStart7_61x51;
 extern const Icon I_Flipper_young_80x60;
 extern const Icon I_Flipper_young_80x60;
-extern const Icon I_DoorLeft_70x55;
-extern const Icon I_DoorLeft_8x56;
+extern const Icon I_DolphinFirstStart3_57x48;
+extern const Icon I_PassportBottom_128x17;
 extern const Icon I_DoorLocked_10x56;
 extern const Icon I_DoorLocked_10x56;
+extern const Icon I_DoorLeft_70x55;
+extern const Icon I_PassportLeft_6x47;
 extern const Icon I_DoorRight_70x55;
 extern const Icon I_DoorRight_70x55;
-extern const Icon I_DoorRight_8x56;
 extern const Icon I_LockPopup_100x49;
 extern const Icon I_LockPopup_100x49;
-extern const Icon I_PassportBottom_128x17;
-extern const Icon I_PassportLeft_6x47;
-extern const Icon I_Back_15x10;
-extern const Icon I_Down_25x27;
-extern const Icon I_Down_hvr_25x27;
-extern const Icon I_Fill_marker_7x7;
-extern const Icon I_IrdaArrowDown_4x8;
-extern const Icon I_IrdaArrowUp_4x8;
-extern const Icon I_IrdaLearnShort_128x31;
-extern const Icon I_IrdaLearn_128x64;
-extern const Icon I_IrdaSendShort_128x34;
-extern const Icon I_IrdaSend_128x64;
 extern const Icon I_Mute_25x27;
 extern const Icon I_Mute_25x27;
-extern const Icon I_Mute_hvr_25x27;
-extern const Icon I_Power_25x27;
-extern const Icon I_Power_hvr_25x27;
-extern const Icon I_Up_25x27;
+extern const Icon I_IrdaArrowUp_4x8;
 extern const Icon I_Up_hvr_25x27;
 extern const Icon I_Up_hvr_25x27;
+extern const Icon I_Mute_hvr_25x27;
 extern const Icon I_Vol_down_25x27;
 extern const Icon I_Vol_down_25x27;
+extern const Icon I_Down_25x27;
+extern const Icon I_Power_hvr_25x27;
+extern const Icon I_IrdaLearnShort_128x31;
+extern const Icon I_IrdaArrowDown_4x8;
 extern const Icon I_Vol_down_hvr_25x27;
 extern const Icon I_Vol_down_hvr_25x27;
+extern const Icon I_IrdaLearn_128x64;
+extern const Icon I_Down_hvr_25x27;
+extern const Icon I_Fill_marker_7x7;
+extern const Icon I_Power_25x27;
 extern const Icon I_Vol_up_25x27;
 extern const Icon I_Vol_up_25x27;
+extern const Icon I_Up_25x27;
+extern const Icon I_Back_15x10;
+extern const Icon I_IrdaSend_128x64;
+extern const Icon I_IrdaSendShort_128x34;
 extern const Icon I_Vol_up_hvr_25x27;
 extern const Icon I_Vol_up_hvr_25x27;
+extern const Icon I_KeySave_24x11;
 extern const Icon I_KeyBackspaceSelected_16x9;
 extern const Icon I_KeyBackspaceSelected_16x9;
-extern const Icon I_KeyBackspace_16x9;
 extern const Icon I_KeySaveSelected_24x11;
 extern const Icon I_KeySaveSelected_24x11;
-extern const Icon I_KeySave_24x11;
+extern const Icon I_KeyBackspace_16x9;
 extern const Icon A_125khz_14;
 extern const Icon A_125khz_14;
 extern const Icon A_Bluetooth_14;
 extern const Icon A_Bluetooth_14;
 extern const Icon A_Debug_14;
 extern const Icon A_Debug_14;
@@ -81,43 +81,43 @@ extern const Icon A_U2F_14;
 extern const Icon A_iButton_14;
 extern const Icon A_iButton_14;
 extern const Icon I_Detailed_chip_17x13;
 extern const Icon I_Detailed_chip_17x13;
 extern const Icon I_Medium_chip_22x21;
 extern const Icon I_Medium_chip_22x21;
-extern const Icon I_BatteryBody_52x28;
-extern const Icon I_Battery_16x16;
+extern const Icon I_Health_16x16;
 extern const Icon I_FaceCharging_29x14;
 extern const Icon I_FaceCharging_29x14;
-extern const Icon I_FaceConfused_29x14;
+extern const Icon I_BatteryBody_52x28;
+extern const Icon I_Voltage_16x16;
+extern const Icon I_Temperature_16x16;
 extern const Icon I_FaceNopower_29x14;
 extern const Icon I_FaceNopower_29x14;
 extern const Icon I_FaceNormal_29x14;
 extern const Icon I_FaceNormal_29x14;
-extern const Icon I_Health_16x16;
-extern const Icon I_Temperature_16x16;
-extern const Icon I_Voltage_16x16;
+extern const Icon I_Battery_16x16;
+extern const Icon I_FaceConfused_29x14;
+extern const Icon I_RFIDDolphinSuccess_108x57;
 extern const Icon I_RFIDBigChip_37x36;
 extern const Icon I_RFIDBigChip_37x36;
-extern const Icon I_RFIDDolphinReceive_97x61;
 extern const Icon I_RFIDDolphinSend_97x61;
 extern const Icon I_RFIDDolphinSend_97x61;
-extern const Icon I_RFIDDolphinSuccess_108x57;
-extern const Icon I_SDError_43x35;
+extern const Icon I_RFIDDolphinReceive_97x61;
 extern const Icon I_SDQuestion_35x43;
 extern const Icon I_SDQuestion_35x43;
+extern const Icon I_SDError_43x35;
 extern const Icon I_Cry_dolph_55x52;
 extern const Icon I_Cry_dolph_55x52;
-extern const Icon I_Background_128x11;
-extern const Icon I_Background_128x8;
 extern const Icon I_BadUsb_9x8;
 extern const Icon I_BadUsb_9x8;
-extern const Icon I_Battery_19x8;
-extern const Icon I_Battery_26x8;
-extern const Icon I_Bluetooth_5x8;
+extern const Icon I_PlaceholderR_30x13;
+extern const Icon I_Background_128x8;
 extern const Icon I_Lock_8x8;
 extern const Icon I_Lock_8x8;
+extern const Icon I_Battery_26x8;
 extern const Icon I_PlaceholderL_11x13;
 extern const Icon I_PlaceholderL_11x13;
-extern const Icon I_PlaceholderR_30x13;
-extern const Icon I_SDcardFail_11x8;
+extern const Icon I_Battery_19x8;
 extern const Icon I_SDcardMounted_11x8;
 extern const Icon I_SDcardMounted_11x8;
+extern const Icon I_SDcardFail_11x8;
 extern const Icon I_USBConnected_15x8;
 extern const Icon I_USBConnected_15x8;
-extern const Icon I_Lock_7x8;
-extern const Icon I_MHz_25x11;
-extern const Icon I_Quest_7x8;
+extern const Icon I_Bluetooth_5x8;
+extern const Icon I_Background_128x11;
 extern const Icon I_Scanning_123x52;
 extern const Icon I_Scanning_123x52;
+extern const Icon I_Quest_7x8;
 extern const Icon I_Unlock_7x8;
 extern const Icon I_Unlock_7x8;
-extern const Icon I_DolphinExcited_64x63;
+extern const Icon I_MHz_25x11;
+extern const Icon I_Lock_7x8;
 extern const Icon I_DolphinMafia_115x62;
 extern const Icon I_DolphinMafia_115x62;
-extern const Icon I_DolphinNice_96x59;
-extern const Icon I_DolphinWait_61x59;
+extern const Icon I_DolphinExcited_64x63;
 extern const Icon I_iButtonDolphinSuccess_109x60;
 extern const Icon I_iButtonDolphinSuccess_109x60;
 extern const Icon I_iButtonDolphinVerySuccess_108x52;
 extern const Icon I_iButtonDolphinVerySuccess_108x52;
 extern const Icon I_iButtonKey_49x44;
 extern const Icon I_iButtonKey_49x44;
+extern const Icon I_DolphinNice_96x59;
+extern const Icon I_DolphinWait_61x59;

BIN
assets/icons/Common/ButtonDown_7x4.png


BIN
assets/icons/Common/ButtonUp_7x4.png


BIN
assets/icons/Interface/DoorLeft_8x56.png


BIN
assets/icons/Interface/DoorRight_8x56.png


Некоторые файлы не были показаны из-за большого количества измененных файлов