Browse Source

Merge pull request #2013 from nextcloud/removeGPS

Remove gps
Marino Faggiana 3 years ago
parent
commit
1ed46d2751

+ 2 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -3006,7 +3006,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 11;
+				CURRENT_PROJECT_VERSION = 12;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = NO;
 				ENABLE_BITCODE = NO;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -3067,6 +3067,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
+				CURRENT_PROJECT_VERSION = 12;
 				CURRENT_PROJECT_VERSION = 11;
 				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = NO;
 				ENABLE_BITCODE = NO;

+ 0 - 12
iOSClient/Brand/iOSClient.entitlements

@@ -4,18 +4,6 @@
 <dict>
 <dict>
 	<key>aps-environment</key>
 	<key>aps-environment</key>
 	<string>development</string>
 	<string>development</string>
-	<key>com.apple.developer.icloud-container-identifiers</key>
-	<array>
-		<string>iCloud.$(CFBundleIdentifier)</string>
-	</array>
-	<key>com.apple.developer.icloud-services</key>
-	<array>
-		<string>CloudDocuments</string>
-	</array>
-	<key>com.apple.developer.ubiquity-container-identifiers</key>
-	<array>
-		<string>iCloud.$(CFBundleIdentifier)</string>
-	</array>
 	<key>com.apple.security.application-groups</key>
 	<key>com.apple.security.application-groups</key>
 	<array>
 	<array>
 		<string>group.it.twsweb.Crypto-Cloud</string>
 		<string>group.it.twsweb.Crypto-Cloud</string>

+ 0 - 2
iOSClient/Data/NCDatabase.swift

@@ -37,9 +37,7 @@ class tableAccount: Object, NCUserBaseUrl {
     @objc dynamic var address = ""
     @objc dynamic var address = ""
     @objc dynamic var alias = ""
     @objc dynamic var alias = ""
     @objc dynamic var autoUpload: Bool = false
     @objc dynamic var autoUpload: Bool = false
-    @objc dynamic var autoUploadBackground: Bool = false
     @objc dynamic var autoUploadCreateSubfolder: Bool = false
     @objc dynamic var autoUploadCreateSubfolder: Bool = false
-    @objc dynamic var autoUploadDeleteAssetLocalIdentifier: Bool = false
     @objc dynamic var autoUploadDirectory = ""
     @objc dynamic var autoUploadDirectory = ""
     @objc dynamic var autoUploadFileName = ""
     @objc dynamic var autoUploadFileName = ""
     @objc dynamic var autoUploadFull: Bool = false
     @objc dynamic var autoUploadFull: Bool = false

+ 2 - 2
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -708,14 +708,14 @@ extension NCManageDatabase {
         }
         }
     }
     }
 
 
-    @objc func getAssetLocalIdentifiersUploaded(account: String, sessionSelector: String) -> [String] {
+    @objc func getAssetLocalIdentifiersUploaded(account: String) -> [String] {
 
 
         let realm = try! Realm()
         let realm = try! Realm()
         realm.refresh()
         realm.refresh()
 
 
         var assetLocalIdentifiers: [String] = []
         var assetLocalIdentifiers: [String] = []
 
 
-        let results = realm.objects(tableMetadata.self).filter("account == %@ AND assetLocalIdentifier != '' AND deleteAssetLocalIdentifier == true AND sessionSelector == %@", account, sessionSelector)
+        let results = realm.objects(tableMetadata.self).filter("account == %@ AND assetLocalIdentifier != '' AND deleteAssetLocalIdentifier == true", account)
         for result in results {
         for result in results {
             assetLocalIdentifiers.append(result.assetLocalIdentifier)
             assetLocalIdentifiers.append(result.assetLocalIdentifier)
         }
         }

+ 1 - 1
iOSClient/Data/NCManageDatabase.swift

@@ -149,7 +149,7 @@ class NCManageDatabase: NSObject {
                         }
                         }
                     }
                     }
 
 
-                    if oldSchemaVersion < 220 && NCUtility.shared.SYSTEM_VERSION_LESS_THAN(version: "13") {
+                    if oldSchemaVersion < 222 && NCUtility.shared.SYSTEM_VERSION_LESS_THAN(version: "13") {
                         migration.deleteData(forType: tableMetadata.className())
                         migration.deleteData(forType: tableMetadata.className())
                         migration.deleteData(forType: tableDirectory.className())
                         migration.deleteData(forType: tableDirectory.className())
                     }
                     }

+ 0 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -415,7 +415,6 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                 metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                 metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                 metadataForUpload.session = self.session
                 metadataForUpload.session = self.session
                 metadataForUpload.sessionSelector = NCGlobal.shared.selectorUploadFile
                 metadataForUpload.sessionSelector = NCGlobal.shared.selectorUploadFile
-                metadataForUpload.size = NCUtilityFileSystem.shared.getFileSize(asset: asset)
                 metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
                 metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
 
 
                 if livePhoto {
                 if livePhoto {

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -423,7 +423,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
 
 
                 } else {
                 } else {
 
 
-                    CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadataNewFile, notification: false) { metadataNew, fileNamePath in
+                    CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadataNewFile) { metadataNew, fileNamePath in
 
 
                         if metadataNew != nil {
                         if metadataNew != nil {
                             self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!
                             self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -112,7 +112,7 @@ class NCGlobal: NSObject {
     // Database Realm
     // Database Realm
     //
     //
     let databaseDefault                             = "nextcloud.realm"
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 220
+    let databaseSchemaVersion: UInt64               = 222
 
 
     // Intro selector
     // Intro selector
     //
     //

+ 2 - 75
iOSClient/Networking/NCAutoUpload.swift

@@ -25,78 +25,17 @@ import UIKit
 import CoreLocation
 import CoreLocation
 import NCCommunication
 import NCCommunication
 
 
-class NCAutoUpload: NSObject, CLLocationManagerDelegate {
+class NCAutoUpload: NSObject {
     @objc static let shared: NCAutoUpload = {
     @objc static let shared: NCAutoUpload = {
         let instance = NCAutoUpload()
         let instance = NCAutoUpload()
         return instance
         return instance
     }()
     }()
 
 
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    public var locationManager: CLLocationManager?
     private var endForAssetToUpload: Bool = false
     private var endForAssetToUpload: Bool = false
 
 
     // MARK: -
     // MARK: -
 
 
-    @objc func startSignificantChangeUpdates() {
-
-        if locationManager == nil {
-
-            locationManager = CLLocationManager()
-            locationManager?.delegate = self
-            locationManager?.distanceFilter = 10
-        }
-
-        locationManager?.requestAlwaysAuthorization()
-        locationManager?.startMonitoringSignificantLocationChanges()
-    }
-
-    @objc func stopSignificantChangeUpdates() {
-
-        locationManager?.stopMonitoringSignificantLocationChanges()
-    }
-
-    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
-
-        let location = locations.last
-        guard let latitude = location?.coordinate.latitude else { return }
-        guard let longitude = location?.coordinate.longitude else { return }
-
-        NCCommunicationCommon.shared.writeLog("Location manager: latitude \(latitude) longitude \(longitude)")
-
-        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
-            if activeAccount.autoUpload && activeAccount.autoUploadBackground && UIApplication.shared.applicationState == UIApplication.State.background {
-                NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: nil) { hasPermission in
-                    if hasPermission {
-                        self.uploadAssetsNewAndFull(viewController: nil, selector: NCGlobal.shared.selectorUploadAutoUpload, log: "Change location") { items in
-                            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUpdateBadgeNumber)
-                            if items > 0 {
-                                self.appDelegate.networkingProcessUpload?.startProcess()
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
-        if CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways {
-            NCManageDatabase.shared.setAccountAutoUploadProperty("autoUploadBackground", state: false)
-            self.stopSignificantChangeUpdates()
-        }
-    }
-
-    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
-        NCAskAuthorization.shared.askAuthorizationLocationManager { hasFullPermissions in
-            if !hasFullPermissions {
-                NCManageDatabase.shared.setAccountAutoUploadProperty("autoUploadBackground", state: false)
-                self.stopSignificantChangeUpdates()
-            }
-        }
-    }
-
-    // MARK: -
-
     @objc func initAutoUpload(viewController: UIViewController?, completion: @escaping (_ items: Int) -> Void) {
     @objc func initAutoUpload(viewController: UIViewController?, completion: @escaping (_ items: Int) -> Void) {
         if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
         if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
             if activeAccount.autoUpload {
             if activeAccount.autoUpload {
@@ -108,19 +47,9 @@ class NCAutoUpload: NSObject, CLLocationManagerDelegate {
                             }
                             }
                             completion(items)
                             completion(items)
                         }
                         }
-                        if activeAccount.autoUploadBackground {
-                            NCAskAuthorization.shared.askAuthorizationLocationManager { hasFullPermissions in
-                                if hasFullPermissions {
-                                    self.startSignificantChangeUpdates()
-                                } else {
-                                    NCManageDatabase.shared.setAccountAutoUploadProperty("autoUploadBackground", state: false)
-                                    self.stopSignificantChangeUpdates()
-                                }
-                            }
-                        }
+
                     } else {
                     } else {
                         NCManageDatabase.shared.setAccountAutoUploadProperty("autoUpload", state: false)
                         NCManageDatabase.shared.setAccountAutoUploadProperty("autoUpload", state: false)
-                        self.stopSignificantChangeUpdates()
                         completion(0)
                         completion(0)
                     }
                     }
                 }
                 }
@@ -128,7 +57,6 @@ class NCAutoUpload: NSObject, CLLocationManagerDelegate {
                 completion(0)
                 completion(0)
             }
             }
         } else {
         } else {
-            stopSignificantChangeUpdates()
             completion(0)
             completion(0)
         }
         }
     }
     }
@@ -241,7 +169,6 @@ class NCAutoUpload: NSObject, CLLocationManagerDelegate {
                         metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                         metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                         metadataForUpload.session = session
                         metadataForUpload.session = session
                         metadataForUpload.sessionSelector = selector
                         metadataForUpload.sessionSelector = selector
-                        metadataForUpload.size = NCUtilityFileSystem.shared.getFileSize(asset: asset)
                         metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
                         metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
                         if assetMediaType == PHAssetMediaType.video {
                         if assetMediaType == PHAssetMediaType.video {
                             metadataForUpload.classFile = NCCommunicationCommon.typeClassFile.video.rawValue
                             metadataForUpload.classFile = NCCommunicationCommon.typeClassFile.video.rawValue

+ 17 - 6
iOSClient/Networking/NCNetworking.swift

@@ -413,10 +413,22 @@ import Queuer
     @objc func upload(metadata: tableMetadata, start: @escaping () -> Void, completion: @escaping (_ errorCode: Int, _ errorDescription: String) -> Void) {
     @objc func upload(metadata: tableMetadata, start: @escaping () -> Void, completion: @escaping (_ errorCode: Int, _ errorDescription: String) -> Void) {
         
         
         func uploadMetadata(_ metadata: tableMetadata) {
         func uploadMetadata(_ metadata: tableMetadata) {
-            
+
+            // DETECT IF CHUNCK
+            let chunckSize = CCUtility.getChunkSize() * 1000000
+            if metadata.size > chunckSize {
+                metadata.chunk = true
+                metadata.session = NCCommunicationCommon.shared.sessionIdentifierUpload
+            }
+
+            // DETECT IF E2EE
+            if CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase) {
+                metadata.e2eEncrypted = true
+            }
+
             NCManageDatabase.shared.addMetadata(metadata)
             NCManageDatabase.shared.addMetadata(metadata)
             let metadata = tableMetadata.init(value: metadata)
             let metadata = tableMetadata.init(value: metadata)
-            
+
             if metadata.e2eEncrypted {
             if metadata.e2eEncrypted {
 #if !EXTENSION_FILE_PROVIDER_EXTENSION
 #if !EXTENSION_FILE_PROVIDER_EXTENSION
                 NCNetworkingE2EE.shared.upload(metadata: metadata, start: start) { errorCode, errorDescription in
                 NCNetworkingE2EE.shared.upload(metadata: metadata, start: start) { errorCode, errorDescription in
@@ -448,7 +460,7 @@ import Queuer
         
         
         let metadata = tableMetadata.init(value: metadata)
         let metadata = tableMetadata.init(value: metadata)
 
 
-        if CCUtility.fileProviderStorageExists(metadata) {
+        if metadata.assetLocalIdentifier.isEmpty {
 
 
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
             let results = NCCommunicationCommon.shared.getInternalType(fileName: metadata.fileNameView, mimeType: metadata.contentType, directory: false)
             let results = NCCommunicationCommon.shared.getInternalType(fileName: metadata.fileNameView, mimeType: metadata.contentType, directory: false)
@@ -467,7 +479,7 @@ import Queuer
 
 
         } else {
         } else {
 
 
-            CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadata, notification: true) { extractMetadata, fileNamePath in
+            CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadata) { extractMetadata, fileNamePath in
 
 
                 guard let metadata = extractMetadata else {
                 guard let metadata = extractMetadata else {
                     NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                     NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
@@ -577,7 +589,6 @@ import Queuer
         }
         }
 
 
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(description) else { return }
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(description) else { return }
-        guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", metadata.account)) else { return }
         let ocIdTemp = metadata.ocId
         let ocIdTemp = metadata.ocId
         var errorDescription = errorDescription
         var errorDescription = errorDescription
 
 
@@ -601,7 +612,7 @@ import Queuer
             metadata.status = NCGlobal.shared.metadataStatusNormal
             metadata.status = NCGlobal.shared.metadataStatusNormal
 
 
             // Delete Asset on Photos album
             // Delete Asset on Photos album
-            if tableAccount.autoUploadDeleteAssetLocalIdentifier && metadata.assetLocalIdentifier != "" && metadata.sessionSelector == NCGlobal.shared.selectorUploadAutoUpload {
+            if CCUtility.getRemovePhotoCameraRoll() && !metadata.assetLocalIdentifier.isEmpty {
                 metadata.deleteAssetLocalIdentifier = true
                 metadata.deleteAssetLocalIdentifier = true
             }
             }
 
 

+ 6 - 0
iOSClient/Networking/NCNetworkingChunkedUpload.swift

@@ -149,6 +149,7 @@ extension NCNetworking {
                         if errorCode == 0 {
                         if errorCode == 0 {
 
 
                             let serverUrl = metadata.serverUrl
                             let serverUrl = metadata.serverUrl
+                            let assetLocalIdentifier = metadata.assetLocalIdentifier
 
 
                             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                             NCManageDatabase.shared.deleteChunks(account: metadata.account, ocId: metadata.ocId)
                             NCManageDatabase.shared.deleteChunks(account: metadata.account, ocId: metadata.ocId)
@@ -158,6 +159,11 @@ extension NCNetworking {
 
 
                                 if errorCode == 0, let metadata = metadata {
                                 if errorCode == 0, let metadata = metadata {
 
 
+                                    metadata.assetLocalIdentifier = assetLocalIdentifier
+                                    // Delete Asset on Photos album
+                                    if CCUtility.getRemovePhotoCameraRoll() && !metadata.assetLocalIdentifier.isEmpty {
+                                        metadata.deleteAssetLocalIdentifier = true
+                                    }
                                     NCManageDatabase.shared.addMetadata(metadata)
                                     NCManageDatabase.shared.addMetadata(metadata)
                                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": serverUrl])
                                     NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": serverUrl])
 
 

+ 4 - 19
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -160,11 +160,9 @@ class NCNetworkingProcessUpload: NSObject {
                 }
                 }
             }
             }
              
              
-            
-            
             // verify delete Asset Local Identifiers in auto upload (DELETE Photos album)
             // verify delete Asset Local Identifiers in auto upload (DELETE Photos album)
             if (counterUpload == 0 && !self.appDelegate.isPasscodePresented()) {
             if (counterUpload == 0 && !self.appDelegate.isPasscodePresented()) {
-                self.deleteAssetLocalIdentifiers(account: self.appDelegate.account, sessionSelector: NCGlobal.shared.selectorUploadAutoUpload) {
+                self.deleteAssetLocalIdentifiers(account: self.appDelegate.account) {
                     self.startTimer()
                     self.startTimer()
                 }
                 }
             } else {
             } else {
@@ -173,7 +171,7 @@ class NCNetworkingProcessUpload: NSObject {
         }
         }
     }
     }
 
 
-    private func deleteAssetLocalIdentifiers(account: String, sessionSelector: String, completition: @escaping () -> Void) {
+    private func deleteAssetLocalIdentifiers(account: String, completition: @escaping () -> Void) {
 
 
         if UIApplication.shared.applicationState != .active {
         if UIApplication.shared.applicationState != .active {
             completition()
             completition()
@@ -184,7 +182,7 @@ class NCNetworkingProcessUpload: NSObject {
             completition()
             completition()
             return
             return
         }
         }
-        let localIdentifiers = NCManageDatabase.shared.getAssetLocalIdentifiersUploaded(account: account, sessionSelector: sessionSelector)
+        let localIdentifiers = NCManageDatabase.shared.getAssetLocalIdentifiersUploaded(account: account)
         if localIdentifiers.isEmpty {
         if localIdentifiers.isEmpty {
             completition()
             completition()
             return
             return
@@ -215,20 +213,7 @@ class NCNetworkingProcessUpload: NSObject {
                 }
                 }
             }
             }
 
 
-            // E2EE
-            if CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase) {
-                metadata.e2eEncrypted = true
-            }
-
-            // CHUNCK
-            let chunckSize = CCUtility.getChunkSize() * 1000000
-            if chunckSize == 0 || metadata.size <= chunckSize {
-                metadatasForUpload.append(metadata)
-            } else {
-                metadata.chunk = true
-                metadata.session = NCCommunicationCommon.shared.sessionIdentifierUpload
-                metadatasForUpload.append(tableMetadata.init(value: metadata))
-            }
+            metadatasForUpload.append(metadata)
         }
         }
 
 
         NCManageDatabase.shared.addMetadatas(metadatasForUpload)
         NCManageDatabase.shared.addMetadatas(metadatasForUpload)

+ 15 - 2
iOSClient/Settings/CCAdvanced.m

@@ -54,11 +54,11 @@
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [section addFormRow:row];
     [section addFormRow:row];
     
     
-    // Format Compatibility + Live Photo
+    // Format Compatibility + Live Photo + Delete asset
     
     
     section = [XLFormSectionDescriptor formSection];
     section = [XLFormSectionDescriptor formSection];
     [form addFormSection:section];
     [form addFormSection:section];
-    section.footerTitle = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil)];
+    section.footerTitle = [NSString stringWithFormat:@"%@\n%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil), NSLocalizedString(@"_remove_photo_CameraRoll_desc_", nil)];
 
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
     row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
     row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
@@ -75,6 +75,14 @@
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [section addFormRow:row];
     [section addFormRow:row];
+
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
+    row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
+    if ([CCUtility getRemovePhotoCameraRoll]) 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];
     
     
     // Disable Local Cache After Upload
     // Disable Local Cache After Upload
     
     
@@ -351,6 +359,11 @@
         
         
         [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
         [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
     }
     }
+
+    if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
+
+        [CCUtility setRemovePhotoCameraRoll:[[rowDescriptor.value valueData] boolValue]];
+    }
     
     
     if ([rowDescriptor.tag isEqualToString:@"disableLocalCacheAfterUpload"]) {
     if ([rowDescriptor.tag isEqualToString:@"disableLocalCacheAfterUpload"]) {
         
         

+ 3 - 88
iOSClient/Settings/CCManageAutoUpload.m

@@ -118,34 +118,6 @@
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
     [section addFormRow:row];
     [section addFormRow:row];
     
     
-    // Delete asset
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
-    row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
-    row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-    if (activeAccount.autoUploadDeleteAssetLocalIdentifier) 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];
-    
-    // Auto Upload Background
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadBackground" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_background_", nil)];
-    row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
-    row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-    if (activeAccount.autoUploadBackground) 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];
-    
     // Auto Upload Full
     // Auto Upload Full
     section = [XLFormSectionDescriptor formSection];
     section = [XLFormSectionDescriptor formSection];
     [form addFormSection:section];
     [form addFormSection:section];
@@ -267,41 +239,6 @@
         
         
         [self reloadForm];
         [self reloadForm];
     }
     }
-    
-    if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
-        
-        [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadDeleteAssetLocalIdentifier" state:[[rowDescriptor.value valueData] boolValue]];
-    }
-    
-    if ([rowDescriptor.tag isEqualToString:@"autoUploadBackground"]) {
-        
-        if ([[rowDescriptor.value valueData] boolValue] == YES) {
-                        
-            [[NCAskAuthorization shared]  askAuthorizationLocationManagerWithCompletion: ^(BOOL hasFullPermissions) {
-                
-                if (hasFullPermissions == YES) {
-                    
-                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_autoupload_background_title_", nil) message:NSLocalizedString(@"_autoupload_background_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
-                    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
-                    
-                    [alertController addAction:okAction];
-                    [self presentViewController:alertController animated:YES completion:nil];
-                    
-                    [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:YES];
-                    [[NCAutoUpload shared] startSignificantChangeUpdates];
-                        
-                } else {
-                     
-                    [self reloadForm];
-                }
-            }];
-            
-        } else {
-            
-            [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
-            [[NCAutoUpload shared] stopSignificantChangeUpdates];
-        }
-    }
 
 
     if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {
     if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {
         
         
@@ -367,11 +304,7 @@
     
     
     XLFormRowDescriptor *rowAutoUploadVideo = [self.form formRowWithTag:@"autoUploadVideo"];
     XLFormRowDescriptor *rowAutoUploadVideo = [self.form formRowWithTag:@"autoUploadVideo"];
     XLFormRowDescriptor *rowAutoUploadWWAnVideo = [self.form formRowWithTag:@"autoUploadWWAnVideo"];
     XLFormRowDescriptor *rowAutoUploadWWAnVideo = [self.form formRowWithTag:@"autoUploadWWAnVideo"];
-    
-    XLFormRowDescriptor *rowRemovePhotoCameraRoll = [self.form formRowWithTag:@"removePhotoCameraRoll"];
 
 
-    XLFormRowDescriptor *rowAutoUploadBackground = [self.form formRowWithTag:@"autoUploadBackground"];
-    
     XLFormRowDescriptor *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];
     XLFormRowDescriptor *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];
     
     
     XLFormRowDescriptor *rowAutoUploadCreateSubfolder = [self.form formRowWithTag:@"autoUploadCreateSubfolder"];
     XLFormRowDescriptor *rowAutoUploadCreateSubfolder = [self.form formRowWithTag:@"autoUploadCreateSubfolder"];
@@ -395,13 +328,7 @@
     
     
     if (activeAccount.autoUploadWWAnVideo)
     if (activeAccount.autoUploadWWAnVideo)
         [rowAutoUploadWWAnVideo setValue:@1]; else [rowAutoUploadWWAnVideo setValue:@0];
         [rowAutoUploadWWAnVideo setValue:@1]; else [rowAutoUploadWWAnVideo setValue:@0];
-    
-    if (activeAccount.autoUploadDeleteAssetLocalIdentifier)
-           [rowRemovePhotoCameraRoll setValue:@1]; else [rowRemovePhotoCameraRoll setValue:@0];
-    
-    if (activeAccount.autoUploadBackground)
-        [rowAutoUploadBackground setValue:@1]; else [rowAutoUploadBackground setValue:@0];
-    
+
     if (activeAccount.autoUploadFull)
     if (activeAccount.autoUploadFull)
         [rowAutoUploadFull setValue:@1]; else [rowAutoUploadFull setValue:@0];
         [rowAutoUploadFull setValue:@1]; else [rowAutoUploadFull setValue:@0];
     
     
@@ -415,11 +342,7 @@
     
     
     rowAutoUploadVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadWWAnVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadWWAnVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-    
-    rowRemovePhotoCameraRoll.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
 
 
-    rowAutoUploadBackground.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
-    
     rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     
     
     rowAutoUploadCreateSubfolder.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadCreateSubfolder.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
@@ -453,22 +376,14 @@
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;
         case 4:
         case 4:
-            if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_remove_photo_CameraRoll_desc_", nil);
-            else sectionName = @"";
-            break;
-        case 5:
-            if (activeAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_description_background_", nil);
-            else sectionName = @"";
-            break;
-        case 6:
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_fullphotos_footer_", nil);
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_fullphotos_footer_", nil);
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;
-        case 7:
+        case 5:
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_create_subfolder_footer_", nil);
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_create_subfolder_footer_", nil);
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;
-        case 8:
+        case 6:
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;

+ 1 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -442,7 +442,7 @@
 "_error_createsubfolders_upload_"           = "Error creating subfolders";
 "_error_createsubfolders_upload_"           = "Error creating subfolders";
 "_activate_autoupload_"                     = "Enable auto upload";
 "_activate_autoupload_"                     = "Enable auto upload";
 "_remove_photo_CameraRoll_"                 = "Remove from camera roll";
 "_remove_photo_CameraRoll_"                 = "Remove from camera roll";
-"_remove_photo_CameraRoll_desc_"            = "After successful automatic uploads, a confirmation message will be displayed to delete the uploaded photos or videos from the camera roll. The deleted photos or videos will still be available in the iOS Photos Trash for 30 days.";
+"_remove_photo_CameraRoll_desc_"            = "\"Remove from camera roll\" after uploads, a confirmation message will be displayed to delete the uploaded photos or videos from the camera roll. The deleted photos or videos will still be available in the iOS Photos Trash for 30 days.";
 "_never_"                       = "never";
 "_never_"                       = "never";
 "_less_a_minute_"               = "less than a minute ago";
 "_less_a_minute_"               = "less than a minute ago";
 "_a_minute_ago_"                = "a minute ago";
 "_a_minute_ago_"                = "a minute ago";

+ 4 - 1
iOSClient/Utility/CCUtility.h

@@ -183,6 +183,9 @@
 + (BOOL)getPrivacyScreenEnabled;
 + (BOOL)getPrivacyScreenEnabled;
 + (void)setPrivacyScreenEnabled:(BOOL)set;
 + (void)setPrivacyScreenEnabled:(BOOL)set;
 
 
++ (BOOL)getRemovePhotoCameraRoll;
++ (void)setRemovePhotoCameraRoll:(BOOL)set;
+
 // ===== Varius =====
 // ===== Varius =====
 
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@@ -240,7 +243,7 @@
 
 
 + (NSString *)getMimeType:(NSString *)fileNameView;
 + (NSString *)getMimeType:(NSString *)fileNameView;
 
 
-+ (void)extractImageVideoFromAssetLocalIdentifierForUpload:(tableMetadata *)metadataForUpload notification:(BOOL)notification completion:(void(^)(tableMetadata *newMetadata, NSString* fileNamePath))completion;
++ (void)extractImageVideoFromAssetLocalIdentifierForUpload:(tableMetadata *)metadataForUpload completion:(void(^)(tableMetadata *newMetadata, NSString* fileNamePath))completion;
 + (void)extractLivePhotoAsset:(PHAsset*)asset filePath:(NSString *)filePath withCompletion:(void (^)(NSURL* url))completion;
 + (void)extractLivePhotoAsset:(PHAsset*)asset filePath:(NSString *)filePath withCompletion:(void (^)(NSURL* url))completion;
 
 
 // ===== E2E Encrypted =====
 // ===== E2E Encrypted =====

+ 15 - 21
iOSClient/Utility/CCUtility.m

@@ -734,6 +734,17 @@
     [UICKeyChainStore setString:sSet forKey:@"privacyScreen" service:NCGlobal.shared.serviceShareKeyChain];
     [UICKeyChainStore setString:sSet forKey:@"privacyScreen" service:NCGlobal.shared.serviceShareKeyChain];
 }
 }
 
 
++ (BOOL)getRemovePhotoCameraRoll
+{
+    return [[UICKeyChainStore stringForKey:@"removePhotoCameraRoll" service:NCGlobal.shared.serviceShareKeyChain] boolValue];
+}
+
++ (void)setRemovePhotoCameraRoll:(BOOL)set
+{
+    NSString *sSet = (set) ? @"true" : @"false";
+    [UICKeyChainStore setString:sSet forKey:@"removePhotoCameraRoll" service:NCGlobal.shared.serviceShareKeyChain];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
@@ -1332,7 +1343,7 @@
     return path;
     return path;
 }
 }
 
 
-+ (void)extractImageVideoFromAssetLocalIdentifierForUpload:(tableMetadata *)metadataForUpload notification:(BOOL)notification completion:(void(^)(tableMetadata *metadata, NSString* fileNamePath))completion
++ (void)extractImageVideoFromAssetLocalIdentifierForUpload:(tableMetadata *)metadataForUpload completion:(void(^)(tableMetadata *metadata, NSString* fileNamePath))completion
 {
 {
     if (metadataForUpload == nil) {
     if (metadataForUpload == nil) {
         return completion(nil, nil);
         return completion(nil, nil);
@@ -1342,10 +1353,6 @@
     
     
     PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadata.assetLocalIdentifier] options:nil];
     PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[metadata.assetLocalIdentifier] options:nil];
     if (!result.count) {
     if (!result.count) {
-        if (notification) {
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(NCGlobal.shared.errorInternalError), @"errorDescription": @"_err_file_not_found_"}];
-        }
-        
         return completion(nil, nil);
         return completion(nil, nil);
     }
     }
     
     
@@ -1367,10 +1374,7 @@
                 NSLog(@"cacheAsset: %f", progress);
                 NSLog(@"cacheAsset: %f", progress);
                 
                 
                 if (error) {
                 if (error) {
-                    if (notification) {
-                        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Image request iCloud failed [%@]", error.description]}];
-                    }
-                    
+                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Image request iCloud failed [%@]", error.description]}];
                     return completion(nil, nil);
                     return completion(nil, nil);
                 }
                 }
             };
             };
@@ -1432,10 +1436,7 @@
                 NSLog(@"cacheAsset: %f", progress);
                 NSLog(@"cacheAsset: %f", progress);
                 
                 
                 if (error) {
                 if (error) {
-                    if (notification) {
-                        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Video request iCloud failed [%@]", error.description]}];
-                    }
-                    
+                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Video request iCloud failed [%@]", error.description]}];
                     completion(nil, nil);
                     completion(nil, nil);
                 }
                 }
             };
             };
@@ -1456,19 +1457,12 @@
                     dispatch_async(dispatch_get_main_queue(), ^{
                     dispatch_async(dispatch_get_main_queue(), ^{
                         
                         
                         if (error) {
                         if (error) {
-                            
-                            if (notification) {
-                                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Video request iCloud failed [%@]", error.description]}];
-                            }
-                            
+                            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterUploadedFile object:nil userInfo:@{@"ocId": metadata.ocId, @"errorCode": @(error.code), @"errorDescription": [NSString stringWithFormat:@"Video request iCloud failed [%@]", error.description]}];
                             completion(nil, nil);
                             completion(nil, nil);
-                            
                         } else {
                         } else {
-                            
                             metadata.creationDate = creationDate;
                             metadata.creationDate = creationDate;
                             metadata.date = modificationDate;
                             metadata.date = modificationDate;
                             metadata.size = [[NCUtilityFileSystem shared] getFileSizeWithFilePath:fileNamePath];
                             metadata.size = [[NCUtilityFileSystem shared] getFileSizeWithFilePath:fileNamePath];
-                            
                             completion(metadata, fileNamePath);
                             completion(metadata, fileNamePath);
                         }
                         }
                     });
                     });

+ 0 - 29
iOSClient/Utility/NCAskAuthorization.swift

@@ -107,33 +107,4 @@ class NCAskAuthorization: NSObject {
             break
             break
         }
         }
     }
     }
-
-    @objc func askAuthorizationLocationManager(completion: @escaping (_ hasFullPermissions: Bool) -> Void) {
-
-        switch CLLocationManager.authorizationStatus() {
-        case CLAuthorizationStatus.authorizedAlways:
-            completion(true)
-            break
-        /*
-        case CLAuthorizationStatus.authorizedWhenInUse, CLAuthorizationStatus.denied, CLAuthorizationStatus.restricted:
-            DispatchQueue.main.async {
-                NCAutoUpload.shared.startSignificantChangeUpdates()
-            }
-            completion(false)
-            break
-        case CLAuthorizationStatus.notDetermined:
-            DispatchQueue.main.async {
-                NCAutoUpload.shared.startSignificantChangeUpdates()
-            }
-            completion(false)
-            break
-        */
-        default:
-            DispatchQueue.main.async {
-                NCAutoUpload.shared.startSignificantChangeUpdates()
-            }
-            completion(false)
-            break
-        }
-    }
 }
 }

+ 0 - 14
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -32,20 +32,6 @@ class NCUtilityFileSystem: NSObject {
 
 
     let fileManager = FileManager.default
     let fileManager = FileManager.default
 
 
-    @objc func getFileSize(asset: PHAsset) -> Int64 {
-
-        let resources = PHAssetResource.assetResources(for: asset)
-
-        if let resource = resources.first {
-            if resource.responds(to: #selector(NSDictionary.fileSize)) {
-                let unsignedInt64 = resource.value(forKey: "fileSize") as! CLong
-                return Int64(bitPattern: UInt64(unsignedInt64))
-            }
-        }
-
-        return 0
-    }
-
     @objc func getFileSize(filePath: String) -> Int64 {
     @objc func getFileSize(filePath: String) -> Int64 {
 
 
         do {
         do {