marinofaggiana 4 éve
szülő
commit
5acc3406f7

+ 2 - 1
iOSClient/Database/NCDatabaseJSON.swift

@@ -40,12 +40,13 @@ class NCDatabaseJSON: NSObject {
             
             
         }
         }
         
         
+        /*
         do {
         do {
             //let data = try Data(contentsOf: databaseUrl)
             //let data = try Data(contentsOf: databaseUrl)
         } catch {
         } catch {
                    // handle error
                    // handle error
         }
         }
-        
+        */
 //        if let dataFromString = jsonString.data(using: .utf8, allowLossyConversion: false) {
 //        if let dataFromString = jsonString.data(using: .utf8, allowLossyConversion: false) {
 //            let json = JSON(data: dataFromString)
 //            let json = JSON(data: dataFromString)
 //        }
 //        }

+ 1 - 1
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -204,7 +204,7 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             let fileURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("capabilities.txt")
             let fileURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("capabilities.txt")
             do {
             do {
                 try self.capabilitiesText.write(to: fileURL, atomically: true, encoding: .utf8)
                 try self.capabilitiesText.write(to: fileURL, atomically: true, encoding: .utf8)
-                NCMainCommon.shared.openIn(fileURL: fileURL, selector: nil)
+                NCNetworkingNotificationCenter.shared.openIn(fileURL: fileURL, selector: nil)
             } catch { }
             } catch { }
         }
         }
     }
     }

+ 1 - 20
iOSClient/Main/NCMainCommon.swift

@@ -28,7 +28,7 @@ import NCCommunication
 
 
 //MARK: - Main Common
 //MARK: - Main Common
 
 
-class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentInteractionControllerDelegate {
+class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate {
     @objc static let shared: NCMainCommon = {
     @objc static let shared: NCMainCommon = {
         let instance = NCMainCommon()
         let instance = NCMainCommon()
         instance.createImagesThemingColor()
         instance.createImagesThemingColor()
@@ -36,7 +36,6 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
     }()
     }()
     
     
     var metadataEditPhoto: tableMetadata?
     var metadataEditPhoto: tableMetadata?
-    var docController: UIDocumentInteractionController?
 
 
     //MARK: -
     //MARK: -
     
     
@@ -468,25 +467,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
 
 
     //MARK: - OpenIn
     //MARK: - OpenIn
     
     
-    func openIn(fileURL: URL, selector: String?) {
-        
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        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)
-        }
-    }
     
     
     //MARK: - OpenShare
     //MARK: - OpenShare
     
     

+ 25 - 7
iOSClient/Networking/NCNetworkingNotificationCenter.swift

@@ -23,12 +23,11 @@
 
 
 import Foundation
 import Foundation
 
 
-@objc class NCNetworkingNotificationCenter: NSObject {
+@objc class NCNetworkingNotificationCenter: NSObject, UIDocumentInteractionControllerDelegate {
     @objc public static let shared: NCNetworkingNotificationCenter = {
     @objc public static let shared: NCNetworkingNotificationCenter = {
         let instance = NCNetworkingNotificationCenter()
         let instance = NCNetworkingNotificationCenter()
         
         
         NotificationCenter.default.addObserver(instance, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadedFile), object: nil)
         NotificationCenter.default.addObserver(instance, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadedFile), object: nil)
-
         NotificationCenter.default.addObserver(instance, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_uploadedFile), object: nil)
         NotificationCenter.default.addObserver(instance, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_uploadedFile), object: nil)
         
         
         return instance
         return instance
@@ -36,6 +35,7 @@ import Foundation
     
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var viewerQuickLook: NCViewerQuickLook?
     var viewerQuickLook: NCViewerQuickLook?
+    var docController: UIDocumentInteractionController?
     
     
     //MARK: - Download
     //MARK: - Download
 
 
@@ -65,15 +65,15 @@ import Foundation
                                                         
                                                         
                             if metadata.contentType.contains("opendocument") && !NCUtility.shared.isRichDocument(metadata) {
                             if metadata.contentType.contains("opendocument") && !NCUtility.shared.isRichDocument(metadata) {
                                 
                                 
-                                NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+                                openIn(fileURL: fileURL, selector: selector)
                                 
                                 
                             } else if metadata.typeFile == k_metadataTypeFile_compress || metadata.typeFile == k_metadataTypeFile_unknown {
                             } else if metadata.typeFile == k_metadataTypeFile_compress || metadata.typeFile == k_metadataTypeFile_unknown {
 
 
-                                NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+                                openIn(fileURL: fileURL, selector: selector)
                                 
                                 
                             } else if metadata.typeFile == k_metadataTypeFile_imagemeter {
                             } else if metadata.typeFile == k_metadataTypeFile_imagemeter {
                                 
                                 
-                                NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+                                openIn(fileURL: fileURL, selector: selector)
                                 
                                 
                             } else {
                             } else {
                                 
                                 
@@ -91,7 +91,7 @@ import Foundation
                         
                         
                         if UIApplication.shared.applicationState == UIApplication.State.active {
                         if UIApplication.shared.applicationState == UIApplication.State.active {
                             
                             
-                            NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+                            openIn(fileURL: fileURL, selector: selector)
                         }
                         }
                         
                         
                     case selectorSaveAlbum:
                     case selectorSaveAlbum:
@@ -141,6 +141,25 @@ 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)
+        }
+    }
+    
     //MARK: - Upload
     //MARK: - Upload
 
 
     @objc func uploadedFile(_ notification: NSNotification) {
     @objc func uploadedFile(_ notification: NSNotification) {
@@ -158,6 +177,5 @@ import Foundation
             }
             }
         }
         }
     }
     }
-    
 }
 }