Browse Source

auto download GIF

marinofaggiana 5 years ago
parent
commit
2375b8cbb4

+ 1 - 2
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -184,8 +184,7 @@ extension NCDetailNavigationController {
                 NCMenuAction(title: NSLocalizedString("_download_image_max_", comment: ""),
                     icon: CCGraphics.changeThemingColorImage(UIImage(named: "downloadImageFullRes"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                     action: { menuAction in
-                        let userInfo: [String : Any] = ["metadata": metadata]
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDownloadImage), object: nil, userInfo: userInfo)
+                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDownloadImage), object: nil, userInfo: ["metadata": metadata])
                     }
                 )
             )

+ 11 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImageCommon.swift

@@ -79,13 +79,23 @@ class NCViewerImageCommon: NSObject {
     func getImage(metadata: tableMetadata) -> UIImage? {
         
         var image: UIImage?
+        let ext = CCUtility.getExtension(metadata.fileNameView)
         
         if CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView) > 0 && metadata.typeFile == k_metadataTypeFile_image {
            
             let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-            let ext = CCUtility.getExtension(metadata.fileNameView)
             if ext == "GIF" { image = UIImage.animatedImage(withAnimatedGIFURL: URL(fileURLWithPath: imagePath)) }
             else { image = UIImage.init(contentsOfFile: imagePath) }
+            
+        } else {
+            
+            // AUTOMATIC DOWNLOAD FOR GIF
+            
+            if ext == "GIF" && metadata.session == "" {
+                DispatchQueue.main.async {
+                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDownloadImage), object: nil, userInfo: ["metadata": metadata])
+                }
+            }
         }
         
         return image