marinofaggiana 4 жил өмнө
parent
commit
2f6d6dfef6

+ 14 - 0
iOSClient/Brand/NCBrand.swift

@@ -240,4 +240,18 @@ class NCBrandColor: NSObject {
     
     // Nextcloud unsupported
     let nextcloud_unsupported_version: Int          = 13
+    
+    // Layout
+    let layoutList                                  = "typeLayoutList"
+    let layoutGrid                                  = "typeLayoutGrid"
+    
+    let layoutViewMove                              = "LayoutMove"
+    let layoutViewTrash                             = "LayoutTrash"
+    let layoutViewOffline                           = "LayoutOffline"
+    let layoutViewFavorite                          = "LayoutFavorite"
+    let layoutViewFiles                             = "LayoutFiles"
+    let layoutViewViewInFolder                      = "ViewInFolder"
+    let layoutViewTransfers                         = "LayoutTransfers"
+    let layoutViewRecent                            = "LayoutRecent"
+    let layoutViewShares                            = "LayoutShares"
 }

+ 0 - 16
iOSClient/CCGlobal.h

@@ -223,22 +223,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
 
-// Layout
-#define k_layout_list                                   @"typeLayoutList"
-#define k_layout_grid                                   @"typeLayoutGrid"
-
-#define k_layout_view_move                              @"LayoutMove"
-#define k_layout_view_richdocument                      @"LayoutRichdocument"
-#define k_layout_view_trash                             @"LayoutTrash"
-#define k_layout_view_offline                           @"LayoutOffline"
-#define k_layout_view_favorite                          @"LayoutFavorite"
-#define k_layout_view_files                             @"LayoutFiles"
-#define k_layout_view_viewInFolder                      @"ViewInFolder"
-#define k_layout_view_transfers                         @"LayoutTransfers"
-#define k_layout_view_media                             @"LayoutMedia"
-#define k_layout_view_recent                            @"LayoutRecent"
-#define k_layout_view_shares                            @"LayoutShares"
-
 // Button Type in Cell list/grid
 #define k_buttonMoreMore                                @"more"
 #define k_buttonMoreStop                                @"stop"

+ 1 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -31,7 +31,7 @@ class NCFavorite: NCCollectionViewCommon  {
         
         appDelegate.activeFavorite = self
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
-        layoutKey = k_layout_view_favorite
+        layoutKey = NCBrandGlobal.shared.layoutViewFavorite
         enableSearchBar = true
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 300, height: 300, color: NCBrandColor.shared.yellowFavorite)
         emptyTitle = "_favorite_no_files_"

+ 2 - 2
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -33,7 +33,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         
         appDelegate.activeFileViewInFolder = self
         titleCurrentFolder = NCBrandOptions.shared.brand
-        layoutKey = k_layout_view_viewInFolder
+        layoutKey = NCBrandGlobal.shared.layoutViewViewInFolder
         enableSearchBar = false
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"
@@ -54,7 +54,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(itemForLine)
         
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             collectionView?.collectionViewLayout = listLayout
         } else {
             collectionView?.collectionViewLayout = gridLayout

+ 1 - 1
iOSClient/Files/NCFiles.swift

@@ -33,7 +33,7 @@ class NCFiles: NCCollectionViewCommon  {
         
         appDelegate.activeFiles = self
         titleCurrentFolder = NCBrandOptions.shared.brand
-        layoutKey = k_layout_view_files
+        layoutKey = NCBrandGlobal.shared.layoutViewFiles
         enableSearchBar = true
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"

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

@@ -177,7 +177,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(itemForLine)
         
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             collectionView?.collectionViewLayout = listLayout
         } else {
             collectionView?.collectionViewLayout = gridLayout
@@ -629,7 +629,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_list
+            layout = NCBrandGlobal.shared.layoutList
             NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layout)
         } else {
             // grid layout
@@ -639,7 +639,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_grid
+            layout = NCBrandGlobal.shared.layoutGrid
             NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layout)
         }
     }
@@ -1023,7 +1023,7 @@ extension NCCollectionViewCommon: UIViewControllerPreviewingDelegate {
 
         viewController.metadata = metadata
 
-        if layout == k_layout_grid {
+        if layout == NCBrandGlobal.shared.layoutGrid {
             guard let cell = collectionView?.cellForItem(at: indexPath) as? NCGridCell else { return nil }
             previewingContext.sourceRect = cell.frame
             viewController.imageFile = cell.imageItem.image
@@ -1079,7 +1079,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataTouch!.serverUrl, addFileName: metadataTouch!.fileName) else { return }
             
             // FILES
-            if layoutKey == k_layout_view_files {
+            if layoutKey == NCBrandGlobal.shared.layoutViewFiles {
                 
                 if let viewController = appDelegate.listFilesVC.value(forKey: serverUrlPush) {
                     guard let vcFiles = (viewController as? NCFiles) else { return }
@@ -1103,7 +1103,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             }
             
             // FAVORITE
-            if layoutKey == k_layout_view_favorite {
+            if layoutKey == NCBrandGlobal.shared.layoutViewFavorite {
             
                 if let viewController = appDelegate.listFavoriteVC.value(forKey: serverUrlPush) {
                     guard let vcFavorite = (viewController as? NCFavorite) else { return }
@@ -1126,7 +1126,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             }
             
             // OFFLINE
-            if layoutKey == k_layout_view_offline {
+            if layoutKey == NCBrandGlobal.shared.layoutViewOffline {
                 
                 if let viewController = appDelegate.listOfflineVC.value(forKey: serverUrlPush) {
                     guard let vcOffline = (viewController as? NCOffline) else { return }
@@ -1149,7 +1149,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             }
             
             // RECENT ( for push use Files ... he he he )
-            if layoutKey == k_layout_view_recent {
+            if layoutKey == NCBrandGlobal.shared.layoutViewRecent {
                 
                 if let viewController = appDelegate.listFilesVC.value(forKey: serverUrlPush) {
                     guard let vcFiles = (viewController as? NCFiles) else { return }
@@ -1173,7 +1173,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             }
             
             //VIEW IN FOLDER
-            if layoutKey == k_layout_view_viewInFolder {
+            if layoutKey == NCBrandGlobal.shared.layoutViewViewInFolder {
                 
                 let vcFileViewInFolder:NCFileViewInFolder = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder
                 
@@ -1184,7 +1184,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             }
             
             // SHARES ( for push use Files ... he he he )
-            if layoutKey == k_layout_view_shares {
+            if layoutKey == NCBrandGlobal.shared.layoutViewShares {
                 
                 if let viewController = appDelegate.listFilesVC.value(forKey: serverUrlPush) {
                     guard let vcFiles = (viewController as? NCFiles) else { return }
@@ -1313,7 +1313,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                 
         guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
-            if layout == k_layout_list {
+            if layout == NCBrandGlobal.shared.layoutList {
                 return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
             } else {
                 return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
@@ -1336,7 +1336,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         //
         // LAYOUT LIST
         //
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
             cell.delegate = self
@@ -1529,7 +1529,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         //
         // LAYOUT GRID
         //
-        if layout == k_layout_grid {
+        if layout == NCBrandGlobal.shared.layoutGrid {
             
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
             cell.delegate = self

+ 1 - 1
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -237,7 +237,7 @@ extension NCCollectionViewCommon {
         //
         // VIEW IN FOLDER
         //
-        if layoutKey == k_layout_view_recent && appDelegate.activeFileViewInFolder == nil {
+        if layoutKey == NCBrandGlobal.shared.layoutViewRecent && appDelegate.activeFileViewInFolder == nil {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_view_in_folder_", comment: ""),

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -31,7 +31,7 @@ class NCOffline: NCCollectionViewCommon  {
         
         appDelegate.activeOffline = self
         titleCurrentFolder = NSLocalizedString("_manage_file_offline_", comment: "")
-        layoutKey = k_layout_view_offline
+        layoutKey = NCBrandGlobal.shared.layoutViewOffline
         enableSearchBar = true
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"

+ 1 - 1
iOSClient/Recent/NCRecent.swift

@@ -31,7 +31,7 @@ class NCRecent: NCCollectionViewCommon  {
         
         appDelegate.activeRecent = self
         titleCurrentFolder = NSLocalizedString("_recent_", comment: "")
-        layoutKey = k_layout_view_recent
+        layoutKey = NCBrandGlobal.shared.layoutViewRecent
         enableSearchBar = false
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "recent"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"

+ 7 - 7
iOSClient/Select/NCSelect.swift

@@ -66,7 +66,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
     
     private var emptyDataSet: NCEmptyDataSet?
     
-    private let keyLayout = k_layout_view_move
+    private let keyLayout = NCBrandGlobal.shared.layoutViewMove
     private var serverUrlPush = ""
     private var metadataTouch: tableMetadata?
     private var metadataFolder = tableMetadata()
@@ -190,7 +190,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: keyLayout,serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(itemForLine)
         
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             collectionView.collectionViewLayout = listLayout
         } else {
             collectionView.collectionViewLayout = gridLayout
@@ -304,7 +304,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_list
+            layout = NCBrandGlobal.shared.layoutList
         } else {
             // grid layout
             UIView.animate(withDuration: 0.0, animations: {
@@ -313,7 +313,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_grid
+            layout = NCBrandGlobal.shared.layoutGrid
         }
     }
     
@@ -450,7 +450,7 @@ extension NCSelect: UICollectionViewDataSource {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         
         guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
-            if layout == k_layout_list {
+            if layout == NCBrandGlobal.shared.layoutList {
                 return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
             } else {
                 return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
@@ -473,7 +473,7 @@ extension NCSelect: UICollectionViewDataSource {
         
         // LAYOUT LIST
         
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
             cell.delegate = self
@@ -607,7 +607,7 @@ extension NCSelect: UICollectionViewDataSource {
         
         // LAYOUT GRID
         
-        if layout == k_layout_grid {
+        if layout == NCBrandGlobal.shared.layoutGrid {
             
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
             cell.delegate = self

+ 1 - 1
iOSClient/Shares/NCShares.swift

@@ -31,7 +31,7 @@ class NCShares: NCCollectionViewCommon  {
         
         appDelegate.activeShares = self
         titleCurrentFolder = NSLocalizedString("_list_shares_", comment: "")
-        layoutKey = k_layout_view_shares
+        layoutKey = NCBrandGlobal.shared.layoutViewShares 
         enableSearchBar = false
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 300, height: 300, color: .gray)
         emptyTitle = "_list_shares_no_files_"

+ 1 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -33,7 +33,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate  {
         
         appDelegate.activeTransfers = self
         titleCurrentFolder = NSLocalizedString("_transfers_", comment: "")
-        layoutKey = k_layout_view_transfers
+        layoutKey = NCBrandGlobal.shared.layoutViewTransfers
         enableSearchBar = false
         emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "load"), width: 300, height: 300, color: .gray)
         emptyTitle = "_no_transfer_"

+ 8 - 8
iOSClient/Trash/NCTrash.swift

@@ -98,10 +98,10 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
         
         self.navigationItem.title = titleCurrentFolder
 
-        (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash, serverUrl: "")
+        (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: NCBrandGlobal.shared.layoutViewTrash, serverUrl: "")
         gridLayout.itemForLine = CGFloat(itemForLine)
         
-        if layout == k_layout_list {
+        if layout == NCBrandGlobal.shared.layoutList {
             collectionView.collectionViewLayout = listLayout
         } else {
             collectionView.collectionViewLayout = gridLayout
@@ -155,8 +155,8 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_list
-            NCUtility.shared.setLayoutForView(key: k_layout_view_trash, serverUrl: "", layout: layout)
+            layout = NCBrandGlobal.shared.layoutList
+            NCUtility.shared.setLayoutForView(key: NCBrandGlobal.shared.layoutViewTrash, serverUrl: "", layout: layout)
         } else {
             // grid layout
             UIView.animate(withDuration: 0.0, animations: {
@@ -165,15 +165,15 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
                     self.collectionView.reloadData()
                 })
             })
-            layout = k_layout_grid
-            NCUtility.shared.setLayoutForView(key: k_layout_view_trash, serverUrl: "", layout: layout)
+            layout = NCBrandGlobal.shared.layoutGrid
+            NCUtility.shared.setLayoutForView(key: NCBrandGlobal.shared.layoutViewTrash, serverUrl: "", layout: layout)
         }
     }
     
     func tapOrderHeaderMenu(sender: Any) {
         
         let sortMenu = NCSortMenu()
-        sortMenu.toggleMenu(viewController: self, key: k_layout_view_trash, sortButton: sender as? UIButton, serverUrl: "", hideDirectoryOnTop: true)
+        sortMenu.toggleMenu(viewController: self, key: NCBrandGlobal.shared.layoutViewTrash, sortButton: sender as? UIButton, serverUrl: "", hideDirectoryOnTop: true)
     }
     
     func tapMoreHeaderMenu(sender: Any) {
@@ -543,7 +543,7 @@ extension NCTrash {
 
     @objc func reloadDataSource() {
         
-        (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash, serverUrl: "")
+        (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: NCBrandGlobal.shared.layoutViewTrash, serverUrl: "")
         
         datasource.removeAll()
         

+ 5 - 5
iOSClient/Utility/NCUtility.swift

@@ -175,7 +175,7 @@ class NCUtility: NSObject {
         var titleButton: String
         var itemForLine: Int
 
-        (_, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite, serverUrl: serverUrl)
+        (_, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: NCBrandGlobal.shared.layoutViewFavorite, serverUrl: serverUrl)
 
         setLayoutForView(key: key, serverUrl: serverUrl, layout: layout, sort: sort, ascending: ascending, groupBy: groupBy, directoryOnTop: directoryOnTop, titleButton: titleButton, itemForLine: itemForLine)
     }
@@ -210,8 +210,8 @@ class NCUtility: NSObject {
         }
         
         guard let string = UICKeyChainStore.string(forKey: keyStore, service: k_serviceShareKeyChain) else {
-            setLayoutForView(key: key, serverUrl: serverUrl, layout: k_layout_list, sort: "fileName", ascending: true, groupBy: "none", directoryOnTop: true, titleButton: "_sorted_by_name_a_z_", itemForLine: 3)
-            return (k_layout_list, "fileName", true, "none", true, "_sorted_by_name_a_z_", 3)
+            setLayoutForView(key: key, serverUrl: serverUrl, layout: NCBrandGlobal.shared.layoutList, sort: "fileName", ascending: true, groupBy: "none", directoryOnTop: true, titleButton: "_sorted_by_name_a_z_", itemForLine: 3)
+            return (NCBrandGlobal.shared.layoutList, "fileName", true, "none", true, "_sorted_by_name_a_z_", 3)
         }
 
         let array = string.components(separatedBy: "|")
@@ -223,9 +223,9 @@ class NCUtility: NSObject {
             return (array[0], array[1], sort.boolValue, array[3], directoryOnTop.boolValue, array[5], Int(itemForLine.intValue))
         }
         
-        setLayoutForView(key: key, serverUrl: serverUrl, layout: k_layout_list, sort: "fileName", ascending: true, groupBy: "none", directoryOnTop: true, titleButton: "_sorted_by_name_a_z_", itemForLine: 3)
+        setLayoutForView(key: key, serverUrl: serverUrl, layout: NCBrandGlobal.shared.layoutList, sort: "fileName", ascending: true, groupBy: "none", directoryOnTop: true, titleButton: "_sorted_by_name_a_z_", itemForLine: 3)
         
-        return (k_layout_list, "fileName", true, "none", true, "_sorted_by_name_a_z_", 3)
+        return (NCBrandGlobal.shared.layoutList, "fileName", true, "none", true, "_sorted_by_name_a_z_", 3)
     }
         
     func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, account: String, closure: @escaping (String?) -> ()) {