瀏覽代碼

Improvements

Marino Faggiana 7 年之前
父節點
當前提交
fada0c2d3a

+ 0 - 3
iOSClient/AppDelegate.h

@@ -128,9 +128,6 @@
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
 
-// ico Image Cache
-@property (nonatomic, strong) NSMutableDictionary *icoImagesCache;
-
 // Is in Crypto Mode
 @property BOOL isCryptoCloudMode;
 

+ 1 - 4
iOSClient/AppDelegate.m

@@ -202,10 +202,7 @@
     // Player audio
     self.player = [LMMediaPlayerView sharedPlayerView];
     self.player.delegate = self;
-        
-    // ico Image Cache
-    self.icoImagesCache = [[NSMutableDictionary alloc] init];
-    
+            
     // setting Reachable in back
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
 

+ 6 - 2
iOSClient/Main/CCDetail.m

@@ -686,7 +686,9 @@
     
     self.docController.delegate = self;
     
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) [self.docController presentOptionsMenuFromRect:photoBrowser.view.frame inView:photoBrowser.view animated:YES];
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
+        [self.docController presentOptionsMenuFromRect:photoBrowser.view.frame inView:photoBrowser.view animated:YES];
+    
     [self.docController presentOptionsMenuFromBarButtonItem:photoBrowser.actionButton animated:YES];
 }
 
@@ -1071,7 +1073,9 @@
 
     self.docController.delegate = self;
     
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) [self.docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
+        [self.docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
+    
     [self.docController presentOptionsMenuFromBarButtonItem:sender animated:YES];
 }
 

+ 16 - 35
iOSClient/Main/CCMain.m

@@ -1290,26 +1290,12 @@
 
 - (void)downloadThumbnailSuccess:(CCMetadataNet *)metadataNet
 {
-    __block CCCellMain *cell;
-    
     NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadataNet.fileID];
     
     if (indexPath && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]]) {
         
-        cell = [self.tableView cellForRowAtIndexPath:indexPath];
-        
-        cell.file.image = [app.icoImagesCache objectForKey:metadataNet.fileID];
-        
-        if (cell.file.image == nil) {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                
-                UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]];
-                
-                [app.icoImagesCache setObject:image forKey:metadataNet.fileID];
-            });
-        }
-     }
+        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
+    }
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -4983,8 +4969,10 @@
     
     if ([_directoryGroupBy isEqualToString:@"alphabetic"]) {
         
-        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) shift = - 35;
-        else shift =  - 20;
+        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
+            shift = - 35;
+        else
+            shift =  - 20;
         
     } else shift = - 10;
     
@@ -5175,28 +5163,21 @@
     // assegnamo l'immagine anteprima se esiste, altrimenti metti quella standars
     if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]]) {
         
-        cell.file.image = [app.icoImagesCache objectForKey:metadata.fileID];
-        
-        if (cell.file.image == nil) {
+        NSString *fileID = metadata.fileID;
             
-            NSString *fileID = metadata.fileID;
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                
-                UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, fileID]];
-                
-                [app.icoImagesCache setObject:image forKey:fileID];
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
+            UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, fileID]];
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
                     
-                    CCCellMainTransfer *cell = [tableView cellForRowAtIndexPath:indexPath];
+                CCCellMainTransfer *cell = [tableView cellForRowAtIndexPath:indexPath];
                     
-                    if (cell)
-                        cell.file.image = image;
-                });
+                if (cell)
+                    cell.file.image = image;
             });
-        }
-
+        });
+        
     } else {
         
         if (metadata.directory)

+ 3 - 12
iOSClient/Photos/CCPhotos.m

@@ -366,9 +366,7 @@
             
             imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
             effect.hidden = YES;
-            checked.hidden = YES;
-            
-            [app.icoImagesCache setObject:imageView.image forKey:metadata.fileID];
+            checked.hidden = YES;            
         }
     }
 }
@@ -602,15 +600,8 @@
     // Image
     if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]]) {
         
-        imageView.image = [app.icoImagesCache objectForKey:metadata.fileID];
-        
-        if (imageView.image == nil) {
-            
-                // insert Image
-                UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
-                imageView.image = image;
-                [app.icoImagesCache setObject:image forKey:metadata.fileID];
-        }
+        // insert Image
+        imageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
         
     } else {
         

+ 80 - 57
iOSClient/Settings/CCAdvanced.m

@@ -301,70 +301,96 @@
 #pragma mark === Clear Cache ===
 #pragma --------------------------------------------------------------------------------------------
 
+- (void)removeAllFiles:(BOOL)removeIco
+{
+    [app maintenanceMode:YES];
+    
+    [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
+    
+    [[NCManageDatabase sharedInstance] clearTable:[tableAutoUpload class] account:app.activeAccount];
+    
+    [app cancelAllOperations];
+    
+    [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC),dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+        [[NSURLCache sharedURLCache] setDiskCapacity:0];
+        
+        [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableGPS class] account:nil];
+        [[NCManageDatabase sharedInstance] clearTable:[tableLocalFile class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
+        [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
+        
+        [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl removeIco:removeIco];
+        
+        [self emptyLocalDirectory];
+        
+        NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
+        for (NSString *file in tmpDirectory)
+            [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
+        
+        [self recalculateSize];
+        
+        [app maintenanceMode:NO];
+        
+        dispatch_async(dispatch_get_main_queue(), ^{
+            // Close HUD
+            [self.hud hideHud];
+            // Inizialized home
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
+        });
+    });
+}
+
 - (void)clearCache:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
     
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         
-        [app maintenanceMode:YES];
-
-        [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
-
-        [[NCManageDatabase sharedInstance] clearTable:[tableAutoUpload class] account:app.activeAccount];
-
-        [app cancelAllOperations];
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_thumbnails_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
         
-        [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
-
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC),dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
-            [[NSURLCache sharedURLCache] setDiskCapacity:0];
-
-            [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableGPS class] account:nil];
-            [[NCManageDatabase sharedInstance] clearTable:[tableLocalFile class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:app.activeAccount];
-            [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:app.activeAccount];
-            
-            [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
-            
-            [self emptyLocalDirectory];
-            
-            NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
-            for (NSString *file in tmpDirectory)
-                [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
-            
-            [self recalculateSize];
-            
-            [app maintenanceMode:NO];
-
-            dispatch_async(dispatch_get_main_queue(), ^{
-                // Close HUD
-                [self.hud hideHud];
-                // Inizialized home
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
-            });
-        });
+        [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil)
+                                                             style:UIAlertActionStyleDefault                                                         handler:^(UIAlertAction *action) {
+                                                               [self removeAllFiles:YES];
+                                                           }]];
+        
+        [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_no_", nil)
+                                                             style:UIAlertActionStyleDefault
+                                                           handler:^(UIAlertAction *action) {
+                                                               [self removeAllFiles:NO];
+                                                           }]];
+        
+        [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        }]];
+        
+        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+            // iPhone
+            [self presentViewController:alertController animated:YES completion:nil];
+        } else {
+            // iPad
+            // Change Rect to position Popover
+            UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
+            [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+        }
     }]];
 
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
     }]];
     
-    //if iPhone
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
-        
+        // iPhone
         [self presentViewController:alertController animated:YES completion:nil];
-    }
-    //if iPad
-    else {
-        
+    } else {
+        // iPad
         // Change Rect to position Popover
         UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
         [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
@@ -436,14 +462,11 @@
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
     }]];
     
-    //if iPhone
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
-        
+        // iPhone
         [self presentViewController:alertController animated:YES completion:nil];
-    }
-    //if iPad
-    else {
-        
+    } else {
+        // iPad
         // Change Rect to position Popover
         UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
         [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
@@ -494,7 +517,7 @@
         [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
 }
 
-- (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
+- (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url removeIco:(BOOL)removeIco
 {
     NSString *file;
     NSString *dirIniziale;
@@ -508,7 +531,7 @@
         NSString *ext = [[file pathExtension] lowercaseString];
         
         // Do not remove ICO
-        if ([ext isEqualToString:@"ico"])
+        if ([ext isEqualToString:@"ico"] && !removeIco)
             continue;
         
         [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];

+ 3 - 6
iOSClient/Settings/CCSettings.m

@@ -256,14 +256,11 @@
                 [self reloadForm];
             }]];
             
-            //if iPhone
             if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
-                
+                // iPhone
                 [self presentViewController:alertController animated:YES completion:nil];
-            }
-            //if iPad
-            else {
-                
+            }else {
+                // iPad
                 // Change Rect to position Popover
                 UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
                 [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:rowDescriptor]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

+ 3 - 1
iOSClient/Share/CCShareOC.m

@@ -280,7 +280,9 @@
     
     UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
     
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) [self presentViewController:activityController animated:YES completion:nil];
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
+        [self presentViewController:activityController animated:YES completion:nil];
+    
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
         
         UIPopoverController *popup;

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

@@ -107,6 +107,7 @@
 "_proceed_"                 = "Proceed";
 "_delete_cache_"            = "Delete cache";
 "_want_delete_cache_"       = "Do you want to delete cache?";
+"_want_delete_thumbnails_"  = "Do you want to delete all thumbnails too ?";
 "_mail_deleted_"            = "Email deleted";
 "_mail_saved_"              = "Email saved";
 "_mail_sent_"               = "Email sent";

+ 1 - 16
iOSClient/Transfers/CCTransfers.m

@@ -298,27 +298,12 @@
 
 - (void)downloadThumbnailSuccess:(CCMetadataNet *)metadataNet
 {
-    __block CCTransfersCell *cell;
-
     NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadataNet.fileID];
     
     if (indexPath && [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]]) {
         
-        cell = [self.tableView cellForRowAtIndexPath:indexPath];
-        
-        cell.file.image = [app.icoImagesCache objectForKey:metadataNet.fileID];
-        
-        if (cell.file.image == nil) {
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-                
-                UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataNet.fileID]];
-                
-                [app.icoImagesCache setObject:image forKey:metadataNet.fileID];
-            });
-        }
+        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
     }
-
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 0 - 5
iOSClient/Utility/CCGraphics.m

@@ -257,11 +257,6 @@
 
     if (move)
         [[NSFileManager defaultManager] moveItemAtPath:fromPath toPath:toPath error:nil];
-
-#ifndef EXTENSION
-    if (image && fileID)
-        [app.icoImagesCache setObject:image forKey:fileID];
-#endif
 }
 
 + (UIColor *)colorFromHexString:(NSString *)hexString