marinofaggiana 5 lat temu
rodzic
commit
d20cb7e19a

+ 1 - 1
Cartfile

@@ -1,4 +1,4 @@
-github "nextcloud/ios-communication-library" "develop"
+github "nextcloud/ios-communication-library" "v0.4"
 github "tilltue/TLPhotoPicker" "2.0.7"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "danielsaidi/Sheeeeeeeeet" "3.0.9"

+ 1 - 1
Cartfile.resolved

@@ -17,7 +17,7 @@ github "krzyzanowskim/OpenSSL" "1.0.218"
 github "malcommac/SwiftRichString" "3.6.0"
 github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/FastScroll" "81967c2309d29bc2c330d422da612160a30bade8"
-github "nextcloud/ios-communication-library" "6a8244f5e66f2dda4a5e01a89f3fea6f39867500"
+github "nextcloud/ios-communication-library" "v0.4"
 github "realm/realm-cocoa" "v4.1.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "tilltue/TLPhotoPicker" "2.0.7"

+ 5 - 6
iOSClient/RichWorkspace/NCViewerNextcloudText.swift

@@ -29,7 +29,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     @objc var metadata: tableMetadata!
-    @objc var link: String = ""
+    @objc var url: String = ""
 
    
     override func viewDidLoad() {
@@ -37,16 +37,15 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
         
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
-        
-        
-        var request = URLRequest(url: URL(string: link)!)
+                
+        var request = URLRequest(url: URL(string: url)!)
         request.addValue("true", forHTTPHeaderField: "OCS-APIRequest")
         let language = NSLocale.preferredLanguages[0] as String
         request.addValue(language, forHTTPHeaderField: "Accept-Language")
         
         let userAgent : String = CCUtility.getUserAgent()
-        self.webView.customUserAgent = userAgent
-        self.webView.load(request)
+        webView.customUserAgent = userAgent
+        webView.load(request)
     }
     
     @objc func keyboardDidShow(notification: Notification) {

+ 1 - 1
iOSClient/RichWorkspace/NCViewerRichWorkspace.storyboard

@@ -75,7 +75,7 @@
         <!--Viewer Nextcloud Text-->
         <scene sceneID="FAF-zB-yaq">
             <objects>
-                <viewController id="Ces-GG-tAv" customClass="NCViewerNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="NCViewerNextcloudText" id="Ces-GG-tAv" customClass="NCViewerNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="T4r-I1-FJU">
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

+ 32 - 2
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import NCCommunication
 
 @objc class NCViewerRichWorkspace: UIViewController {
 
@@ -58,8 +59,37 @@ import Foundation
         
         if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, serverUrl, k_fileNameRichWorkspace.lowercased())) {
             
-            dismiss(animated: false) {
-                //self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
+            if metadata.url == "" {
+                NCUtility.sharedInstance.startActivityIndicator(view: self.view, bottom: 0)
+                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
+                NCCommunication.sharedInstance.NCTextOpenFile(urlString: appDelegate.activeUrl, fileNamePath: fileNamePath, editor: "text", account: appDelegate.activeAccount) { (account, url, errorCode, errorMessage) in
+                    
+                    NCUtility.sharedInstance.stopActivityIndicator()
+                    
+                    if errorCode == 0 && account == self.appDelegate.activeAccount {
+                        
+                        if let viewerNextcloudText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerNextcloudText") as? NCViewerNextcloudText {
+                            
+                            viewerNextcloudText.url = url!
+                            viewerNextcloudText.metadata = metadata
+                            
+                            self.present(viewerNextcloudText, animated: true, completion: nil)
+                        }
+                        
+                    } else if errorCode != 0 {
+                        NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: errorCode)
+                    }
+                }
+                
+            } else {
+                
+                if let viewerNextcloudText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerNextcloudText") as? NCViewerNextcloudText {
+                    
+                    viewerNextcloudText.url = metadata.url
+                    viewerNextcloudText.metadata = metadata
+                    
+                    self.present(viewerNextcloudText, animated: true, completion: nil)
+                }
             }
         }
     }