marinofaggiana 4 年之前
父節點
當前提交
d4f9ab13fa
共有 2 個文件被更改,包括 29 次插入5 次删除
  1. 18 5
      iOSClient/AppDelegate.m
  2. 11 0
      iOSClient/Main/NCCollectionCommon.swift

+ 18 - 5
iOSClient/AppDelegate.m

@@ -1065,9 +1065,8 @@
         return YES;
     
     NSString *scheme = url.scheme;
-
-    dispatch_time_t timer = 0;
-    if (self.activeFiles == nil) timer = 1;
+    NSString *fileName;
+    NSString *serverUrl;
 
     if ([scheme isEqualToString:@"nextcloud"]) {
                 
@@ -1112,7 +1111,21 @@
                     
                     if (matchedAccount) {
                         
-                    
+                        NSString *webDAV = [[NCUtility shared] getWebDAVWithAccount:self.account];
+                        //NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@/%@", matchedAccount.urlBase, webDAV, path];
+
+                        if ([path containsString:@"/"]) {
+
+                            fileName = [[path stringByDeletingLastPathComponent] lastPathComponent];
+                            serverUrl = [CCUtility deletingLastPathComponentFromServerUrl:[NSString stringWithFormat:@"%@/%@/%@", matchedAccount.urlBase, webDAV, [path stringByDeletingLastPathComponent]]];
+                            
+                        } else {
+                            
+                            fileName = [[path stringByDeletingLastPathComponent] lastPathComponent];
+                            serverUrl = [NSString stringWithFormat:@"%@/%@", matchedAccount.urlBase, webDAV];
+                        }
+                        
+                        [[NCCollectionCommon shared] openFilesViewControllerWithServerUrl:serverUrl fileName:fileName];
                    
                     } else {
                         
@@ -1151,7 +1164,7 @@
                 if ([navigationControllerMaster isKindOfClass:[UINavigationController class]]) {
                     UIViewController *uploadNavigationViewController = [[UIStoryboard storyboardWithName:@"CCUploadFromOtherUpp" bundle:nil] instantiateViewControllerWithIdentifier:@"CCUploadNavigationViewController"];
                     
-                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, timer * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                         [navigationControllerMaster presentViewController:uploadNavigationViewController animated:YES completion:nil];
                     });
                 }

+ 11 - 0
iOSClient/Main/NCCollectionCommon.swift

@@ -122,6 +122,17 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
         navigationController.modalPresentationStyle = .fullScreen
         viewController.present(navigationController, animated: true, completion: nil)
     }
+    
+    @objc func openFilesViewController(serverUrl: String, fileName: String) {
+        
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+        let viewController = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as! NCFiles
+        let navigationController = UINavigationController.init(rootViewController: viewController)
+        
+        navigationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
+        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+    }
 }
 
 // MARK: - List Layout