marinofaggiana 4 years ago
parent
commit
6f985698b0

+ 1 - 0
iOSClient/AppDelegate.h

@@ -87,6 +87,7 @@
 @property (nonatomic, retain) TOPasscodeViewController *passcodeViewController;
 
 @property (nonatomic, retain) NSString *activeServerUrl;
+@property (nonatomic, retain) id activeViewController;
 
 @property (nonatomic, strong) CCMain *activeMain;
 @property (nonatomic, strong) CCMain *homeMain;

+ 1 - 0
iOSClient/Favorites/NCFavorite.swift

@@ -39,6 +39,7 @@ class NCFavorite: NCCollectionViewCommon  {
     }
     
     override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
         
         if serverUrl == "" {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)

+ 1 - 0
iOSClient/Main/CCMain.m

@@ -256,6 +256,7 @@
     }
     
     appDelegate.activeServerUrl = self.serverUrl;
+    appDelegate.activeViewController = self;
 }
 
 - (void)viewDidAppear:(BOOL)animated

+ 2 - 0
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -145,6 +145,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
 
+        appDelegate.activeViewController = self
+        
         self.navigationItem.title = titleCurrentFolder
                 
         // get auto upload folder

+ 4 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -329,6 +329,7 @@ import NCCommunication
                         
                         self.dismiss(animated: true, completion: {
                             let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: result.contentType, livePhoto: false)
+                            
                             self.appDelegate.activeMain.readFileReloadFolder()
                             self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
                         })
@@ -353,7 +354,9 @@ import NCCommunication
                     
                         let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
                     
-                       self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
+                        if self.appDelegate.activeViewController is NCFavorite {
+                            (self.appDelegate.activeViewController as! NCFavorite).segue(metadata: metadata)
+                        }
                    })
                    
                     

+ 9 - 9
iOSClient/Main/Menu/AppDelegate+Menu.swift

@@ -56,7 +56,7 @@ extension AppDelegate {
                 title: NSLocalizedString("_upload_photos_videos_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "file_photo"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                 action: { menuAction in
-                    NCPhotosPickerViewController.init(viewController: appDelegate.window.rootViewController!, maxSelectedAssets: 100, singleSelectedMode: false)
+                    NCPhotosPickerViewController.init(viewController: appDelegate.window.rootViewController!, maxSelectedAssets: 0, singleSelectedMode: false)
                 }
             )
         )
@@ -81,7 +81,7 @@ extension AppDelegate {
                 title: NSLocalizedString("_im_create_new_file", tableName: "IMLocalizable", bundle: Bundle.main, value: "", comment: ""),
                 icon: CCGraphics.scale(UIImage(named: "imagemeter"), to: CGSize(width: 25, height: 25), isAspectRation: true),
                 action: { menuAction in
-                    _ = IMCreate.init(serverUrl: appDelegate.activeMain.serverUrl, imagemeterViewerDelegate: NCNetworkingMain.sharedInstance)
+                    _ = IMCreate.init(serverUrl: appDelegate.activeServerUrl, imagemeterViewerDelegate: NCNetworkingMain.sharedInstance)
                 }
             )
         )
@@ -100,7 +100,7 @@ extension AppDelegate {
                     viewController.editorId = k_editor_text
                     viewController.creatorId = directEditingCreator.identifier
                     viewController.typeTemplate = k_template_document
-                    viewController.serverUrl = appDelegate.activeMain.serverUrl
+                    viewController.serverUrl = appDelegate.activeServerUrl
                     viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
                     appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -195,7 +195,7 @@ extension AppDelegate {
                         viewController.editorId = k_editor_onlyoffice
                         viewController.creatorId = directEditingCreator.identifier
                         viewController.typeTemplate = k_template_document
-                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
 
                         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -220,7 +220,7 @@ extension AppDelegate {
                         viewController.editorId = k_editor_onlyoffice
                         viewController.creatorId = directEditingCreator.identifier
                         viewController.typeTemplate = k_template_spreadsheet
-                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
                         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -245,7 +245,7 @@ extension AppDelegate {
                         viewController.editorId = k_editor_onlyoffice
                         viewController.creatorId = directEditingCreator.identifier
                         viewController.typeTemplate = k_template_presentation
-                        viewController.serverUrl = appDelegate.activeMain.serverUrl
+                        viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 
                         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -269,7 +269,7 @@ extension AppDelegate {
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
                             viewController.editorId = k_editor_collabora
                             viewController.typeTemplate = k_template_document
-                            viewController.serverUrl = appDelegate.activeMain.serverUrl
+                            viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
                             appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -290,7 +290,7 @@ extension AppDelegate {
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
                             viewController.editorId = k_editor_collabora
                             viewController.typeTemplate = k_template_spreadsheet
-                            viewController.serverUrl = appDelegate.activeMain.serverUrl
+                            viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
                             appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
@@ -311,7 +311,7 @@ extension AppDelegate {
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
                             viewController.editorId = k_editor_collabora
                             viewController.typeTemplate = k_template_presentation
-                            viewController.serverUrl = appDelegate.activeMain.serverUrl
+                            viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 
                             appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)

+ 1 - 1
iOSClient/Main/NCMainCommon.swift

@@ -527,7 +527,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
         
         let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadVoiceNote
-        viewController.setup(serverUrl: appDelegate.activeMain.serverUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
+        viewController.setup(serverUrl: appDelegate.activeServerUrl, fileNamePath: NSTemporaryDirectory() + fileName, fileName: fileName)
         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
     }
     

+ 4 - 2
iOSClient/Main/NCPickerViewController.swift

@@ -35,7 +35,7 @@ class NCPhotosPickerViewController: NSObject {
     var singleSelectedMode = false
 
     @discardableResult
-    init (viewController: UIViewController, maxSelectedAssets: Int, singleSelectedMode: Bool) {
+    init(viewController: UIViewController, maxSelectedAssets: Int, singleSelectedMode: Bool) {
         sourceViewController = viewController
         super.init()
         
@@ -66,7 +66,9 @@ class NCPhotosPickerViewController: NSObject {
         configure.emptyMessage = NSLocalizedString("_no_albums_", comment: "")
         configure.tapHereToChange = NSLocalizedString("_tap_here_to_change_", comment: "")
         
-        configure.maxSelectedAssets = self.maxSelectedAssets
+        if maxSelectedAssets > 0 {
+            configure.maxSelectedAssets = maxSelectedAssets
+        }
         configure.selectedColor = NCBrandColor.sharedInstance.brandElement
         configure.singleSelectedMode = singleSelectedMode
         

+ 1 - 1
iOSClient/ScanDocument/ScanCollectionView.swift

@@ -115,7 +115,7 @@ class DragDropViewController: UIViewController {
         if imagesDestination.count > 0 {
             
             var images: [UIImage] = []
-            var serverUrl = appDelegate.activeMain.serverUrl!
+            var serverUrl = appDelegate.activeServerUrl!
 
             for image in imagesDestination {
                 images.append(filter(image: image)!)