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

Old Feature request - Photos #540

Marino Faggiana 7 жил өмнө
parent
commit
6d9e067689

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -300,11 +300,11 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
                 "</d:select>"
                 "<d:from>"
                     "<d:scope>"
-                        "<d:href>/files/%@</d:href>"
+                        "<d:href>/files/%@%@</d:href>"
                         "<d:depth>infinity</d:depth>"
                     "</d:scope>"
                 "</d:from>"
-                "<d:where><d:and><d:or>", userID];
+                "<d:where><d:and><d:or>", userID, folder];
         
         for (NSString *type in contentType) {
             whereType = [NSString stringWithFormat: @"%@<d:like><d:prop><d:getcontenttype/></d:prop><d:literal>%@</d:literal></d:like>", whereType, type];

+ 2 - 2
iOSClient/Main/CCMain.m

@@ -1639,9 +1639,9 @@
 
 - (void)searchStartTimer
 {
-    NSString *home = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
+    NSString *startDirectory = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
     
-    [[CCActions sharedInstance] search:home fileName:_searchFileName depth:@"infinity" date:nil contenType:nil selector:selectorSearchFiles delegate:self];
+    [[CCActions sharedInstance] search:startDirectory fileName:_searchFileName depth:@"infinity" date:nil contenType:nil selector:selectorSearchFiles delegate:self];
 
     _noFilesSearchTitle = @"";
     _noFilesSearchDescription = NSLocalizedString(@"_search_in_progress_", nil);

+ 6 - 2
iOSClient/Photos/CCPhotos.m

@@ -577,7 +577,9 @@
     // tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
     // account.dateSearchContentTypeImageVideo
     
-    [[CCActions sharedInstance] search:@"" fileName:@"" depth:@"infinity" date:[NSDate distantPast] contenType:@[@"image/%", @"video/%"] selector:selectorSearchContentType delegate:self];
+    NSString *startDirectory = [CCUtility getStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
+
+    [[CCActions sharedInstance] search:startDirectory fileName:@"" depth:@"infinity" date:[NSDate distantPast] contenType:@[@"image/%", @"video/%"] selector:selectorSearchContentType delegate:self];
     
     _isSearchMode = YES;
 }
@@ -595,7 +597,9 @@
     
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
 
-            NSArray *metadatasDBImageVideo = [[NCManageDatabase sharedInstance] getTableMetadatasContentTypeImageVideo:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl] activeUrl:appDelegate.activeUrl];
+            NSString *startDirectory = [CCUtility getStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
+
+            NSArray *metadatasDBImageVideo = [[NCManageDatabase sharedInstance] getTableMetadatasContentTypeImageVideo:startDirectory activeUrl:appDelegate.activeUrl];
             CCSectionDataSourceMetadata *tempSectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatasDBImageVideo listProgressMetadata:nil groupByField:@"date" activeAccount:appDelegate.activeAccount];
         
             dispatch_async(dispatch_get_main_queue(), ^{

+ 2 - 1
iOSClient/Settings/CCAdvanced.h

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

+ 69 - 11
iOSClient/Settings/CCAdvanced.m

@@ -119,6 +119,26 @@
     [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];
+    NSString *directory = [CCUtility getStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
+    NSString *folder = [directory stringByReplacingOccurrencesOfString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl] withString:@""];
+    if ([folder isEqualToString:@""])
+        folder = @"/";
+    row.title = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_start_directory_photos_tab_", nil), folder];
+    //[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];
@@ -215,7 +235,7 @@
 }
 
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark === Mail ===
+#pragma mark == Action ==
 #pragma --------------------------------------------------------------------------------------------
 
 - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
@@ -313,9 +333,26 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Clear Activity ===
-#pragma --------------------------------------------------------------------------------------------
+- (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];
+}
 
 - (void)clearActivity:(XLFormRowDescriptor *)sender
 {
@@ -326,9 +363,6 @@
     [appDelegate.activeActivity reloadDatasource];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Clear Cache ===
-#pragma --------------------------------------------------------------------------------------------
 
 - (void)removeAllFiles:(BOOL)removeIco
 {
@@ -449,10 +483,6 @@
     });
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == Exit Nextcloud ==
-#pragma --------------------------------------------------------------------------------------------
-
 - (void)exitNextcloud:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
@@ -507,6 +537,34 @@
     }
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark == Delegate Move ==
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title
+{
+    [CCUtility setStartDirectoryPhotosTab:serverUrlTo];
+    
+    NSString *oldStartDirectoryPhotosTab = [CCUtility getStartDirectoryPhotosTab:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]];
+    
+    if (![serverUrlTo isEqualToString:oldStartDirectoryPhotosTab]) {
+    
+        // Save
+        [CCUtility setStartDirectoryPhotosTab:serverUrlTo];
+        
+        // Reload row
+        XLFormRowDescriptor *rowStartDirectoryPhotosTab = [self.form formRowWithTag:@"startDirectoryPhotosTab"];
+        NSString *folder = [serverUrlTo stringByReplacingOccurrencesOfString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl] withString:@""];
+        if ([folder isEqualToString:@""])
+            folder = @"/";
+        rowStartDirectoryPhotosTab.title = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_start_directory_photos_tab_", nil), folder];
+        [self.tableView reloadData];
+        
+        // search PhotoVideo with new start directory
+        [appDelegate.activePhotos searchPhotoVideo];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark == Utility ==
 #pragma --------------------------------------------------------------------------------------------

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

@@ -211,6 +211,8 @@
 "_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
 

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -145,6 +145,9 @@
 
 + (void)clearAllKeysEndToEnd:(NSString *)account;
 
++ (void)setStartDirectoryPhotosTab:(NSString *)directory;
++ (NSString *)getStartDirectoryPhotosTab:(NSString *)homeServerUrl;
+
 // ===== Varius =====
 
 + (NSString *)getUserAgent;

+ 16 - 3
iOSClient/Utility/CCUtility.m

@@ -516,10 +516,23 @@
     [self setEndToEndPublicKeyServer:account publicKey:nil];
 }
 
-#pragma ------------------------------ GET
-
-
++ (void)setStartDirectoryPhotosTab:(NSString *)directory
+{
+    [UICKeyChainStore setString:directory forKey:@"startDirectoryPhotosTab" service:k_serviceShareKeyChain];
+}
 
++ (NSString *)getStartDirectoryPhotosTab:(NSString *)homeServerUrl
+{
+    NSString *valueString = [UICKeyChainStore stringForKey:@"startDirectoryPhotosTab" service:k_serviceShareKeyChain];
+    
+    // Default TRUE
+    if (valueString == nil) {
+        [self setStartDirectoryPhotosTab:homeServerUrl];
+        valueString = homeServerUrl;
+    }
+    
+    return valueString;
+}
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Varius =====