Browse Source

change menu items order

marinofaggiana 4 years ago
parent
commit
eca7f57dcb

+ 5 - 3
iOSClient/Main/Colleaction Common/NCCollectionCommon.swift

@@ -362,18 +362,20 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
             delete = UIMenu(title: NSLocalizedString("_delete_folder_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmFile])
         }
         
+        // ------ MENU -----
+        
         if metadata.directory {
              return UIMenu(title: "", children: [detail, moveCopy, delete])
         }
         
-        var children: [UIMenuElement] = [detail, moveCopy, open, copy, delete]
+        var children: [UIMenuElement] = [detail, open, moveCopy, copy, delete]
 
         if metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileVideo {
-            children.insert(save, at: 4)
+            children.insert(save, at: 2)
         }
         
         if enableViewInFolder {
-            children.insert(viewInFolder, at: 2)
+            children.insert(viewInFolder, at: 5)
         }
         
         return UIMenu(title: "", image: nil, identifier: nil, children: children)

+ 84 - 82
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -121,6 +121,21 @@ extension NCCollectionViewCommon {
             )
         )
         
+        //
+        // DETAIL
+        //
+        if !isFolderEncrypted && !appDelegate.disableSharesView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_details_", comment: ""),
+                    icon: UIImage(named: "details")!.image(color: NCBrandColor.shared.icon, size: 50),
+                    action: { menuAction in
+                        NCNetworkingNotificationCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 0)
+                    }
+                )
+            )
+        }
+        
         //
         // OFFLINE
         //
@@ -154,15 +169,46 @@ extension NCCollectionViewCommon {
         }
         
         //
-        // DETAIL
+        // OPEN IN
         //
-        if !isFolderEncrypted && !appDelegate.disableSharesView {
+        if !metadata.directory && !NCBrandOptions.shared.disable_openin_file {
             actions.append(
                 NCMenuAction(
-                    title: NSLocalizedString("_details_", comment: ""),
-                    icon: UIImage(named: "details")!.image(color: NCBrandColor.shared.icon, size: 50),
+                    title: NSLocalizedString("_open_in_", comment: ""),
+                    icon: UIImage(named: "openFile")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
-                        NCNetworkingNotificationCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 0)
+                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: NCBrandGlobal.shared.selectorOpenIn)
+                    }
+                )
+            )
+        }
+        
+        //
+        // SAVE
+        //
+        if metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileVideo {
+            var title: String = NSLocalizedString("_save_selected_files_", comment: "")
+            var icon = UIImage(named: "saveSelectedFiles")!.image(color: NCBrandColor.shared.icon, size: 50)
+            let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
+            if metadataMOV != nil {
+                title = NSLocalizedString("_livephoto_save_", comment: "")
+                icon = UIImage(named: "livePhoto")!.image(color: NCBrandColor.shared.icon, size: 50)
+            }
+            
+            actions.append(
+                NCMenuAction(
+                    title: title,
+                    icon: icon,
+                    action: { menuAction in
+                        if metadataMOV != nil {
+                            NCCollectionCommon.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
+                        } else {
+                            if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
+                                NCCollectionCommon.shared.saveAlbum(metadata: metadata)
+                            } else {
+                                NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorSaveAlbum)
+                            }
+                        }
                     }
                 )
             )
@@ -220,80 +266,36 @@ extension NCCollectionViewCommon {
         }
         
         //
-        // VIEW IN FOLDER
-        //
-        if layoutKey == NCBrandGlobal.shared.layoutViewRecent && appDelegate.activeFileViewInFolder == nil {
-            actions.append(
-                NCMenuAction(
-                    title: NSLocalizedString("_view_in_folder_", comment: ""),
-                    icon: UIImage(named: "viewInFolder")!.image(color: NCBrandColor.shared.icon, size: 50),
-                    action: { menuAction in
-                        NCCollectionCommon.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName)
-                    }
-                )
-            )
-        }
-        
-        //
-        // OPEN IN
+        // COPY
         //
-        if !metadata.directory && !NCBrandOptions.shared.disable_openin_file {
+        if !metadata.directory {
             actions.append(
                 NCMenuAction(
-                    title: NSLocalizedString("_open_in_", comment: ""),
-                    icon: UIImage(named: "openFile")!.image(color: NCBrandColor.shared.icon, size: 50),
+                    title: NSLocalizedString("_copy_file_", comment: ""),
+                    icon: UIImage(named: "copy")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
-                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: NCBrandGlobal.shared.selectorOpenIn)
+                        self.appDelegate.pasteboardOcIds = [metadata.ocId];
+                        NCCollectionCommon.shared.copyPasteboard()
                     }
                 )
             )
         }
         
         //
-        // SAVE
+        // VIEW IN FOLDER
         //
-        if metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileVideo {
-            var title: String = NSLocalizedString("_save_selected_files_", comment: "")
-            var icon = UIImage(named: "saveSelectedFiles")!.image(color: NCBrandColor.shared.icon, size: 50)
-            let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
-            if metadataMOV != nil {
-                title = NSLocalizedString("_livephoto_save_", comment: "")
-                icon = UIImage(named: "livePhoto")!.image(color: NCBrandColor.shared.icon, size: 50)
-            }
-            
+        if layoutKey == NCBrandGlobal.shared.layoutViewRecent && appDelegate.activeFileViewInFolder == nil {
             actions.append(
                 NCMenuAction(
-                    title: title,
-                    icon: icon,
+                    title: NSLocalizedString("_view_in_folder_", comment: ""),
+                    icon: UIImage(named: "viewInFolder")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
-                        if metadataMOV != nil {
-                            NCCollectionCommon.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
-                        } else {
-                            if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-                                NCCollectionCommon.shared.saveAlbum(metadata: metadata)
-                            } else {
-                                NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorSaveAlbum)
-                            }
-                        }
+                        NCCollectionCommon.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName)
                     }
                 )
             )
         }
         
-        //
-        // COPY
-        //
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_copy_file_", comment: ""),
-                icon: UIImage(named: "copy")!.image(color: NCBrandColor.shared.icon, size: 50),
-                action: { menuAction in
-                    self.appDelegate.pasteboardOcIds = [metadata.ocId];
-                    NCCollectionCommon.shared.copyPasteboard()
-                }
-            )
-        )
-        
         //
         // DELETE
         //
@@ -398,28 +400,6 @@ extension NCCollectionViewCommon {
             )
         )
         
-        //
-        // COPY - MOVE
-        //
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_move_or_copy_selected_files_", comment: ""),
-                icon: UIImage(named: "move")!.image(color: NCBrandColor.shared.icon, size: 50),
-                action: { menuAction in
-                    var meradatasSelect = [tableMetadata]()
-                    for ocId in selectOcId {
-                        if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
-                            meradatasSelect.append(metadata)
-                        }
-                    }
-                    if meradatasSelect.count > 0 {
-                        NCCollectionCommon.shared.openSelectView(items: meradatasSelect, viewController: self)
-                    }
-                    self.tapSelect(sender: self)
-                }
-            )
-        )
-        
         //
         // SAVE TO PHOTO GALLERY
         //
@@ -448,6 +428,28 @@ extension NCCollectionViewCommon {
             )
         )
         
+        //
+        // COPY - MOVE
+        //
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_move_or_copy_selected_files_", comment: ""),
+                icon: UIImage(named: "move")!.image(color: NCBrandColor.shared.icon, size: 50),
+                action: { menuAction in
+                    var meradatasSelect = [tableMetadata]()
+                    for ocId in selectOcId {
+                        if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                            meradatasSelect.append(metadata)
+                        }
+                    }
+                    if meradatasSelect.count > 0 {
+                        NCCollectionCommon.shared.openSelectView(items: meradatasSelect, viewController: self)
+                    }
+                    self.tapSelect(sender: self)
+                }
+            )
+        )
+        
         //
         // COPY
         //

+ 62 - 62
iOSClient/Main/Menu/NCViewer+Menu.swift

@@ -81,6 +81,21 @@ extension NCViewer {
             )
         )
         
+        //
+        // DETAIL
+        //
+        if !appDelegate.disableSharesView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_details_", comment: ""),
+                    icon: UIImage(named: "details")!.image(color: NCBrandColor.shared.icon, size: 50),
+                    action: { menuAction in
+                        NCNetworkingNotificationCenter.shared.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+                    }
+                )
+            )
+        }
+        
         //
         // OFFLINE
         //
@@ -102,15 +117,43 @@ extension NCViewer {
         }
         
         //
-        // DETAIL
+        // OPEN IN
         //
-        if !appDelegate.disableSharesView {
+        if metadata.session == "" && !webView {
             actions.append(
                 NCMenuAction(
-                    title: NSLocalizedString("_details_", comment: ""),
-                    icon: UIImage(named: "details")!.image(color: NCBrandColor.shared.icon, size: 50),
+                    title: NSLocalizedString("_open_in_", comment: ""),
+                    icon: UIImage(named: "openFile")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
-                        NCNetworkingNotificationCenter.shared.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: NCBrandGlobal.shared.selectorOpenIn)
+                    }
+                )
+            )
+        }
+        
+        //
+        // SAVE IMAGE / VIDEO
+        //
+        if metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileVideo {
+            
+            var title: String = NSLocalizedString("_save_selected_files_", comment: "")
+            var icon = UIImage(named: "saveSelectedFiles")!.image(color: NCBrandColor.shared.icon, size: 50)
+            let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
+            if metadataMOV != nil {
+                title = NSLocalizedString("_livephoto_save_", comment: "")
+                icon = UIImage(named: "livePhoto")!.image(color: NCBrandColor.shared.icon, size: 50)
+            }
+            
+            actions.append(
+                NCMenuAction(
+                    title: title,
+                    icon: icon,
+                    action: { menuAction in
+                        if metadataMOV != nil {
+                            NCCollectionCommon.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
+                        } else {
+                            NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorSaveAlbum)
+                        }
                     }
                 )
             )
@@ -179,6 +222,20 @@ extension NCViewer {
             )
         }
         
+        //
+        // COPY
+        //
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_copy_file_", comment: ""),
+                icon: UIImage(named: "copy")!.image(color: NCBrandColor.shared.icon, size: 50),
+                action: { menuAction in
+                    self.appDelegate.pasteboardOcIds = [metadata.ocId];
+                    NCCollectionCommon.shared.copyPasteboard()
+                }
+            )
+        )
+        
         //
         // VIEW IN FOLDER
         //
@@ -196,21 +253,6 @@ extension NCViewer {
             }
         }
         
-        //
-        // OPEN IN
-        //
-        if metadata.session == "" && !webView {
-            actions.append(
-                NCMenuAction(
-                    title: NSLocalizedString("_open_in_", comment: ""),
-                    icon: UIImage(named: "openFile")!.image(color: NCBrandColor.shared.icon, size: 50),
-                    action: { menuAction in
-                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: NCBrandGlobal.shared.selectorOpenIn)
-                    }
-                )
-            )
-        }
-        
         //
         // DOWNLOAD IMAGE MAX RESOLUTION
         //
@@ -228,34 +270,6 @@ extension NCViewer {
             }
         }
         
-        //
-        // SAVE IMAGE / VIDEO
-        //
-        if metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCBrandGlobal.shared.metadataTypeFileVideo {
-            
-            var title: String = NSLocalizedString("_save_selected_files_", comment: "")
-            var icon = UIImage(named: "saveSelectedFiles")!.image(color: NCBrandColor.shared.icon, size: 50)
-            let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
-            if metadataMOV != nil {
-                title = NSLocalizedString("_livephoto_save_", comment: "")
-                icon = UIImage(named: "livePhoto")!.image(color: NCBrandColor.shared.icon, size: 50)
-            }
-            
-            actions.append(
-                NCMenuAction(
-                    title: title,
-                    icon: icon,
-                    action: { menuAction in
-                        if metadataMOV != nil {
-                            NCCollectionCommon.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
-                        } else {
-                            NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorSaveAlbum)
-                        }
-                    }
-                )
-            )
-        }
-        
         //
         // PDF
         //
@@ -271,20 +285,6 @@ extension NCViewer {
             )
         }
         
-        //
-        // COPY
-        //
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_copy_file_", comment: ""),
-                icon: UIImage(named: "copy")!.image(color: NCBrandColor.shared.icon, size: 50),
-                action: { menuAction in
-                    self.appDelegate.pasteboardOcIds = [metadata.ocId];
-                    NCCollectionCommon.shared.copyPasteboard()
-                }
-            )
-        )
-        
         //
         // DELETE
         //