marinofaggiana před 4 roky
rodič
revize
e7c7f4ca41

+ 4 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -22,7 +22,6 @@
 		3757A35523D9D76300EC369E /* NCMenuPanelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3757A35423D9D76300EC369E /* NCMenuPanelController.swift */; };
 		3781B9B023DB2B7E006B4B1D /* AppDelegate+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3781B9AF23DB2B7E006B4B1D /* AppDelegate+Menu.swift */; };
 		3781B9B223DB2B9F006B4B1D /* CCMain+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3781B9B123DB2B9F006B4B1D /* CCMain+Menu.swift */; };
-		3781B9B423DB2BC9006B4B1D /* NCFavorite+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3781B9B323DB2BC9006B4B1D /* NCFavorite+Menu.swift */; };
 		37C83A0D24532B7200618A3B /* AppDelegate+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37C83A0C24532B7200618A3B /* AppDelegate+Swift.swift */; };
 		37C83A0F24532BA600618A3B /* CCMain+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37C83A0E24532BA600618A3B /* CCMain+Swift.swift */; };
 		37ECC83B23D0C7410082EFA2 /* NCMenuAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37ECC83A23D0C7400082EFA2 /* NCMenuAction.swift */; };
@@ -175,6 +174,7 @@
 		F774DF0F1FCC26BE002AF9FC /* iTunesArtwork@1x.png in Resources */ = {isa = PBXBuildFile; fileRef = F774DF0C1FCC26BD002AF9FC /* iTunesArtwork@1x.png */; };
 		F774DF101FCC26BE002AF9FC /* iTunesArtwork@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F774DF0D1FCC26BD002AF9FC /* iTunesArtwork@2x.png */; };
 		F774DF111FCC26BE002AF9FC /* iTunesArtwork@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F774DF0E1FCC26BE002AF9FC /* iTunesArtwork@3x.png */; };
+		F77A697D250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */; };
 		F77B0DF21D118A16002130FE /* CCUploadFromOtherUpp.m in Sources */ = {isa = PBXBuildFile; fileRef = F7956FCA1B4886E60085DEA3 /* CCUploadFromOtherUpp.m */; };
 		F77B0DF41D118A16002130FE /* CCMain.m in Sources */ = {isa = PBXBuildFile; fileRef = F70211FB1BAC56E9003FC03E /* CCMain.m */; };
 		F77B0DF51D118A16002130FE /* CCUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = F7053E3D1C639DF500741EA5 /* CCUtility.m */; };
@@ -211,7 +211,6 @@
 		F787704F22E7019900F287A9 /* NCShareLinkCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F787704E22E7019900F287A9 /* NCShareLinkCell.xib */; };
 		F78A18B623CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B523CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift */; };
 		F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */; };
-		F78A807A25095B3D006D2193 /* NCOffline+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A807925095B3C006D2193 /* NCOffline+Menu.swift */; };
 		F78AA20621F783E900D0F205 /* SwiftRichString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F78AA20521F783E900D0F205 /* SwiftRichString.framework */; };
 		F78ACD4021903CC20088454D /* NCGridCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD3F21903CC20088454D /* NCGridCell.swift */; };
 		F78ACD4221903CE00088454D /* NCListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD4121903CE00088454D /* NCListCell.swift */; };
@@ -361,7 +360,6 @@
 		3757A35423D9D76300EC369E /* NCMenuPanelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMenuPanelController.swift; sourceTree = "<group>"; };
 		3781B9AF23DB2B7E006B4B1D /* AppDelegate+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Menu.swift"; sourceTree = "<group>"; };
 		3781B9B123DB2B9F006B4B1D /* CCMain+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CCMain+Menu.swift"; sourceTree = "<group>"; };
-		3781B9B323DB2BC9006B4B1D /* NCFavorite+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCFavorite+Menu.swift"; sourceTree = "<group>"; };
 		37C83A0C24532B7200618A3B /* AppDelegate+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Swift.swift"; sourceTree = "<group>"; };
 		37C83A0E24532BA600618A3B /* CCMain+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CCMain+Swift.swift"; sourceTree = "<group>"; };
 		37ECC83A23D0C7400082EFA2 /* NCMenuAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMenuAction.swift; sourceTree = "<group>"; };
@@ -554,6 +552,7 @@
 		F774DF0E1FCC26BE002AF9FC /* iTunesArtwork@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "iTunesArtwork@3x.png"; sourceTree = "<group>"; };
 		F777F0301C29717F00CE81CB /* PHAsset+Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PHAsset+Utility.h"; sourceTree = "<group>"; };
 		F777F0311C29717F00CE81CB /* PHAsset+Utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PHAsset+Utility.m"; sourceTree = "<group>"; };
+		F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+Menu.swift"; sourceTree = "<group>"; };
 		F77D49A71DC238E500CDC568 /* loading.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = loading.gif; sourceTree = "<group>"; };
 		F78071071EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+MainThread.h"; sourceTree = "<group>"; };
 		F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNotificationCenter+MainThread.m"; sourceTree = "<group>"; };
@@ -562,7 +561,6 @@
 		F787704E22E7019900F287A9 /* NCShareLinkCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareLinkCell.xib; sourceTree = "<group>"; };
 		F78A18B523CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkspaceWebView.swift; sourceTree = "<group>"; };
 		F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkspace.swift; sourceTree = "<group>"; };
-		F78A807925095B3C006D2193 /* NCOffline+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCOffline+Menu.swift"; sourceTree = "<group>"; };
 		F78AA20521F783E900D0F205 /* SwiftRichString.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftRichString.framework; path = Carthage/Build/iOS/SwiftRichString.framework; sourceTree = "<group>"; };
 		F78ACD3F21903CC20088454D /* NCGridCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCGridCell.swift; sourceTree = "<group>"; };
 		F78ACD4121903CE00088454D /* NCListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCListCell.swift; sourceTree = "<group>"; };
@@ -797,8 +795,7 @@
 			isa = PBXGroup;
 			children = (
 				3781B9AF23DB2B7E006B4B1D /* AppDelegate+Menu.swift */,
-				3781B9B323DB2BC9006B4B1D /* NCFavorite+Menu.swift */,
-				F78A807925095B3C006D2193 /* NCOffline+Menu.swift */,
+				F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */,
 				3781B9B123DB2B9F006B4B1D /* CCMain+Menu.swift */,
 				F7CBC31B24F78E79004D3812 /* NCSortMenu.swift */,
 				F710D2012405826100A6033D /* NCDetailNavigationController+Menu.swift */,
@@ -2011,6 +2008,7 @@
 				F77B0E1B1D118A16002130FE /* CCGraphics.m in Sources */,
 				F710D2022405826100A6033D /* NCDetailNavigationController+Menu.swift in Sources */,
 				3757A35523D9D76300EC369E /* NCMenuPanelController.swift in Sources */,
+				F77A697D250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift in Sources */,
 				F7CA1ED320E7E3FE002CC65E /* PKStopDownloadButton.m in Sources */,
 				F704B5E92430C0B800632F5F /* NCCreateFormUploadConflictCell.swift in Sources */,
 				F72D404923D2082500A97FD0 /* NCViewerNextcloudText.swift in Sources */,
@@ -2075,7 +2073,6 @@
 				F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */,
 				F7E0E1DC22327885006B0911 /* NCAudioRecorderViewController.swift in Sources */,
 				F70CAE3A1F8CF31A008125FD /* NCEndToEndEncryption.m in Sources */,
-				3781B9B423DB2BC9006B4B1D /* NCFavorite+Menu.swift in Sources */,
 				F710D1F924057C9D00A6033D /* NCDetailViewController.swift in Sources */,
 				F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */,
 				F7B2DEF01F976854007CF4D2 /* NYMnemonic.m in Sources */,
@@ -2083,7 +2080,6 @@
 				F7BAADCB1ED5A87C00B7EAD4 /* NCManageDatabase.swift in Sources */,
 				F79018B9240962C7007C9B6D /* NCViewerImageContentTransformers.swift in Sources */,
 				F70968A424212C4E00ED60E5 /* NCLivePhoto.swift in Sources */,
-				F78A807A25095B3D006D2193 /* NCOffline+Menu.swift in Sources */,
 				F704FA5C232A343F00BBA952 /* IMImagemeterViewer.swift in Sources */,
 				370D26B1248A3E1A00121797 /* CCCellMain.swift in Sources */,
 				F7CA1ED220E7E3FE002CC65E /* PKCircleView.m in Sources */,

+ 0 - 12
iOSClient/Favorites/NCFavorite.swift

@@ -51,18 +51,6 @@ class NCFavorite: NCCollectionViewCommon  {
         return NSAttributedString.init(string: text, attributes: attributes)
     }
 
-    override func tapMoreGridItem(with objectId: String, namedButtonMore: String, sender: Any) {
-        
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", objectId)) else { return }
-        guard let tabBarController = self.tabBarController else { return }
-
-        if namedButtonMore == "more" {
-            toggleMoreMenu(viewController: tabBarController, metadata: metadata)
-        } else if namedButtonMore == "stop" {
-            NCMainCommon.shared.cancelTransferMetadata(metadata, uploadStatusForcedStart: false)
-        }
-    }
-    
     // MARK: - Collection View
     
     override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

+ 25 - 3
iOSClient/Main/Menu/NCFavorite+Menu.swift → iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -1,5 +1,5 @@
 //
-//  NCFavorite+Menu.swift
+//  NCCollectionViewCommon+Menu.swift
 //  Nextcloud
 //
 //  Created by Philippe Weidmann on 24.01.20.
@@ -25,7 +25,7 @@
 
 import FloatingPanel
 
-extension NCFavorite {
+extension NCCollectionViewCommon {
 
     func toggleMoreMenu(viewController: UIViewController, metadata: tableMetadata) {
         
@@ -68,7 +68,8 @@ extension NCFavorite {
             )
         )
 
-        if serverUrl == "" {
+        // Favorite
+        if layoutKey == k_layout_view_favorite && serverUrl == "" {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_remove_favorites_", comment: ""),
@@ -79,7 +80,26 @@ extension NCFavorite {
                 )
             )
         }
+        
+        // Offline
+        if layoutKey == k_layout_view_offline && self.serverUrl == "" {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_remove_available_offline_", comment: ""),
+                    icon: CCGraphics.changeThemingColorImage(UIImage(named: "offline"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                    action: { menuAction in
+                        if metadata.directory {
+                            NCManageDatabase.sharedInstance.setDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!, offline: false, account: self.appDelegate.account)
+                        } else {
+                            NCManageDatabase.sharedInstance.setLocalFile(ocId: metadata.ocId, offline: false)
+                        }
+                        self.reloadDataSource()
+                    }
+                )
+            )
+        }
 
+        // All
         actions.append(
             NCMenuAction(
                 title: NSLocalizedString("_details_", comment: ""),
@@ -102,6 +122,7 @@ extension NCFavorite {
             )
         }
 
+        /*
         if !isFolderEncrypted && serverUrl != "" {
             actions.append(
                 NCMenuAction(
@@ -113,6 +134,7 @@ extension NCFavorite {
                 )
             )
         }
+        */
         
         actions.append(
             NCMenuAction(

+ 0 - 101
iOSClient/Main/Menu/NCOffline+Menu.swift

@@ -1,101 +0,0 @@
-//
-//  NCOffline+Menu.swift
-//  Nextcloud
-//
-//  Created by Philippe Weidmann on 24.01.20.
-//  Copyright © 2020 Philippe Weidmann. All rights reserved.
-//  Copyright © 2020 Marino Faggiana All rights reserved.
-//
-//  Author Philippe Weidmann
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-import FloatingPanel
-
-extension NCOffline {
-
-    func toggleMoreMenu(viewController: UIViewController, metadata: tableMetadata) {
-        
-        if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
-            
-            let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateViewController(withIdentifier: "NCMainMenuTableViewController") as! NCMainMenuTableViewController
-            mainMenuViewController.actions = self.initMoreMenu(metadata: metadata, viewController: viewController)
-
-            let menuPanelController = NCMenuPanelController()
-            menuPanelController.parentPresenter = viewController
-            menuPanelController.delegate = mainMenuViewController
-            menuPanelController.set(contentViewController: mainMenuViewController)
-            menuPanelController.track(scrollView: mainMenuViewController.tableView)
-
-            viewController.present(menuPanelController, animated: true, completion: nil)
-        }
-    }
-    
-    private func initMoreMenu(metadata: tableMetadata, viewController: UIViewController) -> [NCMenuAction] {
-        var actions = [NCMenuAction]()
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl+"/"+metadata.fileName, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase)
-        
-        var iconHeader: UIImage!
-        if let icon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
-            iconHeader = icon
-        } else {
-            if metadata.directory {
-                iconHeader = CCGraphics.changeThemingColorImage(UIImage(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)
-            } else {
-                iconHeader = UIImage(named: metadata.iconName)
-            }
-        }
-
-        actions.append(
-            NCMenuAction(
-                title: metadata.fileNameView,
-                icon: iconHeader,
-                action: nil
-            )
-        )
-
-        if self.serverUrl == "" {
-            actions.append(
-                NCMenuAction(
-                    title: NSLocalizedString("_remove_available_offline_", comment: ""),
-                    icon: CCGraphics.changeThemingColorImage(UIImage(named: "offline"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
-                    action: { menuAction in
-                        if metadata.directory {
-                            NCManageDatabase.sharedInstance.setDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!, offline: false, account: self.appDelegate.account)
-                        } else {
-                            NCManageDatabase.sharedInstance.setLocalFile(ocId: metadata.ocId, offline: false)
-                        }
-                        self.reloadDataSource()
-                    }
-                )
-            )
-        }
-        
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_details_", comment: ""),
-                icon: CCGraphics.changeThemingColorImage(UIImage(named: "details"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
-                action: { menuAction in
-                    NCMainCommon.shared.openShare(ViewController: self, metadata: metadata, indexPage: 0)
-                }
-            )
-        )
-
-        return actions
-    }
-}
-

+ 9 - 1
iOSClient/Main/NCCollectionCommon.swift

@@ -869,7 +869,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCL
     
     func tapShareListItem(with objectId: String, sender: Any) {
         
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", objectId)) else {
+        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else {
             return
         }
         
@@ -878,6 +878,14 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCL
         
     func tapMoreGridItem(with objectId: String, namedButtonMore: String, sender: Any) {
         
+        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
+        guard let tabBarController = self.tabBarController else { return }
+
+        if namedButtonMore == "more" {
+            toggleMoreMenu(viewController: tabBarController, metadata: metadata)
+        } else if namedButtonMore == "stop" {
+            NCMainCommon.shared.cancelTransferMetadata(metadata, uploadStatusForcedStart: false)
+        }
     }
     
     // MARK: SEGUE

+ 0 - 12
iOSClient/Offline/NCOffline.swift

@@ -45,18 +45,6 @@ class NCOffline: NCCollectionViewCommon  {
         return NSAttributedString.init(string: text, attributes: attributes)
     }
         
-    override func tapMoreGridItem(with objectId: String, namedButtonMore: String, sender: Any) {
-        
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
-        guard let tabBarController = self.tabBarController else { return }
-
-        if namedButtonMore == "more" {
-            toggleMoreMenu(viewController: tabBarController, metadata: metadata)
-        } else if namedButtonMore == "stop" {
-            NCMainCommon.shared.cancelTransferMetadata(metadata, uploadStatusForcedStart: false)
-        }
-    }
-    
     // MARK: SEGUE
     
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {