Browse Source

Removed the option "Favorite available offline", use the option "Set available offline"

marinofaggiana 4 years ago
parent
commit
1184c5f88a

+ 3 - 11
iOSClient/Favorites/NCFavorite.swift

@@ -77,16 +77,7 @@ class NCFavorite: NCCollectionViewCommon  {
         if serverUrl == "" {
             
             NCNetworking.shared.listingFavoritescompletion(selector: NCBrandGlobal.shared.selectorListingFavorite) { (account, metadatas, errorCode, errorDescription) in
-                if errorCode == 0 {
-                    for metadata in metadatas ?? [] {
-                        if !metadata.directory && CCUtility.getFavoriteOffline() {
-                            let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                            if localFile == nil || localFile?.etag != metadata.etag {
-                                NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorDownloadFile, setFavorite: false)
-                            }
-                        }
-                    }
-                } else {
+                if errorCode != 0 {
                     NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCBrandGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
                 }
                 
@@ -102,7 +93,8 @@ class NCFavorite: NCCollectionViewCommon  {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {
                             let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                            if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
+                            let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+                            if localFile != nil && (localFile?.etag != metadata.etag || fileSize == 0) {
                                 NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorDownloadFile, setFavorite: false)
                             }
                         }

+ 2 - 1
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -133,7 +133,8 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
                 for metadata in metadatas ?? [] {
                     if !metadata.directory {
                         let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                        if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
+                        let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+                        if localFile != nil && (localFile?.etag != metadata.etag || fileSize == 0) {
                             NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorDownloadFile, setFavorite: false)
                         }
                     }

+ 2 - 1
iOSClient/Files/NCFiles.swift

@@ -100,7 +100,8 @@ class NCFiles: NCCollectionViewCommon  {
                 for metadata in metadatas ?? [] {
                     if !metadata.directory {
                         let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                        if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
+                        let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+                        if localFile != nil && (localFile?.etag != metadata.etag || fileSize == 0) {
                             NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorDownloadFile, setFavorite: false)
                         }
                     }

+ 1 - 5
iOSClient/Networking/NCNetworking.swift

@@ -1034,11 +1034,7 @@ import Queuer
                 
                 #if !EXTENSION
                 if favorite {
-                    if CCUtility.getFavoriteOffline() {
-                        NCOperationQueue.shared.synchronizationMetadata(metadata, selector: NCBrandGlobal.shared.selectorDownloadAllFile)
-                    } else {
-                        NCOperationQueue.shared.synchronizationMetadata(metadata, selector: NCBrandGlobal.shared.selectorReadFile)
-                    }
+                    NCOperationQueue.shared.synchronizationMetadata(metadata, selector: NCBrandGlobal.shared.selectorReadFile)
                 }
                 #endif
                 

+ 3 - 2
iOSClient/Networking/NCOperationQueue.swift

@@ -333,7 +333,7 @@ class NCOperationSynchronization: ConcurrentOperation {
                             } else {
                                 let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                                 let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
-                                if localFile == nil || localFile?.etag != metadata.etag || fileSize == 0 {
+                                if localFile == nil && (localFile?.etag != metadata.etag || fileSize == 0) {
                                     NCOperationQueue.shared.download(metadata: metadata, selector: self.selector, setFavorite: false)
                                 }
                             }
@@ -346,7 +346,8 @@ class NCOperationSynchronization: ConcurrentOperation {
             } else {
                 if self.download {
                     let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                    if localFile == nil || localFile?.etag != metadata.etag {
+                    let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+                    if localFile == nil || localFile?.etag != metadata.etag || fileSize == 0 {
                         NCOperationQueue.shared.download(metadata: metadata, selector: self.selector, setFavorite: false)
                     }
                 }

+ 2 - 6
iOSClient/Networking/NCService.swift

@@ -67,12 +67,8 @@ class NCService: NSObject {
                     
                     self.appDelegate.settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userID: tableAccount.userID, password: CCUtility.getPassword(tableAccount.account))
                        
-                    // Synchronize favorite
-                    var selector = NCBrandGlobal.shared.selectorReadFile
-                    if CCUtility.getFavoriteOffline() {
-                        selector = NCBrandGlobal.shared.selectorDownloadFile
-                    }
-                    NCNetworking.shared.listingFavoritescompletion(selector: selector) { (_, _, _, _) in }
+                    // Synchronize favorite                    
+                    NCNetworking.shared.listingFavoritescompletion(selector: NCBrandGlobal.shared.selectorReadFile) { (_, _, _, _) in }
                 
                     // Synchronize Offline Directory
                     if let directories = NCManageDatabase.shared.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", tableAccount.account), sorted: "serverUrl", ascending: true) {

+ 2 - 1
iOSClient/Offline/NCOffline.swift

@@ -101,7 +101,8 @@ class NCOffline: NCCollectionViewCommon  {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {
                             let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-                            if localFile == nil || localFile?.etag != metadata.etag {
+                            let fileSize = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
+                            if localFile == nil || localFile?.etag != metadata.etag || fileSize == 0 {
                                 NCOperationQueue.shared.download(metadata: metadata, selector: NCBrandGlobal.shared.selectorDownloadFile, setFavorite: false)
                             }
                         }

+ 1 - 48
iOSClient/Settings/NCSettings.m

@@ -66,18 +66,6 @@
     row.action.viewControllerClass = [CCManageAutoUpload class];
     [section addFormRow:row];
 
-    // Section FOLDERS FAVORITES OFFLINE ------------------------------------
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"favoriteoffline" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_favorite_offline_", nil)];
-    row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
-    [row.cellConfig setObject:[[UIImage imageNamed:@"favorite"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-    [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
-    [section addFormRow:row];
-    
     // Section : LOCK --------------------------------------------------------------
     
     section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_lock_", nil)];
@@ -233,7 +221,6 @@
     XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
     XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"];
     XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"];
-    XLFormRowDescriptor *rowFavoriteOffline = [self.form formRowWithTag:@"favoriteoffline"];
     XLFormRowDescriptor *rowDarkModeDetect = [self.form formRowWithTag:@"darkModeDetect"];
     XLFormRowDescriptor *rowDarkMode = [self.form formRowWithTag:@"darkMode"];
 
@@ -249,7 +236,6 @@
     
     if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
     if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
-    if ([CCUtility getFavoriteOffline]) [rowFavoriteOffline setValue:@1]; else [rowFavoriteOffline setValue:@0];
     if ([CCUtility getDarkModeDetect]) [rowDarkModeDetect setValue:@1]; else [rowDarkModeDetect setValue:@0];
     if ([CCUtility getDarkMode]) [rowDarkMode setValue:@1]; else [rowDarkMode setValue:@0];
 
@@ -282,35 +268,6 @@
         }
     }
     
-    if ([rowDescriptor.tag isEqualToString:@"favoriteoffline"]) {
-        
-        if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            
-            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_continue_request_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
-            
-            [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-                [CCUtility setFavoriteOffline:true];
-                [[NCManageDatabase shared] removeAllDirectoriesSynchronizedWithAccount:appDelegate.account];
-                [[NCNetworking shared] listingFavoritescompletionWithSelector:(NCBrandGlobal.shared.selectorDownloadAllFile) completion:^(NSString *account, NSArray *metadatas, NSInteger errorCode, NSString *errorDescription) { }];                    
-            }]];
-            
-            [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-                [self reloadForm];
-            }]];
-            
-            alertController.popoverPresentationController.sourceView = self.view;
-            NSIndexPath *indexPath = [self.form indexPathOfFormRow:rowDescriptor];
-            CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
-            alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
-            
-            [self presentViewController:alertController animated:YES completion:nil];
-            
-        } else {
-            
-            [CCUtility setFavoriteOffline:false];
-        }
-    }
-    
     if ([rowDescriptor.tag isEqualToString:@"darkMode"]) {
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
@@ -451,10 +408,6 @@
     switch (section)
     {
         case 1: {
-            sectionName = NSLocalizedString(@"_favorite_offline_footer_", nil);
-        }
-        break;
-        case 2: {
             sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
         }
         break;
@@ -471,7 +424,7 @@
             
             NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
             
-            sectionName = [NSString stringWithFormat:@"%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
+            sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
         }
         break;
     }

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -85,9 +85,6 @@
 + (BOOL)getFileNameType:(NSString *)key;
 + (void)setFileNameType:(BOOL)prefix key:(NSString *)key;
 
-+ (BOOL)getFavoriteOffline;
-+ (void)setFavoriteOffline:(BOOL)offline;
-
 + (BOOL)getActivityVerboseHigh;
 + (void)setActivityVerboseHigh:(BOOL)debug;
 

+ 0 - 11
iOSClient/Utility/CCUtility.m

@@ -255,17 +255,6 @@
     [UICKeyChainStore setString:sPrefix forKey:key service:NCBrandGlobal.shared.serviceShareKeyChain];
 }
 
-+ (BOOL)getFavoriteOffline
-{
-    return [[UICKeyChainStore stringForKey:@"favoriteOffline" service:NCBrandGlobal.shared.serviceShareKeyChain] boolValue];
-}
-
-+ (void)setFavoriteOffline:(BOOL)offline
-{
-    NSString *sFavoriteOffline = (offline) ? @"true" : @"false";
-    [UICKeyChainStore setString:sFavoriteOffline forKey:@"favoriteOffline" service:NCBrandGlobal.shared.serviceShareKeyChain];
-}
-
 + (BOOL)getActivityVerboseHigh
 {
     return [[UICKeyChainStore stringForKey:@"activityVerboseHigh" service:NCBrandGlobal.shared.serviceShareKeyChain] boolValue];