marinofaggiana 4 жил өмнө
parent
commit
16e18d6918

+ 3 - 2
iOSClient/Favorites/NCFavorite.swift

@@ -41,6 +41,7 @@ class NCFavorite: UIViewController, UIGestureRecognizerDelegate, NCListCellDeleg
     private var typeLayout = ""
     private var datasourceGroupBy = ""
     private var datasourceTitleButton = ""
+    private var datasourceItemForLine = 0
 
     private var autoUploadFileName = ""
     private var autoUploadDirectory = ""
@@ -102,7 +103,7 @@ class NCFavorite: UIViewController, UIGestureRecognizerDelegate, NCListCellDeleg
         autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
         autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
         
-        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
+        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
         
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
@@ -467,7 +468,7 @@ extension NCFavorite {
         var datasourceDirectoryOnTop: Bool
         
         sectionDatasource = CCSectionDataSourceMetadata()
-        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
+        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
         
         if serverUrl == "" {
             

+ 4 - 3
iOSClient/Main/Menu/NCSortMenu.swift

@@ -37,7 +37,8 @@ class NCSortMenu: NSObject {
     private var datasourceGroupBy = ""
     private var datasourceDirectoryOnTop = false
     private var datasourceTitleButton = ""
-    
+    private var datasourceItemForLine: Int = 0
+
     @objc func toggleMenu(viewController: UIViewController, layout: String, sortButton: UIButton?, serverUrl: String?, hideDirectoryOnTop: Bool = false) {
         
         self.layout = layout
@@ -45,7 +46,7 @@ class NCSortMenu: NSObject {
         self.serverUrl = serverUrl
         self.hideDirectoryOnTop = hideDirectoryOnTop
         
-        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: layout)
+        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: layout)
 
         let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateViewController(withIdentifier: "NCMainMenuTableViewController") as! NCMainMenuTableViewController
         mainMenuViewController.actions = self.initSortMenu()
@@ -74,7 +75,7 @@ class NCSortMenu: NSObject {
         
         self.sortButton?.setTitle(NSLocalizedString(self.datasourceTitleButton, comment: ""), for: .normal)
         
-        NCUtility.shared.setLayoutForView(key: self.layout, layout: self.typeLayout, sort: self.datasourceSorted, ascending: self.datasourceAscending, groupBy: self.datasourceGroupBy, directoryOnTop: self.datasourceDirectoryOnTop, titleButton: self.datasourceTitleButton)
+        NCUtility.shared.setLayoutForView(key: self.layout, layout: self.typeLayout, sort: self.datasourceSorted, ascending: self.datasourceAscending, groupBy: self.datasourceGroupBy, directoryOnTop: self.datasourceDirectoryOnTop, titleButton: self.datasourceTitleButton, itemForLine: self.datasourceItemForLine)
         
         NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.serverUrl ?? ""])
     }

+ 3 - 2
iOSClient/Offline/NCOffline.swift

@@ -41,6 +41,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
     private var typeLayout = ""
     private var datasourceGroupBy = ""
     private var datasourceTitleButton = ""
+    private var datasourceItemForLine = 0
 
     private var autoUploadFileName = ""
     private var autoUploadDirectory = ""
@@ -112,7 +113,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
         autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
         autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
         
-        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_offline)
+        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_offline)
 
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
@@ -541,7 +542,7 @@ extension NCOffline {
         var datasourceDirectoryOnTop: Bool
         
         sectionDatasource = CCSectionDataSourceMetadata()
-        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_offline)
+        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_offline)
 
         if serverUrl == "" {
             

+ 3 - 2
iOSClient/Select/NCSelect.swift

@@ -78,6 +78,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     private var typeLayout = ""
     private var datasourceGroupBy = ""
     private var datasourceTitleButton = ""
+    private var datasourceItemForLine = 0
 
     private var autoUploadFileName = ""
     private var autoUploadDirectory = ""
@@ -177,7 +178,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
         autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
         
-        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: layoutViewSelect)
+        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: layoutViewSelect)
         
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
@@ -533,7 +534,7 @@ extension NCSelect {
         var datasourceDirectoryOnTop: Bool
         
         sectionDatasource = CCSectionDataSourceMetadata()
-        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: layoutViewSelect)
+        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: layoutViewSelect)
         
         if serverUrl == "" {
             

+ 3 - 2
iOSClient/Trash/NCTrash.swift

@@ -42,6 +42,7 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
     private var typeLayout = ""
     private var datasourceGroupBy = "none"
     private var datasourceTitleButton = ""
+    private var datasourceItemForLine = 0
 
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
@@ -87,7 +88,7 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
         
         self.navigationItem.title = titleCurrentFolder
 
-        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash)
+        (typeLayout, _, _, datasourceGroupBy, _, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash)
 
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
@@ -557,7 +558,7 @@ extension NCTrash {
         var datasourceSorted: String
         var datasourceAscending: Bool
         
-        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, _, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash)
+        (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, _, datasourceTitleButton, datasourceItemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_trash)
         
         datasource.removeAll()
         

+ 24 - 20
iOSClient/Utility/NCUtility.swift

@@ -147,83 +147,87 @@ class NCUtility: NSObject {
         return blurEffectView
     }
     
-    func setLayoutForView(key: String, layout: String, sort: String, ascending: Bool, groupBy: String, directoryOnTop: Bool, titleButton: String) {
+    func setLayoutForView(key: String, layout: String, sort: String, ascending: Bool, groupBy: String, directoryOnTop: Bool, titleButton: String, itemForLine: Int) {
         
-        let string =  layout + "|" + sort + "|" + "\(ascending)" + "|" + groupBy + "|" + "\(directoryOnTop)" + "|" + titleButton
+        let string =  layout + "|" + sort + "|" + "\(ascending)" + "|" + groupBy + "|" + "\(directoryOnTop)" + "|" + titleButton + "|" + "\(itemForLine)"
         
         UICKeyChainStore.setString(string, forKey: key, service: k_serviceShareKeyChain)
     }
     
     func setLayoutForView(key: String, layout: String) {
         
-        var datasourceSorted = ""
-        var datasourceAscending = true
-        var datasourceGroupBy = ""
-        var datasourceDirectoryOnTop = false
-        var datasourceTitleButton = ""
+        var datasourceSorted: String
+        var datasourceAscending: Bool
+        var datasourceGroupBy: String
+        var datasourceDirectoryOnTop: Bool
+        var datasourceTitleButton: String
+        var itemForLine: Int
 
-        (_, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
+        (_, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop, datasourceTitleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: k_layout_view_favorite)
 
-        setLayoutForView(key: key, layout: layout, sort: datasourceSorted, ascending: datasourceAscending, groupBy: datasourceGroupBy, directoryOnTop: datasourceDirectoryOnTop, titleButton: datasourceTitleButton)
+        setLayoutForView(key: key, layout: layout, sort: datasourceSorted, ascending: datasourceAscending, groupBy: datasourceGroupBy, directoryOnTop: datasourceDirectoryOnTop, titleButton: datasourceTitleButton, itemForLine: itemForLine)
     }
     
     @objc func getLayoutForView(key: String) -> (String) {
         
         var typeLayout = ""
-        (typeLayout, _, _, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
+        (typeLayout, _, _, _, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
         return typeLayout
     }
     
     @objc func getSortedForView(key: String) -> (String) {
         
         var sorted = ""
-        (_, sorted, _, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
+        (_, sorted, _, _, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
         return sorted
     }
     
     @objc func getAscendingForView(key: String) -> (Bool) {
         
         var ascending: Bool
-        (_, _, ascending, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
+        (_, _, ascending, _, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
         return ascending
     }
     
     @objc func getGroupByForView(key: String) -> (String) {
         
         var groupBy: String
-        (_, _, _, groupBy, _, _) = NCUtility.shared.getLayoutForView(key: key)
+        (_, _, _, groupBy, _, _, _) = NCUtility.shared.getLayoutForView(key: key)
         return groupBy
     }
     
     @objc func getDirectoryOnTopForView(key: String) -> (Bool) {
         
         var directoryOnTop: Bool
-        (_, _, _, _, directoryOnTop, _) = NCUtility.shared.getLayoutForView(key: key)
+        (_, _, _, _, directoryOnTop, _, _) = NCUtility.shared.getLayoutForView(key: key)
         return directoryOnTop
     }
     
     @objc func getTitleButtonForView(key: String) -> (String) {
         
         var title: String
-        (_, _, _, _, _, title) = NCUtility.shared.getLayoutForView(key: key)
+        (_, _, _, _, _, title, _) = NCUtility.shared.getLayoutForView(key: key)
         return title
     }
     
-    func getLayoutForView(key: String) -> (String, String, Bool, String, Bool, String) {
+    func getLayoutForView(key: String) -> (String, String, Bool, String, Bool, String, Int) {
         
         guard let string = UICKeyChainStore.string(forKey: key, service: k_serviceShareKeyChain) else {
-            return (k_layout_list, "fileName", true, "none", true, "_sorted_by_name_a_z_")
+            setLayoutForView(key: key, 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)
         }
 
         let array = string.components(separatedBy: "|")
-        if array.count == 6 {
+        if array.count == 7 {
             let sort = NSString(string: array[2])
             let directoryOnTop = NSString(string: array[4])
+            let itemForLine = NSString(string: array[6])
 
-            return (array[0], array[1], sort.boolValue, array[3], directoryOnTop.boolValue, array[5])
+            return (array[0], array[1], sort.boolValue, array[3], directoryOnTop.boolValue, array[5], Int(itemForLine.intValue))
         }
         
-        return (k_layout_list, "fileName", true, "none", true, "_sorted_by_name_a_z_")
+        setLayoutForView(key: key, 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)
     }
         
     func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, account: String, closure: @escaping (String?) -> ()) {