marinofaggiana 4 年之前
父节点
当前提交
7383dcf869

+ 2 - 2
iOSClient/Main/NCMainCommon.swift

@@ -783,10 +783,10 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
 
     //MARK: - OpenIn
     
-    func openIn(metadata: tableMetadata, selector: String) {
+    func openIn(fileURL: URL, selector: String?) {
         
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        docController = UIDocumentInteractionController(url: NSURL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) as URL)
+        docController = UIDocumentInteractionController(url: fileURL)
         docController?.delegate = self
         
         if selector == selectorOpenInDetail {

+ 7 - 3
iOSClient/Networking/NCNetworkingNotificationCenter.swift

@@ -102,14 +102,17 @@ import Foundation
                         }
                         #else
                         if metadata.typeFile == k_metadataTypeFile_imagemeter {
-                            NCMainCommon.sharedInstance.openIn(metadata: metadata, selector: selector)
+                            
+                            let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                            NCMainCommon.sharedInstance.openIn(fileURL: fileURL, selector: selector)
                             return
                         }
                         #endif
                         
                         if metadata.typeFile == k_metadataTypeFile_compress || metadata.typeFile == k_metadataTypeFile_unknown {
 
-                            NCMainCommon.sharedInstance.openIn(metadata: metadata, selector: selector)
+                            let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                            NCMainCommon.sharedInstance.openIn(fileURL: fileURL, selector: selector)
                             
                         } else {
                             
@@ -124,7 +127,8 @@ import Foundation
                     // Open in...
                     if (selector == selectorOpenIn || selector == selectorOpenInDetail) && UIApplication.shared.applicationState == UIApplication.State.active {
 
-                        NCMainCommon.sharedInstance.openIn(metadata: metadata, selector: selector)
+                        let fileURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                        NCMainCommon.sharedInstance.openIn(fileURL: fileURL, selector: selector)
                     }
                     
                     // Save to Photo Album

+ 4 - 10
iOSClient/Settings/NCCapabilitiesViewController.swift

@@ -55,6 +55,7 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
     @IBOutlet weak var imageOnlyOffice: UIImageView!
     @IBOutlet weak var imageStatusOnlyOffice: UIImageView!
     
+    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private var documentController: UIDocumentInteractionController?
     private var account: String = ""
     private var capabilitiesText = ""
@@ -112,16 +113,9 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
     }
     
     @objc func share() {
-        
-        let tempDirectoryURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true)
-        let fileURL = tempDirectoryURL.appendingPathComponent("capabilities.txt")
-        
-        if NCUtilityFileSystem.shared.writeFile(fileURL: fileURL, text: capabilitiesText) {
-            documentController = UIDocumentInteractionController.init(url: fileURL)
-            if documentController != nil {
-                documentController!.delegate = self
-                documentController!.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
-            }
+        self.dismiss(animated: true) {
+            let fileURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("capabilities.txt")
+            NCMainCommon.sharedInstance.openIn(fileURL: fileURL, selector: nil)
         }
     }