Browse Source

improved code

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
91433b8389

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -251,7 +251,7 @@
 		F75A9EE623796C6F0044CFCE /* NCNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75A9EE523796C6F0044CFCE /* NCNetworking.swift */; };
 		F75A9EE723796C6F0044CFCE /* NCNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75A9EE523796C6F0044CFCE /* NCNetworking.swift */; };
 		F75AC2431F1F62450073EC19 /* NCManageAutoUploadFileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75AC2421F1F62450073EC19 /* NCManageAutoUploadFileName.swift */; };
-		F75B0ABD244C4DBB00E58DCA /* NCFunctionCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75B0ABC244C4DBB00E58DCA /* NCFunctionCenter.swift */; };
+		F75B0ABD244C4DBB00E58DCA /* NCActionCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75B0ABC244C4DBB00E58DCA /* NCActionCenter.swift */; };
 		F75C0C4823D1FAE300163CC8 /* NCRichWorkspaceCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */; };
 		F75CA1472962F13700B01130 /* HUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75CA1462962F13700B01130 /* HUDView.swift */; };
 		F75CA1482962F13700B01130 /* HUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75CA1462962F13700B01130 /* HUDView.swift */; };
@@ -875,7 +875,7 @@
 		F758B45F212C56A400515F55 /* NCScan.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCScan.swift; sourceTree = "<group>"; };
 		F75A9EE523796C6F0044CFCE /* NCNetworking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCNetworking.swift; sourceTree = "<group>"; };
 		F75AC2421F1F62450073EC19 /* NCManageAutoUploadFileName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCManageAutoUploadFileName.swift; sourceTree = "<group>"; };
-		F75B0ABC244C4DBB00E58DCA /* NCFunctionCenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCFunctionCenter.swift; sourceTree = "<group>"; };
+		F75B0ABC244C4DBB00E58DCA /* NCActionCenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActionCenter.swift; sourceTree = "<group>"; };
 		F75B91E21ECAE17800199C96 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F75B91F71ECAE26300199C96 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F75B923D1ECAE55E00199C96 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -1386,7 +1386,7 @@
 				370D26AE248A3D7A00121797 /* NCCellProtocol.swift */,
 				F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
 				F7682FDF23C36B0500983A04 /* NCMainTabBar.swift */,
-				F75B0ABC244C4DBB00E58DCA /* NCFunctionCenter.swift */,
+				F75B0ABC244C4DBB00E58DCA /* NCActionCenter.swift */,
 				F77444F7222816D5000D5EB0 /* NCPickerViewController.swift */,
 			);
 			path = Main;
@@ -3088,7 +3088,7 @@
 				F71CD6CA2930D7B1006C95C1 /* NCApplicationHandle.swift in Sources */,
 				F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */,
 				F78ACD4021903CC20088454D /* NCGridCell.swift in Sources */,
-				F75B0ABD244C4DBB00E58DCA /* NCFunctionCenter.swift in Sources */,
+				F75B0ABD244C4DBB00E58DCA /* NCActionCenter.swift in Sources */,
 				AF935067276B84E700BD078F /* NCMenu+FloatingPanel.swift in Sources */,
 				F702F2CD25EE5B4F008F8E80 /* AppDelegate.swift in Sources */,
 				F769454022E9F077000A798A /* NCSharePaging.swift in Sources */,

+ 2 - 2
iOSClient/AppDelegate.swift

@@ -571,7 +571,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         self.userId = userId
         self.password = password
 
-        _ = NCFunctionCenter.shared
+        _ = NCActionCenter.shared
 
         NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
         let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
@@ -917,7 +917,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 }
 
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                    NCFunctionCenter.shared.openFileViewInFolder(serverUrl: serverUrl, fileNameBlink: nil, fileNameOpen: fileName)
+                    NCActionCenter.shared.openFileViewInFolder(serverUrl: serverUrl, fileNameBlink: nil, fileNameOpen: fileName)
                 }
             }
             return true

+ 2 - 2
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -891,7 +891,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if isEditMode { return }
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
 
-        NCFunctionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
+        NCActionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
     }
 
     func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {
@@ -989,7 +989,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
 
     @objc func pasteFilesMenu() {
-        NCFunctionCenter.shared.pastePasteboard(serverUrl: serverUrl)
+        NCActionCenter.shared.pastePasteboard(serverUrl: serverUrl)
     }
 
     // MARK: - DataSource + NC Endpoint

+ 57 - 46
iOSClient/Main/NCFunctionCenter.swift → iOSClient/Main/NCActionCenter.swift

@@ -1,5 +1,5 @@
 //
-//  NCFunctionCenter.swift
+//  NCActionCenter.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 19/04/2020.
@@ -28,15 +28,14 @@ import JGProgressHUD
 import SVGKit
 import Photos
 
-@objc class NCFunctionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelectDelegate {
-    @objc public static let shared: NCFunctionCenter = {
-        let instance = NCFunctionCenter()
+@objc class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelectDelegate {
+    @objc public static let shared: NCActionCenter = {
+        let instance = NCActionCenter()
         NotificationCenter.default.addObserver(instance, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadedFile), object: nil)
         NotificationCenter.default.addObserver(instance, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterUploadedFile), object: nil)
         return instance
     }()
 
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var viewerQuickLook: NCViewerQuickLook?
     var documentController: UIDocumentInteractionController?
 
@@ -44,6 +43,7 @@ import Photos
 
     @objc func downloadedFile(_ notification: NSNotification) {
 
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         guard let userInfo = notification.userInfo as NSDictionary?,
               let ocId = userInfo["ocId"] as? String,
               let selector = userInfo["selector"] as? String,
@@ -60,7 +60,6 @@ import Photos
                 } catch { }
                 NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
                 NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId))
-                
             } else {
                 NCContentPresenter.shared.messageNotification("_download_file_", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)
             }
@@ -75,7 +74,7 @@ import Photos
             let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: true, metadata: metadata)
             let navigationController = UINavigationController(rootViewController: viewerQuickLook)
             navigationController.modalPresentationStyle = .fullScreen
-            self.appDelegate.window?.rootViewController?.present(navigationController, animated: true)
+            appDelegate.window?.rootViewController?.present(navigationController, animated: true)
 
         case NCGlobal.shared.selectorLoadFileView:
             guard UIApplication.shared.applicationState == .active else { break }
@@ -85,27 +84,27 @@ import Photos
             } else if metadata.classFile == NKCommon.typeClassFile.compress.rawValue || metadata.classFile == NKCommon.typeClassFile.unknow.rawValue {
                 self.openDocumentController(metadata: metadata)
             } else {
-                if let viewController = self.appDelegate.activeViewController {
+                if let viewController = appDelegate.activeViewController {
                     let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
                     NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: imageIcon)
                 }
             }
-            
+
         case NCGlobal.shared.selectorOpenIn:
             if UIApplication.shared.applicationState == .active {
                 self.openDocumentController(metadata: metadata)
             }
-            
+
         case NCGlobal.shared.selectorLoadOffline:
             NCManageDatabase.shared.setLocalFile(ocId: metadata.ocId, offline: true)
-            
+
         case NCGlobal.shared.selectorPrint:
             // waiting close menu
             // https://github.com/nextcloud/ios/issues/2278
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.printDocument(metadata: metadata)
             }
-            
+
         case NCGlobal.shared.selectorSaveAlbum:
             saveAlbum(metadata: metadata)
 
@@ -140,15 +139,16 @@ import Photos
     }
 
     func setMetadataAvalableOffline(_ metadata: tableMetadata, isOffline: Bool) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         let serverUrl = metadata.serverUrl + "/" + metadata.fileName
         if isOffline {
             if metadata.directory {
-                NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: false, account: self.appDelegate.account)
+                NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: false, account: appDelegate.account)
             } else {
                 NCManageDatabase.shared.setLocalFile(ocId: metadata.ocId, offline: false)
             }
         } else if metadata.directory {
-            NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: true, account: self.appDelegate.account)
+            NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: true, account: appDelegate.account)
             NCOperationQueue.shared.synchronizationMetadata(metadata, selector: NCGlobal.shared.selectorDownloadAllFile)
         } else {
             NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadOffline) { _, _ in }
@@ -162,6 +162,7 @@ import Photos
 
     @objc func uploadedFile(_ notification: NSNotification) {
 
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         guard let userInfo = notification.userInfo as NSDictionary?,
               let error = userInfo["error"] as? NKError,
               let account = userInfo["account"] as? String,
@@ -179,17 +180,19 @@ import Photos
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         NCActivityIndicator.shared.start(backgroundView: viewController.view)
-        NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, queue: .main) { account, metadata, error in
+        NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, queue: .main) { _, metadata, error in
             NCActivityIndicator.shared.stop()
             if let metadata = metadata, error == .success {
-                let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as! UINavigationController
-                let shareViewController = shareNavigationController.topViewController as! NCSharePaging
+                let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as? UINavigationController
+                let shareViewController = shareNavigationController?.topViewController as? NCSharePaging
 
-                shareViewController.metadata = metadata
-                shareViewController.indexPage = indexPage
+                shareViewController?.metadata = metadata
+                shareViewController?.indexPage = indexPage
 
-                shareNavigationController.modalPresentationStyle = .formSheet
-                viewController.present(shareNavigationController, animated: true, completion: nil)
+                shareNavigationController?.modalPresentationStyle = .formSheet
+                if let shareNavigationController = shareNavigationController {
+                    viewController.present(shareNavigationController, animated: true, completion: nil)
+                }
             }
         }
     }
@@ -198,7 +201,8 @@ import Photos
 
     func openDocumentController(metadata: tableMetadata) {
 
-        guard let mainTabBar = self.appDelegate.mainTabBar else { return }
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
+              let mainTabBar = appDelegate.mainTabBar else { return }
         let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
 
         documentController = UIDocumentInteractionController(url: fileURL)
@@ -206,6 +210,7 @@ import Photos
     }
 
     func openActivityViewController(selectedMetadata: [tableMetadata]) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         let metadatas = selectedMetadata.filter({ !$0.directory })
         var items: [URL] = []
@@ -217,7 +222,7 @@ import Photos
             else { downloadMetadata.append((metadata, fileURL)) }
         }
 
-        let processor = ParallelWorker(n: 5, titleKey: "_downloading_", totalTasks: downloadMetadata.count, hudView: self.appDelegate.window?.rootViewController?.view)
+        let processor = ParallelWorker(n: 5, titleKey: "_downloading_", totalTasks: downloadMetadata.count, hudView: appDelegate.window?.rootViewController?.view)
         for (metadata, url) in downloadMetadata {
             processor.execute { completion in
                 NCNetworking.shared.download(metadata: metadata, selector: "", completion: { _, _ in
@@ -228,18 +233,19 @@ import Photos
         }
 
         processor.completeWork {
-            guard !items.isEmpty, let mainTabBar = self.appDelegate.mainTabBar else { return }
+            guard !items.isEmpty, let mainTabBar = appDelegate.mainTabBar else { return }
             let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
             activityViewController.popoverPresentationController?.permittedArrowDirections = .any
             activityViewController.popoverPresentationController?.sourceView = mainTabBar
             activityViewController.popoverPresentationController?.sourceRect = mainTabBar.menuRect
-            self.appDelegate.window?.rootViewController?.present(activityViewController, animated: true)
+            appDelegate.window?.rootViewController?.present(activityViewController, animated: true)
         }
     }
 
     // MARK: - Save as scan
 
     func saveAsScan(metadata: tableMetadata) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
         let fileNameDestination = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)!
@@ -296,6 +302,7 @@ import Photos
     // MARK: - Save photo
 
     func saveAlbum(metadata: tableMetadata) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
 
@@ -313,7 +320,7 @@ import Photos
                     PHPhotoLibrary.shared().performChanges({
                         let assetRequest = PHAssetCreationRequest.forAsset()
                         assetRequest.addResource(with: .photo, data: data, options: nil)
-                    }) { (success, error) in
+                    }) { success, _ in
                         if !success {
                             NCContentPresenter.shared.messageNotification("_save_selected_files_", error: errorSave, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error)
                         }
@@ -321,7 +328,7 @@ import Photos
                 } else if metadata.classFile == NKCommon.typeClassFile.video.rawValue {
                     PHPhotoLibrary.shared().performChanges({
                         PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: URL(fileURLWithPath: fileNamePath))
-                    }) { (success, error) in
+                    }) { success, _ in
                         if !success {
                             NCContentPresenter.shared.messageNotification("_save_selected_files_", error: errorSave, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error)
                         }
@@ -352,11 +359,12 @@ import Photos
     }
 
     func saveLivePhotoToDisk(metadata: tableMetadata, metadataMov: tableMetadata) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         let fileNameImage = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
         let fileNameMov = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadataMov.ocId, fileNameView: metadataMov.fileNameView)!)
         let hud = JGProgressHUD()
-        
+
         hud.indicatorView = JGProgressHUDRingIndicatorView()
         if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
             indicatorView.ringWidth = 1.5
@@ -365,9 +373,7 @@ import Photos
         hud.show(in: (appDelegate.window?.rootViewController?.view)!)
 
         NCLivePhoto.generate(from: fileNameImage, videoURL: fileNameMov, progress: { progress in
-            
             hud.progress = Float(progress)
-
         }, completion: { _, resources in
 
             if resources != nil {
@@ -426,12 +432,14 @@ import Photos
     }
 
     func pastePasteboard(serverUrl: String) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
+
         let parallelizer = ParallelWorker(n: 5, titleKey: "_uploading_", totalTasks: nil, hudView: appDelegate.window?.rootViewController?.view)
 
         func uploadPastePasteboard(fileName: String, serverUrlFileName: String, fileNameLocalPath: String, serverUrl: String, completion: @escaping () -> Void) {
             NextcloudKit.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath) { request in
                 NCNetworking.shared.uploadRequest[fileNameLocalPath] = request
-            } progressHandler: { progress in
+            } progressHandler: { _ in
             } completionHandler: { account, ocId, etag, _, _, _, afError, error in
                 NCNetworking.shared.uploadRequest.removeValue(forKey: fileNameLocalPath)
                 if error == .success && etag != nil && ocId != nil {
@@ -470,21 +478,22 @@ import Photos
     // MARK: -
 
     func openFileViewInFolder(serverUrl: String, fileNameBlink: String?, fileNameOpen: String?) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
             var topNavigationController: UINavigationController?
-            var pushServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId)
-            guard var mostViewController = self.appDelegate.window?.rootViewController?.topMostViewController() else { return }
+            var pushServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
+            guard var mostViewController = appDelegate.window?.rootViewController?.topMostViewController() else { return }
 
             if mostViewController.isModal {
                 mostViewController.dismiss(animated: false)
-                if let viewController = self.appDelegate.window?.rootViewController?.topMostViewController() {
+                if let viewController = appDelegate.window?.rootViewController?.topMostViewController() {
                     mostViewController = viewController
                 }
             }
             mostViewController.navigationController?.popToRootViewController(animated: false)
 
-            if let tabBarController = self.appDelegate.window?.rootViewController as? UITabBarController {
+            if let tabBarController = appDelegate.window?.rootViewController as? UITabBarController {
                 tabBarController.selectedIndex = 0
                 if let navigationController = tabBarController.viewControllers?.first as? UINavigationController {
                     navigationController.popToRootViewController(animated: false)
@@ -502,7 +511,7 @@ import Photos
             let diffDirectory = serverUrl.replacingOccurrences(of: pushServerUrl, with: "")
             var subDirs = diffDirectory.split(separator: "/")
 
-            while pushServerUrl != serverUrl, subDirs.count > 0  {
+            while pushServerUrl != serverUrl, !subDirs.isEmpty {
 
                 guard let dir = subDirs.first, let viewController = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as? NCFiles else { return }
                 pushServerUrl = pushServerUrl + "/" + dir
@@ -514,7 +523,7 @@ import Photos
                     viewController.fileNameBlink = fileNameBlink
                     viewController.fileNameOpen = fileNameOpen
                 }
-                self.appDelegate.listFilesVC[serverUrl] = viewController
+                appDelegate.listFilesVC[serverUrl] = viewController
 
                 viewController.navigationItem.backButtonTitle = viewController.titleCurrentFolder
                 topNavigationController.pushViewController(viewController, animated: false)
@@ -524,17 +533,16 @@ import Photos
         }
     }
 
-
     // MARK: - NCSelect + Delegate
 
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) {
-        if serverUrl != nil && items.count > 0 {
+        if serverUrl != nil && !items.isEmpty {
             if copy {
-                for metadata in items as! [tableMetadata] {
+                for case let metadata as tableMetadata in items {
                     NCOperationQueue.shared.copyMove(metadata: metadata, serverUrl: serverUrl!, overwrite: overwrite, move: false)
                 }
             } else if move {
-                for metadata in items as! [tableMetadata] {
+                for case let metadata as tableMetadata in items {
                     NCOperationQueue.shared.copyMove(metadata: metadata, serverUrl: serverUrl!, overwrite: overwrite, move: true)
                 }
             }
@@ -542,9 +550,10 @@ import Photos
     }
 
     func openSelectView(items: [tableMetadata]) {
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
-        let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
-        let topViewController = navigationController.topViewController as! NCSelect
+        let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as? UINavigationController
+        let topViewController = navigationController?.topViewController as? NCSelect
         var listViewController = [NCSelect]()
 
         var copyItems: [tableMetadata] = []
@@ -588,10 +597,12 @@ import Photos
             }
         }
 
-        navigationController.setViewControllers(listViewController, animated: false)
-        navigationController.modalPresentationStyle = .formSheet
+        navigationController?.setViewControllers(listViewController, animated: false)
+        navigationController?.modalPresentationStyle = .formSheet
 
-        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+        if let navigationController = navigationController {
+            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+        }
     }
 }
 

+ 1 - 1
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -82,7 +82,7 @@ extension NCCollectionViewCommon {
                     icon: NCUtility.shared.loadImage(named: "info"),
                     order: 10,
                     action: { _ in
-                        NCFunctionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .activity)
+                        NCActionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .activity)
                     }
                 )
             )

+ 5 - 5
iOSClient/Menu/NCContextMenu.swift

@@ -53,7 +53,7 @@ class NCContextMenu: NSObject {
 
         let detail = UIAction(title: NSLocalizedString("_details_", comment: ""),
                               image: UIImage(systemName: "info")) { _ in
-            NCFunctionCenter.shared.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
+            NCActionCenter.shared.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
         }
 
         let favorite = UIAction(title: metadata.favorite ?
@@ -91,16 +91,16 @@ class NCContextMenu: NSObject {
 
         let viewInFolder = UIAction(title: NSLocalizedString("_view_in_folder_", comment: ""),
                                     image: UIImage(systemName: "arrow.forward.square")) { _ in
-            NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
+            NCActionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
         }
 
         let save = UIAction(title: titleSave,
                             image: UIImage(systemName: "square.and.arrow.down")) { _ in
             if let metadataMOV = metadataMOV {
-                NCFunctionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)
+                NCActionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)
             } else {
                 if CCUtility.fileProviderStorageExists(metadata) {
-                    NCFunctionCenter.shared.saveAlbum(metadata: metadata)
+                    NCActionCenter.shared.saveAlbum(metadata: metadata)
                 } else {
                     hud.show(in: viewController.view)
                     NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum, notificationCenterProgressTask: false) { request in
@@ -122,7 +122,7 @@ class NCContextMenu: NSObject {
 
         let copy = UIAction(title: NSLocalizedString("_copy_file_", comment: ""),
                             image: UIImage(systemName: "doc.on.doc")) { _ in
-            NCFunctionCenter.shared.copyPasteboard(pasteboardOcIds: [metadata.ocId], hudView: viewController.view)
+            NCActionCenter.shared.copyPasteboard(pasteboardOcIds: [metadata.ocId], hudView: viewController.view)
         }
 
         let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""),

+ 7 - 7
iOSClient/Menu/NCMenuAction.swift

@@ -89,7 +89,7 @@ extension NCMenuAction {
             icon: NCUtility.shared.loadImage(named: "doc.on.doc"),
             order: order,
             action: { _ in
-                NCFunctionCenter.shared.copyPasteboard(pasteboardOcIds: selectOcId, hudView: hudView)
+                NCActionCenter.shared.copyPasteboard(pasteboardOcIds: selectOcId, hudView: hudView)
                 completion?()
             }
         )
@@ -161,7 +161,7 @@ extension NCMenuAction {
             icon: NCUtility.shared.loadImage(named: "square.and.arrow.up"),
             order: order,
             action: { _ in
-                NCFunctionCenter.shared.openActivityViewController(selectedMetadata: selectedMetadatas)
+                NCActionCenter.shared.openActivityViewController(selectedMetadata: selectedMetadatas)
                 completion?()
             }
         )
@@ -183,10 +183,10 @@ extension NCMenuAction {
             action: { _ in
                 for metadata in selectedMediaMetadatas {
                     if let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
-                        NCFunctionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)
+                        NCActionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)
                     } else {
                         if CCUtility.fileProviderStorageExists(metadata) {
-                            NCFunctionCenter.shared.saveAlbum(metadata: metadata)
+                            NCActionCenter.shared.saveAlbum(metadata: metadata)
                         } else {
                             NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum)
                         }
@@ -210,13 +210,13 @@ extension NCMenuAction {
                         message: NSLocalizedString("_select_offline_warning_", comment: ""),
                         preferredStyle: .alert)
                     alert.addAction(UIAlertAction(title: NSLocalizedString("_continue_", comment: ""), style: .default, handler: { _ in
-                        selectedMetadatas.forEach { NCFunctionCenter.shared.setMetadataAvalableOffline($0, isOffline: isAnyOffline) }
+                        selectedMetadatas.forEach { NCActionCenter.shared.setMetadataAvalableOffline($0, isOffline: isAnyOffline) }
                         completion?()
                     }))
                     alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
                     viewController.present(alert, animated: true)
                 } else {
-                    selectedMetadatas.forEach { NCFunctionCenter.shared.setMetadataAvalableOffline($0, isOffline: isAnyOffline) }
+                    selectedMetadatas.forEach { NCActionCenter.shared.setMetadataAvalableOffline($0, isOffline: isAnyOffline) }
                     completion?()
                 }
             }
@@ -230,7 +230,7 @@ extension NCMenuAction {
             icon: NCUtility.shared.loadImage(named: "arrow.up.right.square"),
             order: order,
             action: { _ in
-                NCFunctionCenter.shared.openSelectView(items: selectedMetadatas)
+                NCActionCenter.shared.openSelectView(items: selectedMetadatas)
                 completion?()
             }
         )

+ 2 - 2
iOSClient/Menu/NCViewer+Menu.swift

@@ -46,7 +46,7 @@ extension NCViewer {
                     title: NSLocalizedString("_details_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "info"),
                     action: { _ in
-                        NCFunctionCenter.shared.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
+                        NCActionCenter.shared.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
                     }
                 )
             )
@@ -199,7 +199,7 @@ extension NCViewer {
                     title: NSLocalizedString("_view_in_folder_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "arrow.forward.square"),
                     action: { menuAction in
-                        NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
+                        NCActionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
                     }
                 )
             )

+ 1 - 1
iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift

@@ -83,7 +83,7 @@ class NCViewerRichWorkspaceWebView: UIViewController, WKNavigationDelegate, WKSc
 
             if message.body as? String == "share" {
                 if metadata != nil {
-                    NCFunctionCenter.shared.openShare(viewController: self, metadata: metadata!, indexPage: .sharing)
+                    NCActionCenter.shared.openShare(viewController: self, metadata: metadata!, indexPage: .sharing)
                 }
             }
 

+ 1 - 1
iOSClient/Viewer/NCViewer.swift

@@ -239,7 +239,7 @@ class NCViewer: NSObject {
             viewController.present(viewerQuickLook, animated: true)
         } else {
         // Document Interaction Controller
-            NCFunctionCenter.shared.openDocumentController(metadata: metadata)
+            NCActionCenter.shared.openDocumentController(metadata: metadata)
         }
     }
 }

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -153,7 +153,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
             }
 
             if message.body as? String == "share" {
-                NCFunctionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
+                NCActionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
             }
 
             if message.body as? String == "loading" {

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -174,7 +174,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
             }
 
             if message.body as? String == "share" {
-                NCFunctionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
+                NCActionCenter.shared.openShare(viewController: self, metadata: metadata, indexPage: .sharing)
             }
 
             if let param = message.body as? [AnyHashable: Any] {