Browse Source

Old Feature request - Photos #540

Marino Faggiana 7 years ago
parent
commit
24ba48b0e5

+ 23 - 0
iOSClient/Images.xcassets/startDirectoryPhotosTab.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "startDirectoryPhotosTab.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "startDirectoryPhotosTab@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "startDirectoryPhotosTab@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/startDirectoryPhotosTab.imageset/startDirectoryPhotosTab.png


BIN
iOSClient/Images.xcassets/startDirectoryPhotosTab.imageset/startDirectoryPhotosTab@2x.png


BIN
iOSClient/Images.xcassets/startDirectoryPhotosTab.imageset/startDirectoryPhotosTab@3x.png


+ 1 - 0
iOSClient/Move/CCMove.h

@@ -39,6 +39,7 @@
 @property (nonatomic, weak) id <CCMoveDelegate> delegate;
 @property (nonatomic, strong) NSOperationQueue *networkingOperationQueue;
 @property BOOL includeDirectoryE2EEncryption;
+@property BOOL hideCreateFolder;
 
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) tableMetadata *passMetadata;

+ 7 - 1
iOSClient/Move/CCMove.m

@@ -72,7 +72,7 @@
     
     [self.cancel setTitle:NSLocalizedString(@"_cancel_", nil)];
     [self.create setTitle:NSLocalizedString(@"_create_folder_", nil)];
-
+    
     if (![_serverUrl length]) {
         
         UIImageView *image;
@@ -124,6 +124,11 @@
     
     self.navigationController.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;
     self.navigationController.toolbar.tintColor = NCBrandColor.sharedInstance.brandElement;
+    
+    if (self.hideCreateFolder) {
+        [self.create setEnabled:NO];
+        [self.create setTintColor: [UIColor clearColor]];
+    }
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -528,6 +533,7 @@
     viewController.delegate = self.delegate;
     viewController.includeDirectoryE2EEncryption = self.includeDirectoryE2EEncryption;
     viewController.move.title = self.move.title;
+    viewController.hideCreateFolder = self.hideCreateFolder;
     viewController.networkingOperationQueue = _networkingOperationQueue;
 
     viewController.passMetadata = metadata;

+ 2 - 1
iOSClient/Photos/CCPhotos.h

@@ -34,10 +34,11 @@
 #import "CCSection.h"
 #import "CCHud.h"
 #import "OCNetworking.h"
+#import "CCMove.h"
 
 @class tableMetadata;
 
-@interface CCPhotos: UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegate, UIActionSheetDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, OCNetworkingDelegate>
+@interface CCPhotos: UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegate, UIActionSheetDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, OCNetworkingDelegate, CCMoveDelegate>
 
 @property (nonatomic, weak) CCDetail *detailViewController;
 @property BOOL isSearchMode;

+ 45 - 4
iOSClient/Photos/CCPhotos.m

@@ -163,12 +163,15 @@
 
 - (void)setUINavigationBarDefault
 {
+    UIImage *icon;
+    
     [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     
-    // select
-    UIImage *icon = [UIImage imageNamed:@"seleziona"];
+    icon = [UIImage imageNamed:@"seleziona"];
     UIBarButtonItem *buttonSelect = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:self action:@selector(collectionSelectYES)];
-    
+    icon = [UIImage imageNamed:@"startDirectoryPhotosTab"];
+    UIBarButtonItem *buttonStartDirectoryPhotosTab = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:self action:@selector(selectStartDirectoryPhotosTab)];
+
     if ([_sectionDataSource.allRecordsDataSource count] > 0) {
         
         self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:buttonSelect, nil];
@@ -178,7 +181,7 @@
         self.navigationItem.rightBarButtonItems = nil;
     }
     
-    self.navigationItem.leftBarButtonItem = nil;
+    self.navigationItem.leftBarButtonItems = [[NSArray alloc] initWithObjects:buttonStartDirectoryPhotosTab, nil];
     
     // Title
     self.navigationItem.title = NSLocalizedString(@"_photo_camera_", nil);
@@ -529,6 +532,44 @@
     //float progress = [[dict valueForKey:@"progress"] floatValue];
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ==== Change Start directory ====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title
+{
+    NSString *oldStartDirectoryPhotosTab = [[NCManageDatabase sharedInstance] getAccountStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
+    
+    if (![serverUrlTo isEqualToString:oldStartDirectoryPhotosTab]) {
+        
+        // Save
+        [[NCManageDatabase sharedInstance] setAccountStartDirectoryPhotosTab:serverUrlTo];
+        
+        // search PhotoVideo with new start directory
+        [self searchPhotoVideo];
+    }
+}
+
+- (void)selectStartDirectoryPhotosTab
+{
+    UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMove"];
+    
+    CCMove *viewController = (CCMove *)navigationController.topViewController;
+    
+    viewController.delegate = self;
+    viewController.move.title = NSLocalizedString(@"_select_dir_photos_tab_", nil);
+    viewController.tintColor = [NCBrandColor sharedInstance].brandText;
+    viewController.barTintColor = [NCBrandColor sharedInstance].brand;
+    viewController.tintColorTitle = [NCBrandColor sharedInstance].brandText;
+    viewController.networkingOperationQueue = appDelegate.netQueue;
+    viewController.hideCreateFolder = YES;
+    // E2EE
+    viewController.includeDirectoryE2EEncryption = NO;
+    
+    [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
+    [self presentViewController:navigationController animated:YES completion:nil];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== readPhotoVideo ====
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 2
iOSClient/Settings/CCAdvanced.h

@@ -25,9 +25,8 @@
 #import "XLFormViewController.h"
 #import "XLForm.h"
 #import "CCHud.h"
-#import "CCMove.h"
 
-@interface CCAdvanced : XLFormViewController <MFMailComposeViewControllerDelegate, CCMoveDelegate>
+@interface CCAdvanced : XLFormViewController <MFMailComposeViewControllerDelegate>
 
 @property (nonatomic, strong) CCHud *hud;
 

+ 31 - 84
iOSClient/Settings/CCAdvanced.m

@@ -119,21 +119,6 @@
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
     [section addFormRow:row];
     
-    // Section : START DIRECTOY PHOTOS TAB -----------------------------------
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    section.footerTitle = NSLocalizedString(@"_start_directory_photos_tab_footer_", nil);
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"startDirectoryPhotosTab" rowType:XLFormRowDescriptorTypeButton];
-    [row.cellConfig setObject:[UIImage imageNamed:@"tabBarPhotos"] forKey:@"imageView.image"];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-    //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
-    row.action.formSelector = @selector(selectStartDirectoryPhotosTab:);
-    [section addFormRow:row];
-    
     // Section CLEAR CACHE -------------------------------------------------
     
     section = [XLFormSectionDescriptor formSection];
@@ -184,7 +169,7 @@
     [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
     [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
-    [self reloadForm];
+    [self recalculateSize];
 }
 
 - (void)changeTheming
@@ -229,33 +214,8 @@
     }
 }
 
-- (void)reloadForm
-{
-    // FOLDER TAb "Photos"
-    XLFormRowDescriptor *rowStartDirectoryPhotosTab = [self.form formRowWithTag:@"startDirectoryPhotosTab"];
-    
-    NSString *directory = [[NCManageDatabase sharedInstance] getAccountStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
-    NSString *folder = [directory stringByReplacingOccurrencesOfString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl] withString:@""];
-    if ([folder isEqualToString:@""])
-        folder = @"/";
-    rowStartDirectoryPhotosTab.title = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_start_directory_photos_tab_", nil), folder];
-    
-    [self.tableView reloadData];
-    
-    // CLEAR CACHE
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
-        
-        NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
-        rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
-        
-        [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
-    });
-}
-
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark == Action ==
+#pragma mark === Mail ===
 #pragma --------------------------------------------------------------------------------------------
 
 - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
@@ -353,26 +313,9 @@
     }
 }
 
-- (void)selectStartDirectoryPhotosTab:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    
-    UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"CCMove" bundle:nil] instantiateViewControllerWithIdentifier:@"CCMove"];
-        
-    CCMove *viewController = (CCMove *)navigationController.topViewController;
-        
-    viewController.delegate = self;
-    viewController.move.title = NSLocalizedString(@"_select_", nil);
-    viewController.tintColor = [NCBrandColor sharedInstance].brandText;
-    viewController.barTintColor = [NCBrandColor sharedInstance].brand;
-    viewController.tintColorTitle = [NCBrandColor sharedInstance].brandText;
-    viewController.networkingOperationQueue = appDelegate.netQueue;
-    // E2EE
-    viewController.includeDirectoryE2EEncryption = YES;
-        
-    [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
-    [self presentViewController:navigationController animated:YES completion:nil];
-}
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark === Clear Activity ===
+#pragma --------------------------------------------------------------------------------------------
 
 - (void)clearActivity:(XLFormRowDescriptor *)sender
 {
@@ -383,6 +326,9 @@
     [appDelegate.activeActivity reloadDatasource];
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark === Clear Cache ===
+#pragma --------------------------------------------------------------------------------------------
 
 - (void)removeAllFiles:(BOOL)removeIco
 {
@@ -422,7 +368,7 @@
         for (NSString *file in tmpDirectory)
             [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
         
-        [self reloadForm];
+        [self recalculateSize];
         
         [appDelegate maintenanceMode:NO];
         
@@ -485,6 +431,28 @@
     }
 }
 
+- (void)recalculateSize
+{
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        self.form.delegate = nil;
+        
+        XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
+        
+        NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
+        rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
+        //rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
+        
+        [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
+        
+        self.form.delegate = self;
+    });
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark == Exit Nextcloud ==
+#pragma --------------------------------------------------------------------------------------------
+
 - (void)exitNextcloud:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
@@ -539,27 +507,6 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == Delegate Move ==
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title
-{
-    NSString *oldStartDirectoryPhotosTab = [[NCManageDatabase sharedInstance] getAccountStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
-    
-    if (![serverUrlTo isEqualToString:oldStartDirectoryPhotosTab]) {
-    
-        // Save
-        [[NCManageDatabase sharedInstance] setAccountStartDirectoryPhotosTab:serverUrlTo];
-        
-        // Reload form
-        [self reloadForm];
-        
-        // search PhotoVideo with new start directory
-        [appDelegate.activePhotos searchPhotoVideo];
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark == Utility ==
 #pragma --------------------------------------------------------------------------------------------

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

@@ -83,6 +83,7 @@
 "_success_"                 = "Success";
 "_initialization_"          = "Initialization";
 "_experimental_"            = "Experimental";
+"_select_dir_photos_tab_"   = "Select Folder \"Photos\"";
 
 // App
 
@@ -211,8 +212,6 @@
 "_show_hidden_files_"           = "Show hidden files";
 "_format_compatibility_"        = "Most Compatible";
 "_format_compatibility_footer_" = "\"Most compatible\" will always save photos as JPEG";
-"_start_directory_photos_tab_"  = "Folder tab \"Photos\"";
-"_start_directory_photos_tab_footer_" = "Select the starting directory to search for images and videos for the Photos tab";
 
 // Login