浏览代码

Add new option Auto upload : Detect modified photo/video

Marino Faggiana 7 年之前
父节点
当前提交
a2f065c4bd

+ 13 - 4
iOSClient/AutoUpload/NCAutoUpload.m

@@ -568,10 +568,11 @@
             
             if (assetsFull == NO) {
             
+                NSPredicate *predicate;
                 NSString *creationDate;
                 NSString *modificationDate;
-                NSString *idAsset;
-                
+                BOOL detectModificationDateCameraRollAsset = [CCUtility getDetectModificationDateCameraRollAsset];
+
                 NSArray *idsAsset = [[NCManageDatabase sharedInstance] getPhotoLibraryIdAssetWithImage:account.autoUploadImage video:account.autoUploadVideo];
                 
                 for (PHAsset *asset in assets) {
@@ -579,9 +580,17 @@
                     (asset.creationDate != nil) ? (creationDate = [NSString stringWithFormat:@"%@", asset.creationDate]) : (creationDate = @"");
                     (asset.modificationDate != nil) ? (modificationDate = [NSString stringWithFormat:@"%@", asset.modificationDate]) : (modificationDate = @"");
                     
-                    idAsset = [NSString stringWithFormat:@"%@%@%@%@", account.account, asset.localIdentifier, creationDate, modificationDate];
+                    if (detectModificationDateCameraRollAsset) {
+                        NSString *idAsset = [NSString stringWithFormat:@"%@%@%@%@", account.account, asset.localIdentifier, creationDate, modificationDate];
+                        predicate = [NSPredicate predicateWithFormat:@"SELF = %@", idAsset];
+                    } else {
+                        NSString *idAsset = [NSString stringWithFormat:@"%@%@%@", account.account, asset.localIdentifier, creationDate];
+                        predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", idAsset];
+                    }
+                    
+                    NSArray *filteredArray = [idsAsset filteredArrayUsingPredicate: predicate];
                     
-                    if (![idsAsset containsObject: idAsset])
+                    if ([filteredArray count] == 0)
                         [newAssets addObject:asset];
                 }
                 

+ 1 - 0
iOSClient/Photos/CCPhotos.m

@@ -90,6 +90,7 @@
     // Plus Button
     [app plusButtonVisibile:true];
 
+    
     [self reloadDatasource];
 }
 

+ 28 - 1
iOSClient/Settings/CCManageAutoUpload.m

@@ -165,6 +165,18 @@
     row.action.viewControllerClass = [NCManageAutoUploadFileName class];
     [section addFormRow:row];
     
+    // Detect Modification Date CameraRoll Asset
+    
+    section = [XLFormSectionDescriptor formSection];
+    [form addFormSection:section];
+    
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"detectModificationDateCameraRollAsset" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_detectModificationAsset_", nil)];
+    row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
+    if ([CCUtility getDetectModificationDateCameraRollAsset]) row.value = @1;
+    else row.value = @0;
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [section addFormRow:row];
+
     // end
     
     section = [XLFormSectionDescriptor formSection];
@@ -316,6 +328,11 @@
         
         [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadCreateSubfolder" state:[[rowDescriptor.value valueData] boolValue]];
     }
+    
+    if ([rowDescriptor.tag isEqualToString:@"detectModificationDateCameraRollAsset"]) {
+        
+        [CCUtility setDetectModificationDateCameraRollAsset:[[rowDescriptor.value valueData] boolValue]];
+    }
 }
 
 - (void)done:(XLFormRowDescriptor *)sender
@@ -342,8 +359,9 @@
     XLFormRowDescriptor *rowAutoUploadCreateSubfolder = [self.form formRowWithTag:@"autoUploadCreateSubfolder"];
 
     XLFormRowDescriptor *rowAutoUploadFileName = [self.form formRowWithTag:@"autoUploadFileName"];
-
     
+    XLFormRowDescriptor *rowDetectModificationDateCameraRollAsset = [self.form formRowWithTag:@"detectModificationDateCameraRollAsset"];
+
     // - STATUS ---------------------
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     
@@ -371,6 +389,9 @@
     if (tableAccount.autoUploadCreateSubfolder)
         [rowAutoUploadCreateSubfolder setValue:@1]; else [rowAutoUploadCreateSubfolder setValue:@0];
     
+    if ([CCUtility getDetectModificationDateCameraRollAsset])
+        [rowDetectModificationDateCameraRollAsset setValue:@1]; else [rowDetectModificationDateCameraRollAsset setValue:@0];
+
     // - HIDDEN ---------------------
     
     rowAutoUploadImage.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
@@ -386,6 +407,8 @@
     rowAutoUploadCreateSubfolder.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
     
     rowAutoUploadFileName.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
+    
+    rowDetectModificationDateCameraRollAsset.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
 
     // ----------------------
     
@@ -420,6 +443,10 @@
             if (tableAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
             else sectionName = @"";
             break;
+        case 7:
+            if (tableAccount.autoUpload) sectionName =  NSLocalizedString(@"_autoupload_detectModificationAsset_footer_", nil);
+            else sectionName = @"";
+            break;
     }
     return sectionName;
 }

+ 3 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -178,6 +178,9 @@
 "_autoupload_create_subfolder_footer_" = "Store in subfolders based on year and month";
 "_autoupload_filenamemask_"         = "Change filename mask";
 "_autoupload_filenamemask_footer_"  = "Change the automatic filename mask";
+"_autoupload_detectModificationAsset_" = "Detect modified photo/video";
+"_autoupload_detectModificationAsset_footer_" = "In addition to detecting new photos/videos it also detects modified photos/videos";
+
 
 // Manage Crypto Cloud
 

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -93,6 +93,7 @@
 
 + (void)setShowHiddenFiles:(BOOL)show;
 
++ (void)setDetectModificationDateCameraRollAsset:(BOOL)detect;
 
 // GET
 
@@ -140,6 +141,8 @@
 
 + (BOOL)getShowHiddenFiles;
 
++ (BOOL)getDetectModificationDateCameraRollAsset;
+
 // ===== Varius =====
 
 + (NSString *)getUserAgent;

+ 11 - 0
iOSClient/Utility/CCUtility.m

@@ -227,6 +227,12 @@
     [UICKeyChainStore setString:sShow forKey:@"showHiddenFiles" service:k_serviceShareKeyChain];
 }
 
++ (void)setDetectModificationDateCameraRollAsset:(BOOL)detect
+{
+    NSString *sDetect = (detect) ? @"true" : @"false";
+    [UICKeyChainStore setString:sDetect forKey:@"detectModificationDateCameraRollAsset" service:k_serviceShareKeyChain];
+}
+
 #pragma ------------------------------ GET
 
 + (NSString *)getKeyChainPasscodeForUUID:(NSString *)uuid
@@ -431,6 +437,11 @@
     return [[UICKeyChainStore stringForKey:@"showHiddenFiles" service:k_serviceShareKeyChain] boolValue];
 }
 
++ (BOOL)getDetectModificationDateCameraRollAsset
+{
+    return [[UICKeyChainStore stringForKey:@"detectModificationDateCameraRollAsset" service:k_serviceShareKeyChain] boolValue];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Varius =====
 #pragma --------------------------------------------------------------------------------------------