Browse Source

remove AutomaticDownloadImage option

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
79f4dc8bfc

+ 7 - 5
iOSClient/Networking/NCNetworking.swift

@@ -399,9 +399,6 @@ import Queuer
             }
 
             self.downloadRequest[fileNameLocalPath] = nil
-            #if !EXTENSION
-            DispatchQueue.main.async { (UIApplication.shared.delegate as! AppDelegate).listProgress[metadata.ocId] = nil }
-            #endif
 
             if error?.isExplicitlyCancelledError ?? false {
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadCancelFile, userInfo: ["ocId": metadata.ocId])
@@ -409,7 +406,12 @@ import Queuer
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": selector, "errorCode": errorCode, "errorDescription": errorDescription])
             }
 
-            completion(errorCode)
+            DispatchQueue.main.async {
+                #if !EXTENSION
+                (UIApplication.shared.delegate as! AppDelegate).listProgress[metadata.ocId] = nil
+                #endif
+                completion(errorCode)
+            }
         }
     }
 
@@ -1081,7 +1083,7 @@ import Queuer
     private func loadMetadata(urlBase: NCUserBaseUrl, filePath: String, dispatchGroup: DispatchGroup? = nil, completion: @escaping (tableMetadata) -> Void) {
         let urlPath = urlBase.urlBase + "/remote.php/dav/files/" + urlBase.user + filePath
         dispatchGroup?.enter()
-        self.readFile(serverUrlFileName: urlPath, showHiddenFiles: true) { account, metadata, errorCode, errorDescription in
+        self.readFile(serverUrlFileName: urlPath) { account, metadata, errorCode, errorDescription in
             defer { dispatchGroup?.leave() }
             guard let metadata = metadata else { return }
             DispatchQueue.main.async {

+ 1 - 20
iOSClient/Settings/CCAdvanced.m

@@ -97,21 +97,7 @@
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [section addFormRow:row];
-    
-    // Automatic download image
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    section.footerTitle = NSLocalizedString(@"_automatic_Download_Image_footer_", nil);
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"automaticDownloadImage" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_automatic_Download_Image_", nil)];
-    row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
-    if ([CCUtility getAutomaticDownloadImage]) row.value = @"1";
-    else row.value = @"0";
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-    [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
-    [section addFormRow:row];
-    
+
     // Section : Files App --------------------------------------------------------------
     
     if (![NCBrandOptions shared].disable_openin_file) {
@@ -370,11 +356,6 @@
         [CCUtility setDisableLocalCacheAfterUpload:[[rowDescriptor.value valueData] boolValue]];
     }
     
-    if ([rowDescriptor.tag isEqualToString:@"automaticDownloadImage"]) {
-        
-        [CCUtility setAutomaticDownloadImage:[[rowDescriptor.value valueData] boolValue]];
-    }
-    
     if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
         
         [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]];

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -168,9 +168,6 @@
 + (BOOL)getAudioMute;
 + (void)setAudioMute:(BOOL)set;
 
-+ (BOOL)getAutomaticDownloadImage;
-+ (void)setAutomaticDownloadImage:(BOOL)set;
-
 + (BOOL)getAccountRequest;
 + (void)setAccountRequest:(BOOL)set;
 

+ 0 - 11
iOSClient/Utility/CCUtility.m

@@ -659,17 +659,6 @@
     [UICKeyChainStore setString:sSet forKey:@"audioMute" service:NCGlobal.shared.serviceShareKeyChain];
 }
 
-+ (BOOL)getAutomaticDownloadImage
-{
-    return [[UICKeyChainStore stringForKey:@"automaticDownloadImage" service:NCGlobal.shared.serviceShareKeyChain] boolValue];
-}
-
-+ (void)setAutomaticDownloadImage:(BOOL)set
-{
-    NSString *sSet = (set) ? @"true" : @"false";
-    [UICKeyChainStore setString:sSet forKey:@"automaticDownloadImage" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 + (BOOL)getAccountRequest
 {
     return [[UICKeyChainStore stringForKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain] boolValue];

+ 24 - 46
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -199,18 +199,11 @@ class NCViewerMedia: UIViewController {
     func reloadImage() {
         if let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) {
             self.metadata = metadata
-            loadImage(metadata: metadata) { _, image in
-                self.image = image
-                // do not update if is present the videoLayer
-                let numSublayers = self.imageVideoContainer.layer.sublayers?.count
-                if numSublayers == nil {
-                    self.imageVideoContainer.image = image
-                }
-            }
+            loadImage(metadata: metadata)
         }
     }
 
-    func loadImage(metadata: tableMetadata, completion: @escaping (_ ocId: String, _ image: UIImage?) -> Void) {
+    func loadImage(metadata: tableMetadata) {
 
         // Download preview
         if metadata.hasPreview && !CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
@@ -230,58 +223,43 @@ class NCViewerMedia: UIViewController {
                 heightPreview: NCGlobal.shared.sizePreview,
                 fileNameIconLocalPath: fileNameIconLocalPath,
                 sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource,
-                queue: NCCommunicationCommon.shared.backgroundQueue) { _, _, imageIcon, _, etag, errorCode, _ in
+                queue: .main) { _, _, imageIcon, _, etag, errorCode, _ in
 
-                    if errorCode == 0 && imageIcon != nil {
+                    if let image = imageIcon, errorCode == 0 {
+                        if self.imageVideoContainer.layer.sublayers?.count == nil {
+                            self.image = image
+                            self.imageVideoContainer.image = image
+                        }
                         NCManageDatabase.shared.setMetadataEtagResource(ocId: metadata.ocId, etagResource: etag)
                     }
 
-                    // Download file max resolution
                     downloadFile(metadata: metadata)
-                    // Download file live photo
-                    if metadata.livePhoto { downloadFileLivePhoto(metadata: metadata) }
                 }
         } else {
 
-            // Download file max resolution
+            let image = getImageMetadata(metadata)
+            if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
+                self.image = image
+                self.imageVideoContainer.image = image
+            }
             downloadFile(metadata: metadata)
-            // Download file live photo
-            if metadata.livePhoto { downloadFileLivePhoto(metadata: metadata) }
         }
 
-        // Download file max resolution
         func downloadFile(metadata: tableMetadata) {
-
-            let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase)
-            let ext = CCUtility.getExtension(metadata.fileNameView)
-
-            if (CCUtility.getAutomaticDownloadImage() || (metadata.contentType == "image/heic" &&  metadata.hasPreview == false) || ext == "GIF" || ext == "SVG" || isFolderEncrypted) && (metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue && !CCUtility.fileProviderStorageExists(metadata) && metadata.session == "") {
-
-                NCNetworking.shared.download(metadata: metadata, selector: "") { _ in
-
-                    DispatchQueue.main.async {
-                        let image = getImageMetadata(metadata)
-                        completion(metadata.ocId, image)
-                    }
-                }
-
-            } else {
-
-                DispatchQueue.main.async {
-                    let image = getImageMetadata(metadata)
-                    completion(metadata.ocId, image)
+            if metadata.livePhoto {
+                let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
+                if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata) {
+                    NCNetworking.shared.download(metadata: metadata, selector: "") { _ in }
                 }
             }
-        }
+            guard metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue, !CCUtility.fileProviderStorageExists(metadata), metadata.session == "" else { return }
 
-        // Download Live Photo
-        func downloadFileLivePhoto(metadata: tableMetadata) {
-
-            let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
-
-            if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata) {
-
-                NCNetworking.shared.download(metadata: metadata, selector: "") { _ in }
+            NCNetworking.shared.download(metadata: metadata, selector: "") { _ in
+                let image = getImageMetadata(metadata)
+                if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
+                    self.image = image
+                    self.imageVideoContainer.image = image
+                }
             }
         }