Explorar o código

fix OpenIn with optimization Image

Marino Faggiana %!s(int64=6) %!d(string=hai) anos
pai
achega
f934eded4d

+ 2 - 1
iOSClient/Favorites/CCFavorites.m

@@ -327,7 +327,8 @@
 
 - (void)openIn:(tableMetadata *)metadata
 {
-    NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
+    NSURL *url = [[NCUtility sharedInstance] getUrlforDocumentInteractionControllerWithFileID:metadata.fileID fileNameView:metadata.fileNameView typeFile:metadata.typeFile];
+    if (url == nil) return;
         
     UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url];
     docController.delegate = self;

+ 5 - 1
iOSClient/Main/CCDetail.m

@@ -25,6 +25,7 @@
 #import "AppDelegate.h"
 #import "CCMain.h"
 #import "NCUchardet.h"
+#import "NCBridgeSwift.h"
 #import <KTVHTTPCache/KTVHTTPCache.h>
 
 #import "NCBridgeSwift.h"
@@ -713,7 +714,10 @@
     tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
     if (metadata == nil) return;
 
-    self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]]];
+    NSURL *url = [[NCUtility sharedInstance] getUrlforDocumentInteractionControllerWithFileID:metadata.fileID fileNameView:metadata.fileNameView typeFile:metadata.typeFile];
+    if (url == nil) return;
+    
+    self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
     
     self.docController.delegate = self;
     

+ 2 - 1
iOSClient/Main/CCMain.m

@@ -1135,7 +1135,8 @@
 
             [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl];
 
-            NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
+            NSURL *url = [[NCUtility sharedInstance] getUrlforDocumentInteractionControllerWithFileID:metadata.fileID fileNameView:metadata.fileNameView typeFile:metadata.typeFile];
+            if (url == nil) return;
             
             UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url];
             docController.delegate = self;

+ 14 - 0
iOSClient/Utility/NCUtility.swift

@@ -90,4 +90,18 @@ class NCUtility: NSObject {
         return 0
     }
     
+    @objc func getUrlforDocumentInteractionController(fileID: String, fileNameView: String, typeFile: String) -> NSURL? {
+        
+        if CCUtility.fileProviderStorageExists(fileID, fileNameView: fileNameView) {
+            
+            return NSURL.fileURL(withPath: CCUtility.getDirectoryProviderStorageFileID(fileID, fileNameView: fileNameView)) as NSURL
+            
+        } else if CCUtility.fileProviderStorageIconExists(fileID, fileNameView: fileNameView) && typeFile == k_metadataTypeFile_image {
+            
+            return NSURL.fileURL(withPath: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: fileNameView)) as NSURL
+        }
+        
+        return nil;
+    }
+    
 }