Browse Source

delete returnCreate

Marino Faggiana 6 năm trước cách đây
mục cha
commit
e508b97ddf

+ 0 - 8
iOSClient/CCGlobal.h

@@ -68,14 +68,6 @@
 
 #define k_maxErrorAutoUploadAll                         100
 
-#define k_returnCreateFolderPlain                       0
-#define k_returnCreateFotoVideoPlain                    1
-#define k_returnCreateFilePlain                         2
-#define k_returnCreateFolderEncrypted                   3
-#define k_returnCreateFotoVideoEncrypted                4
-#define k_returnCreateFileEncrypted                     5
-#define k_returnCreateFileText                          6
-
 // Name Default DB
 #define k_databaseDefault                               @"nextcloud.realm"
 

+ 8 - 4
iOSClient/Create/CCCreateCloud.swift

@@ -66,19 +66,23 @@ class CreateMenuAdd: NSObject {
         actionSheet.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
         
         actionSheet.addButton(withTitle: NSLocalizedString("_upload_photos_videos_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "media"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
-            appDelegate.activeMain.returnCreate(Int(k_returnCreateFotoVideoPlain))
+            appDelegate.activeMain.openAssetsPickerController()
         })
         
         actionSheet.addButton(withTitle: NSLocalizedString("_upload_file_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "file"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
-            appDelegate.activeMain.returnCreate(Int(k_returnCreateFilePlain))
+            appDelegate.activeMain.openImportDocumentPicker()
         })
         
         actionSheet.addButton(withTitle: NSLocalizedString("_upload_file_text_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "file_txt"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
-            appDelegate.activeMain.returnCreate(Int(k_returnCreateFileText))
+            
+            let storyboard = UIStoryboard(name: "NCText", bundle: nil)
+            let controller = storyboard.instantiateViewController(withIdentifier: "NCText")
+            controller.modalPresentationStyle = UIModalPresentationStyle.pageSheet
+            appDelegate.activeMain.present(controller, animated: true, completion: nil)
         })
         
         actionSheet.addButton(withTitle: NSLocalizedString("_create_folder_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), multiplier:2, color: colorIcon), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0 ,type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
-            appDelegate.activeMain.returnCreate(Int(k_returnCreateFolderPlain))
+            appDelegate.activeMain.createFolder()
         })
         
         actionSheet.show()

+ 4 - 1
iOSClient/Main/CCMain.h

@@ -75,7 +75,6 @@
 - (void)copyFileToPasteboard:(tableMetadata *)metadata;
 
 - (void)closeAllMenu;
-- (void)returnCreate:(NSInteger)type;
 
 - (void)setUINavigationBarDefault;
 
@@ -90,5 +89,9 @@
 - (void)clearDateReadDataSource:(NSNotification *)notification;
 - (void)cancelSearchBar;
 
+- (void)openAssetsPickerController;
+- (void)openImportDocumentPicker;
+- (void)createFolder;
+
 @end
 

+ 38 - 77
iOSClient/Main/CCMain.m

@@ -863,83 +863,6 @@
     }];
 }
 
-// New folder or new photo or video
-- (void)returnCreate:(NSInteger)type
-{
-    switch (type) {
-            
-        case k_returnCreateFolderPlain: {
-            
-            NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
-            NSString *message;
-            UIAlertController *alertController;
-            
-            if ([serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]]) {
-                message = @"/";
-            } else {
-                message = [serverUrl lastPathComponent];
-            }
-            
-            alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_on_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
-
-            [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
-                [textField addTarget:self action:@selector(minCharTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-                
-                textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
-            }];
-            
-            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-                NSLog(@"[LOG] Cancel action");
-            }];
-            
-            UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-                
-                UITextField *fileName = alertController.textFields.firstObject;
-                [self createFolder:fileName.text serverUrl:serverUrl];
-            }];
-            
-            okAction.enabled = NO;
-            
-            [alertController addAction:cancelAction];
-            [alertController addAction:okAction];
-            
-            [self presentViewController:alertController animated:YES completion:nil];
-        }
-            break;
-        case k_returnCreateFotoVideoPlain: {
-            
-            [self openAssetsPickerController];
-        }
-            break;
-        case k_returnCreateFilePlain: {
-            
-            [self openImportDocumentPicker];
-        }
-            break;
-            
-        case k_returnCreateFotoVideoEncrypted: {
-            
-            [self openAssetsPickerController];
-        }
-            break;
-        case k_returnCreateFileEncrypted: {
-            
-            [self openImportDocumentPicker];
-        }
-            break;
-    
-        case k_returnCreateFileText: {
-            
-            UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCText" bundle:nil] instantiateViewControllerWithIdentifier:@"NCText"];
-                        
-            navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
-
-            [self presentViewController:navigationController animated:YES completion:nil];
-        }
-            break;
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Save selected File =====
 #pragma --------------------------------------------------------------------------------------------
@@ -1901,6 +1824,44 @@
 #pragma mark ===== Create folder =====
 #pragma --------------------------------------------------------------------------------------------
 
+- (void)createFolder
+{
+    NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
+    NSString *message;
+    UIAlertController *alertController;
+    
+    if ([serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]]) {
+        message = @"/";
+    } else {
+        message = [serverUrl lastPathComponent];
+    }
+    
+    alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_on_",nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+    
+    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+        [textField addTarget:self action:@selector(minCharTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
+        
+        textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
+    }];
+    
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        NSLog(@"[LOG] Cancel action");
+    }];
+    
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        
+        UITextField *fileName = alertController.textFields.firstObject;
+        [self createFolder:fileName.text serverUrl:serverUrl];
+    }];
+    
+    okAction.enabled = NO;
+    
+    [alertController addAction:cancelAction];
+    [alertController addAction:okAction];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
+}
+
 - (void)createFolder:(NSString *)fileNameFolder serverUrl:(NSString *)serverUrl
 {
     fileNameFolder = [CCUtility removeForbiddenCharactersServer:fileNameFolder];