소스 검색

clear code

marinofaggiana 4 년 전
부모
커밋
3367b2eb8b

+ 14 - 0
iOSClient/Brand/NCBrand.swift

@@ -270,6 +270,20 @@ class NCBrandColor: NSObject {
     let buttonMoreMore                              = "more"
     let buttonMoreStop                              = "stop"
     
+    // Text -  OnlyOffice - Collabora
+    let editorText                                  = "text"
+    let editorOnlyoffice                            = "onlyoffice"
+    let editorCollabora                             = "collabora"
+
+    let onlyofficeDocx                              = "onlyoffice_docx"
+    let onlyofficeXlsx                              = "onlyoffice_xlsx"
+    let onlyofficePptx                              = "onlyoffice_pptx"
+
+    // Template
+    let templateDocument                            = "document"
+    let templateSpreadsheet                         = "spreadsheet"
+    let templatePresentation                        = "presentation"
+    
     // Rich Workspace
     let fileNameRichWorkspace                       = "Readme.md"
     

+ 0 - 14
iOSClient/CCGlobal.h

@@ -190,20 +190,6 @@
 #define k_default_file_remote_share_permission_no_support_share_option      3
 #define k_default_folder_remote_share_permission_no_support_share_option    15
 
-// Text -  OnlyOffice - Collabora
-#define k_editor_text                                   @"text"
-#define k_editor_onlyoffice                             @"onlyoffice"
-#define k_editor_collabora                              @"collabora"
-
-#define k_onlyoffice_docx                               @"onlyoffice_docx"
-#define k_onlyoffice_xlsx                               @"onlyoffice_xlsx"
-#define k_onlyoffice_pptx                               @"onlyoffice_pptx"
-
-// Template
-#define k_template_document                             @"document"
-#define k_template_spreadsheet                          @"spreadsheet"
-#define k_template_presentation                         @"presentation"
-
 // Notification Center
 
 #define k_notificationCenter_applicationDidEnterBackground  @"applicationDidEnterBackground"

+ 3 - 3
iOSClient/Data/NCManageDatabase.swift

@@ -1035,10 +1035,10 @@ class NCManageDatabase: NSObject {
                         addObject.mimetypes.append(mimeType)
                     }
                     addObject.name = editor.name
-                    if editor.name.lowercased() == k_editor_onlyoffice {
-                        addObject.editor = k_editor_onlyoffice
+                    if editor.name.lowercased() == NCBrandGlobal.shared.editorOnlyoffice {
+                        addObject.editor = NCBrandGlobal.shared.editorOnlyoffice
                     } else {
-                        addObject.editor = k_editor_text
+                        addObject.editor = NCBrandGlobal.shared.editorText
                     }
                     for mimeType in editor.optionalMimetypes {
                         addObject.optionalMimetypes.append(mimeType)

+ 2 - 2
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -278,9 +278,9 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         var onlyofficeEditors = false
         if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: account) {
             for editor in editors {
-                if editor.editor == k_editor_text {
+                if editor.editor == NCBrandGlobal.shared.editorText {
                     textEditor = true
-                } else if editor.editor == k_editor_onlyoffice {
+                } else if editor.editor == NCBrandGlobal.shared.editorOnlyoffice {
                     onlyofficeEditors = true
                 }
             }

+ 13 - 13
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -315,11 +315,11 @@ import NCCommunication
     
     func createDocument(fileNamePath: String, fileName: String) {
         
-        if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {
+        if self.editorId == NCBrandGlobal.shared.editorText || self.editorId == NCBrandGlobal.shared.editorOnlyoffice {
              
             var customUserAgent: String?
             
-            if self.editorId == k_editor_onlyoffice {
+            if self.editorId == NCBrandGlobal.shared.editorOnlyoffice {
                 customUserAgent = NCUtility.shared.getCustomUserAgentOnlyOffice()
             }
             
@@ -345,7 +345,7 @@ import NCCommunication
             }
         }
         
-        if self.editorId == k_editor_collabora {
+        if self.editorId == NCBrandGlobal.shared.editorCollabora {
             
             NCCommunication.shared.createRichdocuments(path: fileNamePath, templateId: templateIdentifier) { (account, url, errorCode, errorDescription) in
                 
@@ -380,10 +380,10 @@ import NCCommunication
         indicator.color = NCBrandColor.shared.brandElement
         indicator.startAnimating()
         
-        if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {
+        if self.editorId == NCBrandGlobal.shared.editorText || self.editorId == NCBrandGlobal.shared.editorOnlyoffice {
                         
             var customUserAgent: String?
-            if self.editorId == k_editor_onlyoffice {
+            if self.editorId == NCBrandGlobal.shared.editorOnlyoffice {
                 customUserAgent = NCUtility.shared.getCustomUserAgentOnlyOffice()
             }
             NCCommunication.shared.NCTextGetListOfTemplates(customUserAgent: customUserAgent) { (account, templates, errorCode, errorMessage) in
@@ -417,13 +417,13 @@ import NCCommunication
                     let temp = NCCommunicationEditorTemplates()
                     
                     temp.identifier = ""
-                    if self.editorId == k_editor_text {
+                    if self.editorId == NCBrandGlobal.shared.editorText {
                         temp.ext = "md"
-                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_document {
+                    } else if self.editorId == NCBrandGlobal.shared.editorOnlyoffice && self.typeTemplate == NCBrandGlobal.shared.templateDocument {
                         temp.ext = "docx"
-                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_spreadsheet {
+                    } else if self.editorId == NCBrandGlobal.shared.editorOnlyoffice && self.typeTemplate == NCBrandGlobal.shared.templateSpreadsheet {
                         temp.ext = "xlsx"
-                    } else if self.editorId == k_editor_onlyoffice && self.typeTemplate == k_template_presentation {
+                    } else if self.editorId == NCBrandGlobal.shared.editorOnlyoffice && self.typeTemplate == NCBrandGlobal.shared.templatePresentation {
                         temp.ext = "pptx"
                     }
                     temp.name = "Empty"
@@ -441,7 +441,7 @@ import NCCommunication
             
         }
         
-        if self.editorId == k_editor_collabora  {
+        if self.editorId == NCBrandGlobal.shared.editorCollabora  {
                         
             NCCommunication.shared.getTemplatesRichdocuments(typeTemplate: typeTemplate) { (account, templates, errorCode, errorDescription) in
                 
@@ -476,11 +476,11 @@ import NCCommunication
                     let temp = NCCommunicationEditorTemplates()
                     
                     temp.identifier = ""
-                    if self.typeTemplate == k_template_document {
+                    if self.typeTemplate == NCBrandGlobal.shared.templateDocument {
                         temp.ext = "docx"
-                    } else if self.typeTemplate == k_template_spreadsheet {
+                    } else if self.typeTemplate == NCBrandGlobal.shared.templateSpreadsheet {
                         temp.ext = "xlsx"
-                    } else if self.typeTemplate == k_template_presentation {
+                    } else if self.typeTemplate == NCBrandGlobal.shared.templatePresentation {
                         temp.ext = "pptx"
                     }
                     temp.name = "Empty"

+ 22 - 22
iOSClient/Main/Menu/AppDelegate+Menu.swift

@@ -85,8 +85,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
         )
         #endif
       
-        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == k_editor_text}) && !isEncrypted {
-            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == k_editor_text})!
+        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == NCBrandGlobal.shared.editorText}) && !isEncrypted {
+            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == NCBrandGlobal.shared.editorText})!
             actions.append(
                 NCMenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), icon: CCGraphics.changeThemingColorImage(UIImage(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.shared.icon), action: { menuAction in
                     guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
@@ -95,9 +95,9 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                     navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
                     
                     let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                    viewController.editorId = k_editor_text
+                    viewController.editorId = NCBrandGlobal.shared.editorText
                     viewController.creatorId = directEditingCreator.identifier
-                    viewController.typeTemplate = k_template_document
+                    viewController.typeTemplate = NCBrandGlobal.shared.templateDocument
                     viewController.serverUrl = appDelegate.activeServerUrl
                     viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
@@ -188,8 +188,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
             )
         }
                
-        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_docx}) && !isEncrypted {
-            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_docx})!
+        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficeDocx}) && !isEncrypted {
+            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficeDocx})!
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_create_new_document_", comment: ""),
@@ -201,9 +201,9 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                         let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = k_editor_onlyoffice
+                        viewController.editorId = NCBrandGlobal.shared.editorOnlyoffice
                         viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = k_template_document
+                        viewController.typeTemplate = NCBrandGlobal.shared.templateDocument
                         viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
 
@@ -213,8 +213,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
             )
         }
         
-        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_xlsx}) && !isEncrypted {
-            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_xlsx})!
+        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficeXlsx}) && !isEncrypted {
+            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficeXlsx})!
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_create_new_spreadsheet_", comment: ""),
@@ -226,9 +226,9 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                         let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = k_editor_onlyoffice
+                        viewController.editorId = NCBrandGlobal.shared.editorOnlyoffice
                         viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = k_template_spreadsheet
+                        viewController.typeTemplate = NCBrandGlobal.shared.templateSpreadsheet
                         viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
@@ -238,8 +238,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
             )
         }
         
-        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_pptx}) && !isEncrypted {
-            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == k_editor_onlyoffice && $0.identifier == k_onlyoffice_pptx})!
+        if NCCommunication.shared.isNetworkReachable() && directEditingCreators != nil && directEditingCreators!.contains(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficePptx}) && !isEncrypted {
+            let directEditingCreator = directEditingCreators!.first(where: { $0.editor == NCBrandGlobal.shared.editorOnlyoffice && $0.identifier == NCBrandGlobal.shared.onlyofficePptx})!
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_create_new_presentation_", comment: ""),
@@ -251,9 +251,9 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                         let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = k_editor_onlyoffice
+                        viewController.editorId = NCBrandGlobal.shared.editorOnlyoffice
                         viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = k_template_presentation
+                        viewController.typeTemplate = NCBrandGlobal.shared.templatePresentation
                         viewController.serverUrl = appDelegate.activeServerUrl
                         viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 
@@ -276,8 +276,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = k_editor_collabora
-                            viewController.typeTemplate = k_template_document
+                            viewController.editorId = NCBrandGlobal.shared.editorCollabora
+                            viewController.typeTemplate = NCBrandGlobal.shared.templateDocument
                             viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
@@ -297,8 +297,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = k_editor_collabora
-                            viewController.typeTemplate = k_template_spreadsheet
+                            viewController.editorId = NCBrandGlobal.shared.editorCollabora
+                            viewController.typeTemplate = NCBrandGlobal.shared.templateSpreadsheet
                             viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
@@ -318,8 +318,8 @@ extension AppDelegate: NCAudioRecorderViewControllerDelegate {
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
                             let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = k_editor_collabora
-                            viewController.typeTemplate = k_template_presentation
+                            viewController.editorId = NCBrandGlobal.shared.editorCollabora
+                            viewController.typeTemplate = NCBrandGlobal.shared.templatePresentation
                             viewController.serverUrl = appDelegate.activeServerUrl
                             viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 

+ 1 - 1
iOSClient/Utility/NCUtility.swift

@@ -411,7 +411,7 @@ class NCUtility: NSObject {
         
         // HARDCODE
         if editor == "" {
-            editor = k_editor_text
+            editor = NCBrandGlobal.shared.editorText
         }
         
         return editor

+ 2 - 2
iOSClient/Viewer/NCViewer.swift

@@ -82,14 +82,14 @@ class NCViewer: NSObject {
             if NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil &&  NCCommunication.shared.isNetworkReachable() {
                 
                 guard let editor = NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) else { return }
-                if editor == k_editor_text || editor == k_editor_onlyoffice {
+                if editor == NCBrandGlobal.shared.editorText || editor == NCBrandGlobal.shared.editorOnlyoffice {
                     
                     if metadata.url == "" {
                         
                         var customUserAgent: String?
                         let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, account: metadata.account)!
                         
-                        if editor == k_editor_onlyoffice {
+                        if editor == NCBrandGlobal.shared.editorOnlyoffice {
                             customUserAgent = NCUtility.shared.getCustomUserAgentOnlyOffice()
                         }
                         

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -68,7 +68,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
         let language = NSLocale.preferredLanguages[0] as String
         request.addValue(language, forHTTPHeaderField: "Accept-Language")
                 
-        if editor == k_editor_onlyoffice {
+        if editor == NCBrandGlobal.shared.editorOnlyoffice {
             webView.customUserAgent = NCUtility.shared.getCustomUserAgentOnlyOffice()
         } else {
             webView.customUserAgent = CCUtility.getUserAgent()