marinofaggiana 4 年之前
父节点
当前提交
54998078b2

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -1085,11 +1085,11 @@
 			isa = PBXGroup;
 			children = (
 				F7F9D1BA25397CE000D9BFF5 /* NCViewer.swift */,
+				F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */,
 				F76D3CEF2428B3DD005DFA87 /* NCViewerPDF */,
 				F79018B1240962C7007C9B6D /* NCViewerImage */,
 				F72D404823D2082500A97FD0 /* NCViewerNextcloudText.swift */,
 				F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */,
-				F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */,
 				F79630ED215527D40015EEA5 /* NCViewerVideo.swift */,
 			);
 			path = Viewer;

+ 1 - 1
iOSClient/CCGlobal.h

@@ -166,7 +166,7 @@
 #define selectorLoadCopy                                @"loadCopy"
 #define selectorLoadOffline                             @"loadOffline"
 #define selectorOpenIn                                  @"openIn"
-#define selectorOpenInDetail                            @"openInDetail"
+#define selectorOpenInView                              @"openInView"
 #define selectorUploadAutoUpload                        @"uploadAutoUpload"
 #define selectorUploadAutoUploadAll                     @"uploadAutoUploadAll"
 #define selectorUploadFile                              @"uploadFile"

+ 6 - 1
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -195,7 +195,12 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             let fileURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("capabilities.txt")
             do {
                 try self.capabilitiesText.write(to: fileURL, atomically: true, encoding: .utf8)
-                NCNetworkingNotificationCenter.shared.openIn(fileURL: fileURL, selector: nil)
+                
+                if let view = self.appDelegate.window?.rootViewController?.view {
+                    self.documentController = UIDocumentInteractionController(url: fileURL)
+                    self.documentController?.delegate = self
+                    self.documentController?.presentOptionsMenu(from: view.frame, in: view, animated: true)
+                }
             } catch { }
         }
     }

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

@@ -121,7 +121,7 @@ extension NCViewer {
                 NCMenuAction(title: NSLocalizedString("_open_in_", comment: ""),
                     icon: CCGraphics.changeThemingColorImage(UIImage(named: "openFile"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                     action: { menuAction in
-                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: selectorOpenInDetail)
+                        NCNetworkingNotificationCenter.shared.downloadOpen(metadata: metadata, selector: selectorOpenInView)
                     }
                 )
             )

+ 17 - 26
iOSClient/Networking/NCNetworkingNotificationCenter.swift

@@ -35,7 +35,7 @@ import Foundation
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var viewerQuickLook: NCViewerQuickLook?
-    var docController: UIDocumentInteractionController?
+    var documentController: UIDocumentInteractionController?
     
     //MARK: - Download
 
@@ -49,7 +49,9 @@ import Foundation
                 if errorCode == 0 {
                     
                     let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-                    
+                    documentController = UIDocumentInteractionController(url: fileURL)
+                    documentController?.delegate = self
+
                     switch selector {
                     case selectorLoadFileQuickLook:
                         
@@ -65,15 +67,21 @@ import Foundation
                                                         
                             if metadata.contentType.contains("opendocument") && !NCUtility.shared.isRichDocument(metadata) {
                                 
-                                openIn(fileURL: fileURL, selector: selector)
+                                if let view = appDelegate.window?.rootViewController?.view {
+                                    documentController?.presentOptionsMenu(from: view.frame, in: view, animated: true)
+                                }
                                 
                             } else if metadata.typeFile == k_metadataTypeFile_compress || metadata.typeFile == k_metadataTypeFile_unknown {
 
-                                openIn(fileURL: fileURL, selector: selector)
+                                if let view = appDelegate.window?.rootViewController?.view {
+                                    documentController?.presentOptionsMenu(from: view.frame, in: view, animated: true)
+                                }
                                 
                             } else if metadata.typeFile == k_metadataTypeFile_imagemeter {
                                 
-                                openIn(fileURL: fileURL, selector: selector)
+                                if let view = appDelegate.window?.rootViewController?.view {
+                                    documentController?.presentOptionsMenu(from: view.frame, in: view, animated: true)
+                                }
                                 
                             } else {
                                 
@@ -81,11 +89,13 @@ import Foundation
                             }
                         }
                         
-                    case selectorOpenIn, selectorOpenInDetail:
+                    case selectorOpenIn, selectorOpenInView:
                         
                         if UIApplication.shared.applicationState == UIApplication.State.active {
                             
-                            openIn(fileURL: fileURL, selector: selector)
+                            if let view = appDelegate.window?.rootViewController?.view {
+                                documentController?.presentOptionsMenu(from: view.frame, in: view, animated: true)
+                            }
                         }
                         
                     case selectorLoadCopy:
@@ -131,25 +141,6 @@ import Foundation
         }
     }
     
-    func openIn(fileURL: URL, selector: String?) {
-        
-        docController = UIDocumentInteractionController(url: fileURL)
-        docController?.delegate = self
-        
-        if selector == selectorOpenInDetail {
-            guard let barButtonItem = appDelegate.activeDetail.navigationItem.rightBarButtonItem else { return }
-            guard let buttonItemView = barButtonItem.value(forKey: "view") as? UIView else { return }
-            
-            docController?.presentOptionsMenu(from: buttonItemView.frame, in: buttonItemView, animated: true)
-            
-        } else {
-            guard let splitViewController = appDelegate.window?.rootViewController as? UISplitViewController, let view = splitViewController.viewControllers.first?.view, let frame = splitViewController.viewControllers.first?.view.frame else {
-                return }
-    
-            docController?.presentOptionsMenu(from: frame, in: view, animated: true)
-        }
-    }
-    
     @objc func openShare(ViewController: UIViewController, metadata: tableMetadata, indexPage: Int) {
         
         let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as! UINavigationController