Эх сурвалжийг харах

Improvements delete Asset on Photos album

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 жил өмнө
parent
commit
d5391d64df

+ 0 - 1
iOSClient/Data/NCDatabase.swift

@@ -38,7 +38,6 @@ class tableAccount: Object, NCUserBaseUrl {
     @objc dynamic var alias = ""
     @objc dynamic var alias = ""
     @objc dynamic var autoUpload: Bool = false
     @objc dynamic var autoUpload: 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())
                     }
                     }

+ 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               = 221
+    let databaseSchemaVersion: UInt64               = 222
 
 
     // Intro selector
     // Intro selector
     //
     //

+ 1 - 2
iOSClient/Networking/NCNetworking.swift

@@ -577,7 +577,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 +600,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
             }
             }
 
 

+ 3 - 5
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

+ 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"]) {
         
         

+ 2 - 32
iOSClient/Settings/CCManageAutoUpload.m

@@ -118,20 +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 Full
     // Auto Upload Full
     section = [XLFormSectionDescriptor formSection];
     section = [XLFormSectionDescriptor formSection];
     [form addFormSection:section];
     [form addFormSection:section];
@@ -253,11 +239,6 @@
         
         
         [self reloadForm];
         [self reloadForm];
     }
     }
-    
-    if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
-        
-        [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadDeleteAssetLocalIdentifier" state:[[rowDescriptor.value valueData] boolValue]];
-    }
 
 
     if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {
     if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {
         
         
@@ -323,8 +304,6 @@
     
     
     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 *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];
     XLFormRowDescriptor *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];
     
     
@@ -349,9 +328,6 @@
     
     
     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.autoUploadFull)
     if (activeAccount.autoUploadFull)
         [rowAutoUploadFull setValue:@1]; else [rowAutoUploadFull setValue:@0];
         [rowAutoUploadFull setValue:@1]; else [rowAutoUploadFull setValue:@0];
@@ -366,8 +342,6 @@
     
     
     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"];
 
 
     rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     
     
@@ -402,18 +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_fullphotos_footer_", nil);
             if (activeAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_fullphotos_footer_", nil);
             else sectionName = @"";
             else sectionName = @"";
             break;
             break;
-        case 6:
+        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 7:
+        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";

+ 3 - 0
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;

+ 11 - 0
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 --------------------------------------------------------------------------------------------