marinofaggiana 4 年之前
父节点
当前提交
078b8f62fb

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -76,7 +76,6 @@
 
 - (void)openAssetsPickerController;
 - (void)openImportDocumentPicker;
-- (void)createFolder;
 
 - (void)setTableViewHeader;
 

+ 0 - 44
iOSClient/Main/CCMain.m

@@ -1343,50 +1343,6 @@
     [self presentViewController:navigationController animated:YES completion:nil];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Create folder =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)createFolder
-{
-    NSString *serverUrl = [appDelegate getTabBarControllerActiveServerUrl];
-    NSString *message;
-    UIAlertController *alertController;
-    
-    if ([serverUrl isEqualToString:[[NCUtility shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account]]) {
-        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 = UITextAutocapitalizationTypeSentences;
-    }];
-    
-    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }];
-    
-    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-        
-        UITextField *fileName = alertController.textFields.firstObject;
-        
-        [[NCNetworking shared] createFolderWithFileName:[fileName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] serverUrl:serverUrl account:appDelegate.account urlBase:appDelegate.urlBase overwrite:false completion:^(NSInteger errorCode, NSString *errorDescription) {
-            if (errorCode != 0){
-                [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode forced:false];
-            }
-        }];
-    }];
-    
-    okAction.enabled = NO;
-    
-    [alertController addAction:cancelAction];
-    [alertController addAction:okAction];
-    
-    [self presentViewController:alertController animated:YES completion:nil];
-}
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Progress & Task Button =====

+ 0 - 31
iOSClient/Main/Collection/NCCollectionCommon.swift

@@ -75,37 +75,6 @@ class NCCollectionCommon: NSObject {
         NCCollectionCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
     }
     
-    // MARK: -
-
-    @objc func createFolder() {
-        
-        guard let serverUrl = appDelegate.activeServerUrl else { return }
-        
-        let alertController = UIAlertController(title: NSLocalizedString("_create_folder_on_", comment: ""), message: nil, preferredStyle: .alert)
-        
-        alertController.addTextField { (textField) in
-            textField.autocapitalizationType = UITextAutocapitalizationType.sentences
-            textField.delegate = self as? UITextFieldDelegate
-        }
-        
-        let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
-        let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
-            if let fileNameFolder = alertController.textFields?.first?.text {
-                NCNetworking.shared.createFolder(fileName: fileNameFolder, serverUrl: serverUrl, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, overwrite: false) { (errorCode, errorDescription) in
-                    if errorCode != 0 {
-                        NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                    }
-                }
-            }
-        })
-        
-        okAction.isEnabled = false
-        alertController.addAction(cancelAction)
-        alertController.addAction(okAction)
-
-        appDelegate.window.rootViewController?.present(alertController, animated: true, completion: nil)        
-    }
-    
     // MARK: -
     
     func cellForItemAt(indexPath: IndexPath, collectionView: UICollectionView, cell: UICollectionViewCell, metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, isEditMode: Bool, selectocId: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, downloadThumbnail: Bool, shares: [tableShare]?, source: UIViewController, dataSource: NCDataSource?) {

+ 2 - 1
iOSClient/Main/Menu/AppDelegate+Menu.swift

@@ -125,7 +125,8 @@ extension AppDelegate {
             NCMenuAction(title: NSLocalizedString("_create_folder_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement),
                 action: { menuAction in
-                    appDelegate.activeMain.createFolder()
+                    NCMainCommon.shared.createFolder()
+                    //appDelegate.activeMain.createFolder()
                 }
             )
         )

+ 36 - 2
iOSClient/Main/NCMainCommon.swift

@@ -28,7 +28,7 @@ import NCCommunication
 
 //MARK: - Main Common
 
-class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentInteractionControllerDelegate {
+class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentInteractionControllerDelegate, UITextViewDelegate {
     @objc static let shared: NCMainCommon = {
         let instance = NCMainCommon()
         instance.createImagesThemingColor()
@@ -80,11 +80,43 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
         NCMainCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
     }
     
+    // MARK: -
+
+    func createFolder() {
+       
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        guard let serverUrl = appDelegate.activeServerUrl else { return }
+       
+        let alertController = UIAlertController(title: NSLocalizedString("_create_folder_on_", comment: ""), message: nil, preferredStyle: .alert)
+       
+        alertController.addTextField { (textField) in
+            //[textField addTarget:self action:@selector(minCharTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
+            textField.autocapitalizationType = UITextAutocapitalizationType.sentences
+        }
+       
+        let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
+        let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
+            if let fileNameFolder = alertController.textFields?.first?.text {
+                NCNetworking.shared.createFolder(fileName: fileNameFolder, serverUrl: serverUrl, account: appDelegate.account, urlBase: appDelegate.urlBase, overwrite: false) { (errorCode, errorDescription) in
+                    if errorCode != 0 {
+                        NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                    }
+                }
+            }
+        })
+       
+        //okAction.enabled = NO;
+        alertController.addAction(cancelAction)
+        alertController.addAction(okAction)
+
+        appDelegate.window.rootViewController?.present(alertController, animated: true, completion: nil)
+   }
+    
     //MARK: -
     
     @objc func triggerProgressTask(_ notification: Notification, sectionDataSourceocIdIndexPath: NSDictionary, tableView: UITableView, viewController: UIViewController, serverUrlViewController: String?) {
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
         if viewController.viewIfLoaded?.window == nil {
             return
         }
@@ -188,6 +220,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
     }
     
     @objc func cancelAllTransfer() {
+       
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
         // Delete k_metadataStatusWaitUpload OR k_metadataStatusUploadError
@@ -215,6 +248,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
     //MARK: -
     
     @objc func cellForRowAtIndexPath(_ indexPath: IndexPath, tableView: UITableView ,metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, autoUploadFileName: String, autoUploadDirectory: String, tableShare: tableShare?, livePhoto: Bool) -> UITableViewCell {
+        
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
         // Create File System