Browse Source

clear code

marinofaggiana 4 years ago
parent
commit
a5bc1b261d
30 changed files with 172 additions and 193 deletions
  1. 4 4
      File Provider Extension/FileProviderData.swift
  2. 1 1
      File Provider Extension/FileProviderExtension+Actions.swift
  3. 1 1
      File Provider Extension/FileProviderExtension.swift
  4. 1 1
      File Provider Extension/FileProviderUtility.swift
  5. 1 1
      Share/NCSelectDestination.m
  6. 4 4
      Share/ShareViewController.m
  7. 1 1
      iOSClient/Activity/NCActivity.swift
  8. 3 3
      iOSClient/AppDelegate.m
  9. 37 1
      iOSClient/Brand/NCBrand.swift
  10. 5 5
      iOSClient/Data/NCManageDatabase.swift
  11. 2 2
      iOSClient/Diagnostics/NCCapabilitiesViewController.swift
  12. 1 1
      iOSClient/FileViewInFolder/NCFileViewInFolder.swift
  13. 2 2
      iOSClient/Files/NCFiles.swift
  14. 1 1
      iOSClient/Login/CCLogin.m
  15. 3 3
      iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift
  16. 8 1
      iOSClient/Main/Colleaction Common/NCListCell.swift
  17. 2 2
      iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift
  18. 1 1
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  19. 2 2
      iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift
  20. 2 2
      iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
  21. 1 1
      iOSClient/Media/NCMedia.swift
  22. 1 1
      iOSClient/Networking/NCNetworking.swift
  23. 1 1
      iOSClient/Select/NCSelect.swift
  24. 2 2
      iOSClient/Settings/CCManageAutoUpload.m
  25. 1 1
      iOSClient/Transfers/NCTransfers.swift
  26. 8 1
      iOSClient/Trash/Cell/NCTrashListCell.swift
  27. 2 2
      iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m
  28. 4 4
      iOSClient/Utility/CCUtility.m
  29. 1 141
      iOSClient/Utility/NCUtility.swift
  30. 69 0
      iOSClient/Utility/NCUtilityFileSystem.swift

+ 4 - 4
File Provider Extension/FileProviderData.swift

@@ -80,11 +80,11 @@ class fileProviderData: NSObject {
             
             guard let accountActive = NCManageDatabase.shared.getAccountActive() else { return nil }
             let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-            let webDav = NCUtility.shared.getWebDAV(account: accountActive.account)
+            let webDav = NCUtilityFileSystem.shared.getWebDAV(account: accountActive.account)
             
             account = accountActive.account
             accountUrlBase = accountActive.urlBase
-            homeServerUrl = NCUtility.shared.getHomeServer(urlBase: accountActive.urlBase, account: accountActive.account)
+            homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: accountActive.urlBase, account: accountActive.account)
                         
             NCCommunicationCommon.shared.setup(account: accountActive.account, user: accountActive.user, userId: accountActive.userID, password: CCUtility.getPassword(accountActive.account), urlBase: accountActive.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
@@ -103,11 +103,11 @@ class fileProviderData: NSObject {
             if accountDomain == domain!.identifier.rawValue {
                 
                 let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-                let webDav = NCUtility.shared.getWebDAV(account: accountActive.account)
+                let webDav = NCUtilityFileSystem.shared.getWebDAV(account: accountActive.account)
                 
                 account = accountActive.account
                 accountUrlBase = accountActive.urlBase
-                homeServerUrl = NCUtility.shared.getHomeServer(urlBase: accountActive.urlBase, account: accountActive.account)
+                homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: accountActive.urlBase, account: accountActive.account)
                 
                 NCCommunicationCommon.shared.setup(account: accountActive.account, user: accountActive.user, userId: accountActive.userID, password: CCUtility.getPassword(accountActive.account), urlBase: accountActive.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
                 NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate

+ 1 - 1
File Provider Extension/FileProviderExtension+Actions.swift

@@ -33,7 +33,7 @@ extension FileProviderExtension {
             return
         }
         
-        let directoryName = NCUtility.shared.createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
+        let directoryName = NCUtilityFileSystem.shared.createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
         let serverUrlFileName = tableDirectory.serverUrl + "/" + directoryName
         
         NCCommunication.shared.createFolder(serverUrlFileName) { (account, ocId, date, errorCode, errorDescription) in

+ 1 - 1
File Provider Extension/FileProviderExtension.swift

@@ -340,7 +340,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                     return
                 }
         
-                let fileName = NCUtility.shared.createFileName(fileURL.lastPathComponent, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
+                let fileName = NCUtilityFileSystem.shared.createFileName(fileURL.lastPathComponent, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
                 let ocIdTemp = NSUUID().uuidString.lowercased()
                 
                 NSFileCoordinator().coordinate(readingItemAt: fileURL, options: .withoutChanges, error: &error) { (url) in

+ 1 - 1
File Provider Extension/FileProviderUtility.swift

@@ -59,7 +59,7 @@ class fileProviderUtility: NSObject {
     
     func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier? {
         
-        let homeServerUrl = NCUtility.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
+        let homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
         if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl))  {
             if directory.serverUrl == homeServerUrl {
                 return NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue)

+ 1 - 1
Share/NCSelectDestination.m

@@ -69,7 +69,7 @@
     
     if (![_serverUrl length]) {
                 
-        _serverUrl = [[NCUtility shared] getHomeServerWithUrlBase:urlBase account:account];
+        _serverUrl = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase account:account];
         
         [self.navigationController.navigationBar.topItem setTitleView:[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"themingLogo"]]];
         self.title = @"Home";

+ 4 - 4
Share/ShareViewController.m

@@ -62,7 +62,7 @@
     } else {
         
         NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:tableAccount.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
-        NSString *webDav = [[NCUtility shared] getWebDAVWithAccount:tableAccount.account];
+        NSString *webDav = [[NCUtilityFileSystem shared] getWebDAVWithAccount:tableAccount.account];
         
         // Networking
         [[NCCommunicationCommon shared] setupWithAccount:tableAccount.account user:tableAccount.user userId:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] urlBase:tableAccount.urlBase userAgent:[CCUtility getUserAgent] webDav:webDav dav:nil nextcloudVersion:serverVersionMajor delegate:[NCNetworking shared]];
@@ -84,7 +84,7 @@
             
             [CCUtility setAccountExt:self.account];
 
-            _serverUrl  = [[NCUtility shared] getHomeServerWithUrlBase:tableAccount.urlBase account:tableAccount.account];
+            _serverUrl  = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:tableAccount.urlBase account:tableAccount.account];
             [CCUtility setServerUrlExt:_serverUrl];
 
             _destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
@@ -180,7 +180,7 @@
         NSString *themingColor = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColor];
         NSString *themingColorElement = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
         NSString *themingColorText = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorText];
-        [NCUtility.shared settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
+        [NCBrandColor.shared settingBrandColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
     }
     
     self.navigationController.navigationBar.barTintColor = NCBrandColor.shared.brand;
@@ -270,7 +270,7 @@
         
         // <--
         
-        NSString *fileNameForUpload = [[NCUtility shared] createFileName:fileName serverUrl:self.serverUrl account:self.account];
+        NSString *fileNameForUpload = [[NCUtilityFileSystem shared] createFileName:fileName serverUrl:self.serverUrl account:self.account];
         NSString *fileNameServer = [NSString stringWithFormat:@"%@/%@", self.serverUrl, fileNameForUpload];
         
         [[NCCommunication shared] uploadWithServerUrlFileName:fileNameServer fileNameLocalPath:fileNameLocal dateCreationFile:nil dateModificationFile:nil customUserAgent:nil addCustomHeaders:nil taskHandler:^(NSURLSessionTask *task) {

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -382,7 +382,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
             var pathComponents = activityPreview.link.components(separatedBy: "?")
             pathComponents = pathComponents[1].components(separatedBy: "&")
             var serverUrlFileName = pathComponents[0].replacingOccurrences(of: "dir=", with: "").removingPercentEncoding!
-            serverUrlFileName = appDelegate.urlBase + "/" + NCUtility.shared.getWebDAV(account: activityPreview.account) + serverUrlFileName + "/" + activitySubjectRich.name
+            serverUrlFileName = appDelegate.urlBase + "/" + NCUtilityFileSystem.shared.getWebDAV(account: activityPreview.account) + serverUrlFileName + "/" + activitySubjectRich.name
             
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(activitySubjectRich.id, fileNameView: activitySubjectRich.name)!
             

+ 3 - 3
iOSClient/AppDelegate.m

@@ -490,8 +490,8 @@
         [[NCCommunicationCommon shared] setupWithNextcloudVersion:serverVersionMajor];
     }
     
-    [[NCCommunicationCommon shared] setupWithWebDav:[[NCUtility shared] getWebDAVWithAccount:account]];
-    [[NCCommunicationCommon shared] setupWithDav:[[NCUtility shared] getDAV]];
+    [[NCCommunicationCommon shared] setupWithWebDav:[[NCUtilityFileSystem shared] getWebDAVWithAccount:account]];
+    [[NCCommunicationCommon shared] setupWithDav:[[NCUtilityFileSystem shared] getDAV]];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -800,7 +800,7 @@
                     
                     if (matchedAccount) {
                         
-                        NSString *webDAV = [[NCUtility shared] getWebDAVWithAccount:self.account];
+                        NSString *webDAV = [[NCUtilityFileSystem shared] getWebDAVWithAccount:self.account];
 
                         if ([path containsString:@"/"]) {
 

+ 37 - 1
iOSClient/Brand/NCBrand.swift

@@ -168,7 +168,7 @@ class NCBrandColor: NSObject {
             
             let themingColorText = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText)
             
-            NCUtility.shared.settingThemingColor(themingColor, themingColorElement: themingColorElement, themingColorText: themingColorText)
+            settingBrandColor(themingColor, themingColorElement: themingColorElement, themingColorText: themingColorText)
                         
             if NCBrandColor.shared.brandElement.isTooLight() {
                 if let color = NCBrandColor.shared.brandElement.darker(by: darker) {
@@ -206,6 +206,42 @@ class NCBrandColor: NSObject {
         }
     }
 #endif
+    
+    @objc func settingBrandColor(_ themingColor: String?, themingColorElement: String?, themingColorText: String?) {
+                
+        // COLOR
+        if themingColor?.first == "#" {
+            if let color = UIColor(hex: themingColor!) {
+                NCBrandColor.shared.brand = color
+            } else {
+                NCBrandColor.shared.brand = NCBrandColor.shared.customer
+            }
+        } else {
+            NCBrandColor.shared.brand = NCBrandColor.shared.customer
+        }
+        
+        // COLOR TEXT
+        if themingColorText?.first == "#" {
+            if let color = UIColor(hex: themingColorText!) {
+                NCBrandColor.shared.brandText = color
+            } else {
+                NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
+            }
+        } else {
+            NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
+        }
+        
+        // COLOR ELEMENT
+        if themingColorElement?.first == "#" {
+            if let color = UIColor(hex: themingColorElement!) {
+                NCBrandColor.shared.brandElement = color
+            } else {
+                NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
+            }
+        } else {
+            NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
+        }
+    }
 }
 
 //MARK: - Global

+ 5 - 5
iOSClient/Data/NCManageDatabase.swift

@@ -400,7 +400,7 @@ class NCManageDatabase: NSObject {
         if result.autoUploadDirectory.count > 0 {
             return result.autoUploadDirectory
         } else {
-            return NCUtility.shared.getHomeServer(urlBase: urlBase, account: account)
+            return NCUtilityFileSystem.shared.getHomeServer(urlBase: urlBase, account: account)
         }
     }
 
@@ -2223,13 +2223,13 @@ class NCManageDatabase: NSObject {
         var serverUrl = serverUrl
         var fileName = ""
         
-        let serverUrlHome = NCUtility.shared.getHomeServer(urlBase: urlBase, account: account)
+        let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: urlBase, account: account)
         if serverUrlHome == serverUrl {
             fileName = "."
             serverUrl = ".."
         } else {
             fileName = (serverUrl as NSString).lastPathComponent
-            serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl: serverUrl, urlBase: urlBase, account: account)
+            serverUrl = NCUtilityFileSystem.shared.deletingLastPathComponent(serverUrl: serverUrl, urlBase: urlBase, account: account)
         }
         
         guard let result = realm.objects(tableMetadata.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", account, serverUrl, fileName).first else { return nil }
@@ -2457,8 +2457,8 @@ class NCManageDatabase: NSObject {
         for share in shares {
             
             let addObject = tableShare()
-            let fullPath = NCUtility.shared.getHomeServer(urlBase: urlBase, account: account) + share.path
-            let serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl:fullPath, urlBase: urlBase, account: account)
+            let fullPath = NCUtilityFileSystem.shared.getHomeServer(urlBase: urlBase, account: account) + share.path
+            let serverUrl = NCUtilityFileSystem.shared.deletingLastPathComponent(serverUrl:fullPath, urlBase: urlBase, account: account)
             let fileName = NSString(string: fullPath).lastPathComponent
                         
             addObject.account = account

+ 2 - 2
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -167,10 +167,10 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         }
         
         homeImage.image = UIImage.init(named: "home")!.image(color: .gray, size: 50)
-        homeServer.text = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) + "/"
+        homeServer.text = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) + "/"
         
         davImage.image = UIImage.init(named: "dav")!.image(color: .gray, size: 50)
-        davFiles.text = appDelegate.urlBase + "/" + NCUtility.shared.getDAV() + "/files/" + appDelegate.user + "/"
+        davFiles.text = appDelegate.urlBase + "/" + NCUtilityFileSystem.shared.getDAV() + "/files/" + appDelegate.user + "/"
     }
 
     @objc func updateCapabilities() {

+ 1 - 1
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -42,7 +42,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
     
     override func viewWillAppear(_ animated: Bool) {
                 
-        if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             self.navigationItem.title = NCBrandOptions.shared.brand
         } else {
             self.navigationItem.title = (serverUrl as NSString).lastPathComponent

+ 2 - 2
iOSClient/Files/NCFiles.swift

@@ -43,7 +43,7 @@ class NCFiles: NCCollectionViewCommon  {
     override func viewWillAppear(_ animated: Bool) {
         
         if isRoot {
-            serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         }
         
         super.viewWillAppear(animated)
@@ -54,7 +54,7 @@ class NCFiles: NCCollectionViewCommon  {
     override func initializeMain() {
         
         if isRoot {
-            serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
             reloadDataSourceNetwork(forced: true)
         }
         

+ 1 - 1
iOSClient/Login/CCLogin.m

@@ -331,7 +331,7 @@
             self.login.enabled = NO;
             [self.activity startAnimating];
             
-            NSString *webDAV = [[NCUtility shared] getWebDAVWithAccount:appDelegate.account];
+            NSString *webDAV = [[NCUtilityFileSystem shared] getWebDAVWithAccount:appDelegate.account];
             NSString *serverUrl = [NSString stringWithFormat:@"%@/%@", url, webDAV];
             
             [[NCCommunication shared] checkServerWithServerUrl:serverUrl completionHandler:^(NSInteger errorCode, NSString *errorDescription) {

+ 3 - 3
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -169,7 +169,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         appDelegate.activeViewController = self
 
         if serverUrl == "" {
-            appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            appDelegate.activeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
             appDelegate.activeServerUrl = serverUrl
         }
@@ -245,7 +245,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         // set active serverUrl
         if self.view?.window != nil {
             if serverUrl == "" {
-                appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+                appDelegate.activeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
             } else {
                 appDelegate.activeServerUrl = serverUrl
             }
@@ -871,7 +871,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     private func uploadPasteOcId(_ ocId: String) {
         if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
             if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-                let fileNameView = NCUtility.shared.createFileName(metadata.fileNameView, serverUrl: serverUrl, account: appDelegate.account)
+                let fileNameView = NCUtilityFileSystem.shared.createFileName(metadata.fileNameView, serverUrl: serverUrl, account: appDelegate.account)
                 let ocId = NSUUID().uuidString
                 
                 CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView))

+ 8 - 1
iOSClient/Main/Colleaction Common/NCListCell.swift

@@ -132,7 +132,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
     func selected(_ status: Bool) {
         if status {
             imageSelect.image = NCCollectionCommon.images.cellCheckedYes
-            backgroundView = NCUtility.shared.cellBlurEffect(with: self.bounds)
+            
+            let blurEffect = UIBlurEffect(style: .extraLight)
+            let blurEffectView = UIVisualEffectView(effect: blurEffect)
+            blurEffectView.frame = self.bounds
+            blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+            blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
+            backgroundView = blurEffectView
+            
             separator.isHidden = true
         } else {
             imageSelect.image = NCCollectionCommon.images.cellCheckedNo

+ 2 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -46,7 +46,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         
         self.init()
         
-        if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             titleServerUrl = "/"
         } else {
             if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
@@ -309,7 +309,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             
             self.serverUrl = serverUrl!
             
-            if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+            if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
                 self.titleServerUrl = "/"
             } else {
                 if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -170,7 +170,7 @@ extension NCCreateFormUploadConflictDelegate {
             
                 let fileNameMOV = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
                 
-                let newFileName = NCUtility.shared.createFileName(metadata.fileNameView, serverUrl: metadata.serverUrl, account: metadata.account)
+                let newFileName = NCUtilityFileSystem.shared.createFileName(metadata.fileNameView, serverUrl: metadata.serverUrl, account: metadata.account)
                 metadata.ocId = UUID().uuidString
                 metadata.fileName = newFileName
                 metadata.fileNameView = newFileName

+ 2 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -49,7 +49,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         
         self.init()
         
-        if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             titleServerUrl = "/"
         } else {
             titleServerUrl = (serverUrl as NSString).lastPathComponent
@@ -368,7 +368,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             CCUtility.setDirectoryScanDocuments(serverUrl!)
             self.serverUrl = serverUrl!
             
-            if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+            if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
                 self.titleServerUrl = "/"
             } else {
                 self.titleServerUrl = (serverUrl! as NSString).lastPathComponent

+ 2 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -45,7 +45,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
     
     public func setup(serverUrl: String, fileNamePath: String, fileName: String) {
     
-        if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             titleServerUrl = "/"
         } else {
             titleServerUrl = (serverUrl as NSString).lastPathComponent
@@ -193,7 +193,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
             
             self.serverUrl = serverUrl!
             
-            if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+            if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
                 self.titleServerUrl = "/"
             } else {
                 self.titleServerUrl = (serverUrl! as NSString).lastPathComponent

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -645,7 +645,7 @@ extension NCMedia {
         if let tableAccount = NCManageDatabase.shared.getAccountActive() {
             self.mediaPath = tableAccount.mediaPath
         }
-        let startServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) + mediaPath
+        let startServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) + mediaPath
         
         predicateDefault = NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND (typeFile == %@ OR typeFile == %@) AND NOT (session CONTAINS[c] 'upload')", appDelegate.account, startServerUrl, NCBrandGlobal.shared.metadataTypeFileImage, NCBrandGlobal.shared.metadataTypeFileVideo)
         

+ 1 - 1
iOSClient/Networking/NCNetworking.swift

@@ -842,7 +842,7 @@ import Queuer
         var fileNameFolder = CCUtility.removeForbiddenCharactersServer(fileName)!
         
         if (!overwrite) {
-            fileNameFolder = NCUtility.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account)
+            fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account)
         }
         if fileNameFolder.count == 0 {
             completion(0, "")

+ 1 - 1
iOSClient/Select/NCSelect.swift

@@ -178,7 +178,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
         
         // set the serverUrl
         if serverUrl == "" {
-            serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         }
                 
         // get auto upload folder

+ 2 - 2
iOSClient/Settings/CCManageAutoUpload.m

@@ -488,14 +488,14 @@
 {
     if (serverUrl != nil) {
         
-        if ([serverUrl isEqualToString:[[NCUtility shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account]]) {
+        if ([serverUrl isEqualToString:[[NCUtilityFileSystem shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account]]) {
             [[NCContentPresenter shared] messageNotification:@"_error_" description:@"_autoupload_error_select_folder_" delay:[[NCBrandGlobal shared] dismissAfterSecond] type:messageTypeError errorCode:NCBrandGlobal.shared.ErrorInternalError forced:true];
             return;
         }
         
         // Settings new folder Automatatic upload
         [[NCManageDatabase shared] setAccountAutoUploadFileName:serverUrl.lastPathComponent];
-        [[NCManageDatabase shared] setAccountAutoUploadDirectory:[[NCUtility shared] deletingLastPathComponentWithServerUrl:serverUrl urlBase:appDelegate.urlBase account:appDelegate.account] urlBase:appDelegate.urlBase account:appDelegate.account];
+        [[NCManageDatabase shared] setAccountAutoUploadDirectory:[[NCUtilityFileSystem shared] deletingLastPathComponentWithServerUrl:serverUrl urlBase:appDelegate.urlBase account:appDelegate.account] urlBase:appDelegate.urlBase account:appDelegate.account];
     }
 }
 

+ 1 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -183,7 +183,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
         cell.labelTitle.text = metadata.fileNameView
         cell.labelTitle.textColor = NCBrandColor.shared.textView
         
-        let serverUrlHome = NCUtility.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
+        let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
         var pathText = metadata.serverUrl.replacingOccurrences(of: serverUrlHome, with: "")
         if pathText == "" { pathText = "/" }
         cell.labelPath.text = pathText

+ 8 - 1
iOSClient/Trash/Cell/NCTrashListCell.swift

@@ -80,7 +80,14 @@ class NCTrashListCell: UICollectionViewCell {
     func selected(_ status: Bool) {
         if status {
             imageSelect.image = NCCollectionCommon.images.cellCheckedYes
-            backgroundView = NCUtility.shared.cellBlurEffect(with: self.bounds)
+            
+            let blurEffect = UIBlurEffect(style: .extraLight)
+            let blurEffectView = UIVisualEffectView(effect: blurEffect)
+            blurEffectView.frame = self.bounds
+            blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+            blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
+            backgroundView = blurEffectView
+            
         } else {
             imageSelect.image = NCCollectionCommon.images.cellCheckedNo
             backgroundView = nil

+ 2 - 2
iOSClient/UploadFromOtherUpp/CCUploadFromOtherUpp.m

@@ -44,7 +44,7 @@
 
     self.title = NSLocalizedString(@"_upload_", nil);
     
-    serverUrlLocal= [[NCUtility shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account];
+    serverUrlLocal= [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:appDelegate.urlBase account:appDelegate.account];
     destinationTitle = @"/";
     
     // changeTheming
@@ -173,7 +173,7 @@
 
 -(void)upload
 {
-    NSString *fileName = [[NCUtility shared] createFileName:self.fileNameTextfield.text serverUrl:serverUrlLocal account:appDelegate.account];
+    NSString *fileName = [[NCUtilityFileSystem shared] createFileName:self.fileNameTextfield.text serverUrl:serverUrlLocal account:appDelegate.account];
     
     tableMetadata *metadataForUpload = [[NCManageDatabase shared] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrlLocal urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:false];
     

+ 4 - 4
iOSClient/Utility/CCUtility.m

@@ -1253,7 +1253,7 @@
 
 + (NSString *)returnPathfromServerUrl:(NSString *)serverUrl urlBase:(NSString *)urlBase account:(NSString *)account
 {
-    NSString *homeServer = [[NCUtility shared] getHomeServerWithUrlBase:urlBase account:account];
+    NSString *homeServer = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase account:account];
     NSString *path = [serverUrl stringByReplacingOccurrencesOfString:homeServer withString:@""];
     return path;
 }
@@ -1264,7 +1264,7 @@
         return @"";
     }
     
-    NSString *homeServer = [[NCUtility shared] getHomeServerWithUrlBase:urlBase account:account];
+    NSString *homeServer = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase account:account];
     NSString *fileName = [NSString stringWithFormat:@"%@/%@", [serverUrl stringByReplacingOccurrencesOfString:homeServer withString:@""], metadataFileName];
     
     if ([fileName hasPrefix:@"/"]) fileName = [fileName substringFromIndex:1];
@@ -1514,7 +1514,7 @@
 
 + (BOOL)isFolderEncrypted:(NSString *)serverUrl e2eEncrypted:(BOOL)e2eEncrypted account:(NSString *)account urlBase:(NSString *)urlBase
 {
-    NSString *home = [[NCUtility shared] getHomeServerWithUrlBase:urlBase account:account];
+    NSString *home = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase account:account];
         
     if (e2eEncrypted) {
     
@@ -1532,7 +1532,7 @@
             if (directory.e2eEncrypted == true) {
                 return true;
             }
-            serverUrl = [[NCUtility shared] deletingLastPathComponentWithServerUrl:serverUrl urlBase:urlBase account:account];
+            serverUrl = [[NCUtilityFileSystem shared] deletingLastPathComponentWithServerUrl:serverUrl urlBase:urlBase account:account];
             directory = [[NCManageDatabase shared] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, serverUrl]];
         }
         

+ 1 - 141
iOSClient/Utility/NCUtility.swift

@@ -36,73 +36,6 @@ class NCUtility: NSObject {
     
     let activityIndicator = UIActivityIndicatorView(style: .whiteLarge)
     
-    @objc func getWebDAV(account: String) -> String {
-        return NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesWebDavRoot) ?? "remote.php/webdav"
-    }
-    
-    @objc func getDAV() -> String {
-        return "remote.php/dav"
-    }
-    
-    @objc func getHomeServer(urlBase: String, account: String) -> String {
-        return urlBase + "/" + self.getWebDAV(account: account)
-    }
-    
-    @objc func deletingLastPathComponent(serverUrl: String, urlBase: String, account: String) -> String {
-        if getHomeServer(urlBase: urlBase, account: account) == serverUrl { return serverUrl }
-        let fileName = (serverUrl as NSString).lastPathComponent
-        let serverUrl = serverUrl.replacingOccurrences(of: "/"+fileName, with: "", options: String.CompareOptions.backwards, range: nil)
-        return serverUrl
-    }
-    
-    @objc func createFileName(_ fileName: String, serverUrl: String, account: String) -> String {
-        
-        var resultFileName = fileName
-        var exitLoop = false
-            
-            while exitLoop == false {
-                
-                if NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "fileNameView == %@ AND serverUrl == %@ AND account == %@", resultFileName, serverUrl, account)) != nil {
-                    
-                    var name = NSString(string: resultFileName).deletingPathExtension
-                    let ext = NSString(string: resultFileName).pathExtension
-                    let characters = Array(name)
-                    
-                    if characters.count < 2 {
-                        if ext == "" {
-                            resultFileName = name + " " + "1"
-                        } else {
-                            resultFileName = name + " " + "1" + "." + ext
-                        }
-                    } else {
-                        let space = characters[characters.count-2]
-                        let numChar = characters[characters.count-1]
-                        var num = Int(String(numChar))
-                        if (space == " " && num != nil) {
-                            name = String(name.dropLast())
-                            num = num! + 1
-                            if ext == "" {
-                                resultFileName = name + "\(num!)"
-                            } else {
-                                resultFileName = name + "\(num!)" + "." + ext
-                            }
-                        } else {
-                            if ext == "" {
-                                resultFileName = name + " " + "1"
-                            } else {
-                                resultFileName = name + " " + "1" + "." + ext
-                            }
-                        }
-                    }
-                    
-                } else {
-                    exitLoop = true
-                }
-        }
-        
-        return resultFileName
-    }
-    
     @objc func isEncryptedMetadata(_ metadata: tableMetadata) -> Bool {
         
         if metadata.fileName != metadata.fileNameView && metadata.fileName.count == 32 && metadata.fileName.contains(".") == false {
@@ -112,18 +45,6 @@ class NCUtility: NSObject {
         return false
     }
     
-    func cellBlurEffect(with frame: CGRect) -> UIView {
-        
-        let blurEffect = UIBlurEffect(style: .extraLight)
-        let blurEffectView = UIVisualEffectView(effect: blurEffect)
-        
-        blurEffectView.frame = frame
-        blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-        blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
-        
-        return blurEffectView
-    }
-    
     func setLayoutForView(key: String, serverUrl: String, layout: String, sort: String, ascending: Bool, groupBy: String, directoryOnTop: Bool, titleButton: String, itemForLine: Int) {
         
         let string =  layout + "|" + sort + "|" + "\(ascending)" + "|" + groupBy + "|" + "\(directoryOnTop)" + "|" + titleButton + "|" + "\(itemForLine)"
@@ -406,33 +327,6 @@ class NCUtility: NSObject {
         CCUtility.deleteAllChainStore()
     }
     
-    @objc func UIColorFromRGB(rgbValue: UInt32) -> UIColor {
-        return UIColor(
-            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
-            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
-            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
-            alpha: CGFloat(1.0)
-        )
-    }
-    
-    @objc func RGBFromUIColor(uicolorValue: UIColor) -> UInt32 {
-        
-        var red: CGFloat = 0, green: CGFloat = 0, blue: CGFloat = 0, alpha: CGFloat = 0
-
-        if uicolorValue.getRed(&red, green: &green, blue: &blue, alpha: &alpha) {
-
-            var colorAsUInt : UInt32 = 0
-
-            colorAsUInt += UInt32(red * 255.0) << 16 +
-                           UInt32(green * 255.0) << 8 +
-                           UInt32(blue * 255.0)
-
-            return colorAsUInt
-        }
-        
-        return 0
-    }
-    
     @objc func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool {
         
         for char in permissions {
@@ -576,41 +470,7 @@ class NCUtility: NSObject {
         return(onlineStatus, statusMessage)
     }
     
-    @objc func settingThemingColor(_ themingColor: String?, themingColorElement: String?, themingColorText: String?) {
-                
-        // COLOR
-        if themingColor?.first == "#" {
-            if let color = UIColor(hex: themingColor!) {
-                NCBrandColor.shared.brand = color
-            } else {
-                NCBrandColor.shared.brand = NCBrandColor.shared.customer
-            }
-        } else {
-            NCBrandColor.shared.brand = NCBrandColor.shared.customer
-        }
-        
-        // COLOR TEXT
-        if themingColorText?.first == "#" {
-            if let color = UIColor(hex: themingColorText!) {
-                NCBrandColor.shared.brandText = color
-            } else {
-                NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
-            }
-        } else {
-            NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
-        }
-        
-        // COLOR ELEMENT
-        if themingColorElement?.first == "#" {
-            if let color = UIColor(hex: themingColorElement!) {
-                NCBrandColor.shared.brandElement = color
-            } else {
-                NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
-            }
-        } else {
-            NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
-        }
-    }
+   
     
     func imageFromVideo(url: URL, at time: TimeInterval) -> UIImage? {
         

+ 69 - 0
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -123,5 +123,74 @@ class NCUtilityFileSystem: NSObject {
         try? FileManager.default.removeItem(atPath: toPath)
         try? FileManager.default.linkItem(atPath: atPath, toPath: toPath)
     }
+    
+    // MARK: - 
+    
+    @objc func getWebDAV(account: String) -> String {
+        return NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesWebDavRoot) ?? "remote.php/webdav"
+    }
+    
+    @objc func getDAV() -> String {
+        return "remote.php/dav"
+    }
+    
+    @objc func getHomeServer(urlBase: String, account: String) -> String {
+        return urlBase + "/" + self.getWebDAV(account: account)
+    }
+    
+    @objc func deletingLastPathComponent(serverUrl: String, urlBase: String, account: String) -> String {
+        if getHomeServer(urlBase: urlBase, account: account) == serverUrl { return serverUrl }
+        let fileName = (serverUrl as NSString).lastPathComponent
+        let serverUrl = serverUrl.replacingOccurrences(of: "/"+fileName, with: "", options: String.CompareOptions.backwards, range: nil)
+        return serverUrl
+    }
+    
+    @objc func createFileName(_ fileName: String, serverUrl: String, account: String) -> String {
+        
+        var resultFileName = fileName
+        var exitLoop = false
+            
+            while exitLoop == false {
+                
+                if NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "fileNameView == %@ AND serverUrl == %@ AND account == %@", resultFileName, serverUrl, account)) != nil {
+                    
+                    var name = NSString(string: resultFileName).deletingPathExtension
+                    let ext = NSString(string: resultFileName).pathExtension
+                    let characters = Array(name)
+                    
+                    if characters.count < 2 {
+                        if ext == "" {
+                            resultFileName = name + " " + "1"
+                        } else {
+                            resultFileName = name + " " + "1" + "." + ext
+                        }
+                    } else {
+                        let space = characters[characters.count-2]
+                        let numChar = characters[characters.count-1]
+                        var num = Int(String(numChar))
+                        if (space == " " && num != nil) {
+                            name = String(name.dropLast())
+                            num = num! + 1
+                            if ext == "" {
+                                resultFileName = name + "\(num!)"
+                            } else {
+                                resultFileName = name + "\(num!)" + "." + ext
+                            }
+                        } else {
+                            if ext == "" {
+                                resultFileName = name + " " + "1"
+                            } else {
+                                resultFileName = name + " " + "1" + "." + ext
+                            }
+                        }
+                    }
+                    
+                } else {
+                    exitLoop = true
+                }
+        }
+        
+        return resultFileName
+    }
 }