Browse Source

replace view select Remote image... on Collabora

Marino Faggiana 6 years ago
parent
commit
011345e4e8
3 changed files with 35 additions and 16 deletions
  1. 1 0
      iOSClient/CCGlobal.h
  2. 5 0
      iOSClient/Select/NCSelect.swift
  3. 29 16
      iOSClient/Viewer/NCViewerRichdocument.swift

+ 1 - 0
iOSClient/CCGlobal.h

@@ -312,6 +312,7 @@
 
 // Layout View
 #define k_layout_view_move                              @"LayoutMove"
+#define k_layout_view_richdocument                      @"LayoutRichdocument"
 #define k_layout_view_trash                             @"LayoutTrash"
 #define k_layout_view_offline                           @"LayoutOffline"
 

+ 5 - 0
iOSClient/Select/NCSelect.swift

@@ -129,6 +129,11 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
         
         buttonDone.title = titleButtonDone
         
+        if selectFile {
+            buttonDone.isEnabled = false
+            buttonDone.tintColor = UIColor.clear
+        }
+        
         if hideButtonCreateFolder {
             buttonCreateFolder.isEnabled = false
             buttonCreateFolder.tintColor = UIColor.clear

+ 29 - 16
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -23,7 +23,7 @@
 
 import Foundation
 
-class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler, CCMoveDelegate {
+class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler, NCSelectDelegate {
     
     @objc static let sharedInstance: NCViewerRichdocument = {
         let instance = NCViewerRichdocument()
@@ -77,23 +77,20 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
             
             if message.body as! String == "insertGraphic" {
                 
-                let storyboard = UIStoryboard(name: "CCMove", bundle: nil)
-                let movieNavigationController = storyboard.instantiateViewController(withIdentifier: "CCMove") as! UINavigationController
-                let moveViewController = movieNavigationController.topViewController as! CCMove
+                let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
+                let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
+                let viewController = navigationController.topViewController as! NCSelect
                 
-                moveViewController.delegate = self
-                moveViewController.hideMoveutton = true
-                moveViewController.hideCreateFolder = true
-                moveViewController.tintColor = NCBrandColor.sharedInstance.brandText
-                moveViewController.barTintColor = NCBrandColor.sharedInstance.brand
-                moveViewController.tintColorTitle = NCBrandColor.sharedInstance.brandText
-                moveViewController.networkingOperationQueue = appDelegate.netQueue
-                moveViewController.includeImages = true
-                moveViewController.includeDirectoryE2EEncryption = false
-                moveViewController.selectFile = true
+                viewController.delegate = self
+                viewController.hideButtonCreateFolder = true
+                viewController.selectFile = true
+                viewController.includeDirectoryE2EEncryption = false
+                viewController.includeImages = true
+                viewController.type = ""
+                viewController.layoutViewSelect = k_layout_view_richdocument
                 
-                movieNavigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-                self.detail.present(movieNavigationController, animated: true, completion: nil)
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+                self.detail.present(navigationController, animated: true, completion: nil)
             }
             
             if message.body as! String == "share" {
@@ -104,6 +101,22 @@ class NCViewerRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandl
     
     //MARK: -
     
+    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String) {
+        
+        if serverUrl != nil && metadata != nil {
+            
+            let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
+            ocNetworking?.createAssetRichdocuments(withFileName: metadata!.fileName, serverUrl: serverUrl, success: { (url) in
+                
+                let functionJS = "OCA.RichDocuments.documentsMain.postAsset('\(metadata!.fileNameView)', '\(url!)')"
+                self.webView.evaluateJavaScript(functionJS, completionHandler: { (result, error) in })
+                
+            }, failure: { (message, errorCode) in
+                self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
+            })
+        }
+    }
+    
     func select(_ metadata: tableMetadata!, serverUrl: String!) {
         
         let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)