Browse Source

Merge pull request #2063 from nextcloud/datasource

Datasource
Marino Faggiana 2 years ago
parent
commit
0acb90f3db

+ 3 - 3
Nextcloud.xcodeproj/project.pbxproj

@@ -2995,7 +2995,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 5;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -3058,7 +3058,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 5;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -3277,7 +3277,7 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
-				branch = unifiedsearchimprovement;
+				branch = develop;
 				kind = branch;
 			};
 		};

+ 4 - 0
Share/NCShareExtension+NCDelegate.swift

@@ -76,6 +76,10 @@ extension NCShareExtension: NCEmptyDataSetDelegate, NCAccountRequestDelegate {
         }
         self.activeAccount = activeAccount
 
+        // COLORS
+        NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
+        NCBrandColor.shared.createUserColors()
+
         // NETWORKING
         NCCommunicationCommon.shared.setup(
             account: activeAccount.account,

+ 8 - 0
Share/NCShareExtension.swift

@@ -126,6 +126,14 @@ class NCShareExtension: UIViewController {
             NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS)
         }
 
+        // Colors
+        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+            NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
+        } else {
+            NCBrandColor.shared.createImagesThemingColor()
+        }
+        NCBrandColor.shared.createUserColors()
+
         hud.indicatorView = JGProgressHUDRingIndicatorView()
         if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
             indicatorView.ringWidth = 1.5

+ 17 - 6
iOSClient/AppDelegate.swift

@@ -120,17 +120,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
             settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
 
+            NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
+
         } else {
 
             CCUtility.deleteAllChainStore()
             if let bundleID = Bundle.main.bundleIdentifier {
                 UserDefaults.standard.removePersistentDomain(forName: bundleID)
             }
+
+            NCBrandColor.shared.createImagesThemingColor()
         }
 
+        // Create user color
+        NCBrandColor.shared.createUserColors()
+
         // initialize
         NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize, userInfo:["atStart":1])
 
         // Process upload
         networkingProcessUpload = NCNetworkingProcessUpload()
@@ -182,6 +189,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             }
         }
 
+        // ITMS-90076: Potential Loss of Keychain Access
+        if let account = NCManageDatabase.shared.getActiveAccount(), CCUtility.getPassword(account.account).isEmpty, NCUtility.shared.getVersionApp(withBuild: false) == "4.4.1" {
+
+            let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: "Due to a change in the Nextcloud application identifier, the settings and password for accessing your cloud are reset, so please re-enter your account data and check your Settings, we are sorry about what happened but it is not up to us.", preferredStyle: .alert)
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+            window?.rootViewController?.present(alertController, animated: true, completion: { })
+        }
+
         return true
     }
 
@@ -298,17 +313,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     // MARK: -
 
     @objc private func initialize() {
-
-        if account == "" { return }
+        guard !account.isEmpty else { return }
 
         NCCommunicationCommon.shared.writeLog("initialize Main")
 
         // Registeration push notification
         NCPushNotification.shared().pushNotification()
 
-        // Setting Theming
-        NCBrandColor.shared.settingThemingColor(account: account)
-
         // Start Auto Upload
         NCAutoUpload.shared.initAutoUpload(viewController: nil) { _ in }
 

+ 85 - 72
iOSClient/Brand/NCBrand.swift

@@ -106,8 +106,6 @@ import UIKit
 class NCBrandColor: NSObject {
     @objc static let shared: NCBrandColor = {
         let instance = NCBrandColor()
-        instance.createImagesThemingColor()
-        instance.createUserColors()
         return instance
     }()
 
@@ -164,6 +162,9 @@ class NCBrandColor: NSObject {
     @objc public let yellowFavorite: UIColor = UIColor(red: 248.0/255.0, green: 205.0/255.0, blue: 70.0/255.0, alpha: 1.0)
 
     public var userColors: [CGColor] = []
+    public var themingColor: String = ""
+    public var themingColorElement: String = ""
+    public var themingColorText: String = ""
 
     @objc public var annotationColor: UIColor {
         get {
@@ -342,16 +343,32 @@ class NCBrandColor: NSObject {
     }
 
     override init() {
-        self.brand = self.customer
-        self.brandElement = self.customer
-        self.brandText = self.customerText
+        brand = customer
+        brandElement = customer
+        brandText = customerText
     }
 
-    private func createUserColors() {
-        self.userColors = generateColors()
+    /*
+    func createColors() {
+        #if !EXTENSION
+        if let tableAccount = NCManageDatabase.shared.getActiveAccount() {
+            settingThemingColor(account: tableAccount.account)
+        } else {
+            createImagesThemingColor()
+        }
+        createUserColors()
+        #else
+        createImagesThemingColor()
+        createUserColors()
+        #endif
+    }
+    */
+    
+    func createUserColors() {
+        userColors = generateColors()
     }
 
-    public func createImagesThemingColor() {
+    func createImagesThemingColor() {
 
         let gray: UIColor = UIColor(red: 162.0/255.0, green: 162.0/255.0, blue: 162.0/255.0, alpha: 0.5)
 
@@ -394,91 +411,87 @@ class NCBrandColor: NSObject {
         cacheImages.iconPages = UIImage(named: "icon-pages")!.image(color: brandElement, size: folderWidth)
     }
 
-    #if !EXTENSION
-    public func settingThemingColor(account: String) {
+    func settingThemingColor(account: String) {
 
         let darker: CGFloat = 30    // %
         let lighter: CGFloat = 30   // %
 
         if NCBrandOptions.shared.use_themingColor {
 
-            let themingColor = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColor)
-
-            let themingColorElement = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorElement)
-
-            let themingColorText = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText)
-
-            settingBrandColor(themingColor, themingColorElement: themingColorElement, themingColorText: themingColorText)
+            if let themingColor = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColor),
+               let themingColorElement = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorElement),
+               let themingColorText = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText) {
+
+                self.themingColor = themingColor
+                self.themingColorElement = themingColorElement
+                self.themingColorText = themingColorText
+                
+                // COLOR
+                if themingColor.first == "#" {
+                    if let color = UIColor(hex: themingColor) {
+                        brand = color
+                    } else {
+                        brand = customer
+                    }
+                } else {
+                    brand = customer
+                }
 
-            if NCBrandColor.shared.brandElement.isTooLight() {
-                if let color = NCBrandColor.shared.brandElement.darker(by: darker) {
-                    NCBrandColor.shared.brandElement = color
+                // COLOR TEXT
+                if themingColorText.first == "#" {
+                    if let color = UIColor(hex: themingColorText) {
+                        brandText = color
+                    } else {
+                        brandText = customerText
+                    }
+                } else {
+                    brandText = customerText
                 }
-            } else if NCBrandColor.shared.brandElement.isTooDark() {
-                if let color = NCBrandColor.shared.brandElement.lighter(by: lighter) {
-                    NCBrandColor.shared.brandElement = color
+
+                // COLOR ELEMENT
+                if themingColorElement.first == "#" {
+                    if let color = UIColor(hex: themingColorElement) {
+                        brandElement = color
+                    } else {
+                        brandElement = brand
+                    }
+                } else {
+                    brandElement = brand
                 }
             }
 
-        } else {
-
-            if NCBrandColor.shared.customer.isTooLight() {
-                if let color = NCBrandColor.shared.customer.darker(by: darker) {
-                    NCBrandColor.shared.brandElement = color
+            if brandElement.isTooLight() {
+                if let color = brandElement.darker(by: darker) {
+                    brandElement = color
                 }
-            } else if NCBrandColor.shared.customer.isTooDark() {
-                if let color = NCBrandColor.shared.customer.lighter(by: lighter) {
-                    NCBrandColor.shared.brandElement = color
+            } else if brandElement.isTooDark() {
+                if let color = brandElement.lighter(by: lighter) {
+                    brandElement = color
                 }
-            } else {
-                NCBrandColor.shared.brandElement = NCBrandColor.shared.customer
             }
 
-            NCBrandColor.shared.brand = NCBrandColor.shared.customer
-            NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
-        }
-
-        DispatchQueue.main.async {
-            self.createImagesThemingColor()
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
-        }
-    }
-    #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
+            if self.customer.isTooLight() {
+                if let color = customer.darker(by: darker) {
+                    brandElement = color
+                }
+            } else if customer.isTooDark() {
+                if let color = customer.lighter(by: lighter) {
+                    brandElement = color
+                }
             } else {
-                NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
+                brandElement = customer
             }
-        } 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
+            brand = customer
+            brandText = customerText
         }
+        
+        createImagesThemingColor()
+        #if !EXTENSION
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
+        #endif
     }
 
     private func stepCalc(steps: Int, color1: CGColor, color2: CGColor) -> [CGFloat] {

+ 10 - 1
iOSClient/Data/NCDataSource.swift

@@ -29,6 +29,8 @@ class NCDataSource: NSObject {
     public var metadatasSource: [tableMetadata] = []
     public var metadatasForSection: [NCMetadataForSection] = []
 
+    public var directory: tableDirectory?
+
     private var sectionsValue: [String] = []
     private var providers: [NCCSearchProvider]?
     private var searchResults: [NCCSearchResult]?
@@ -46,10 +48,11 @@ class NCDataSource: NSObject {
         super.init()
     }
 
-    init(metadatasSource: [tableMetadata], account: String, sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, filterLivePhoto: Bool? = true, groupByField: String = "name", providers: [NCCSearchProvider]? = nil, searchResults: [NCCSearchResult]? = nil) {
+    init(metadatasSource: [tableMetadata], account: String, directory: tableDirectory? = nil, sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, filterLivePhoto: Bool? = true, groupByField: String = "name", providers: [NCCSearchProvider]? = nil, searchResults: [NCCSearchResult]? = nil) {
         super.init()
 
         self.metadatasSource = metadatasSource
+        self.directory = directory
         self.shares = NCManageDatabase.shared.getTableShares(account: account)
         self.localFiles = NCManageDatabase.shared.getTableLocalFile(account: account)
         self.sort = sort ?? "none"
@@ -71,6 +74,7 @@ class NCDataSource: NSObject {
 
         self.metadatasSource.removeAll()
         self.metadatasForSection.removeAll()
+        self.directory = nil
         self.sectionsValue.removeAll()
         self.providers = nil
         self.searchResults = nil
@@ -78,6 +82,11 @@ class NCDataSource: NSObject {
         self.localFiles.removeAll()
     }
 
+    func clearDirectory() {
+
+        self.directory = nil
+    }
+
     func addSection(metadatas: [tableMetadata], searchResult: NCCSearchResult?) {
 
         self.metadatasSource.append(contentsOf: metadatas)

+ 1 - 6
iOSClient/Favorites/NCFavorite.swift

@@ -44,7 +44,7 @@ class NCFavorite: NCCollectionViewCommon {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         if !self.isSearching {
@@ -75,11 +75,6 @@ class NCFavorite: NCCollectionViewCommon {
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
 
-        if isSearching {
-            networkSearch()
-            return
-        }
-
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
 

+ 1 - 1
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -79,7 +79,7 @@ class NCFileViewInFolder: NCCollectionViewCommon {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         DispatchQueue.global().async {

+ 29 - 23
iOSClient/Files/NCFiles.swift

@@ -46,43 +46,54 @@ class NCFiles: NCCollectionViewCommon {
     }
 
     override func viewWillAppear(_ animated: Bool) {
-
         if isRoot {
             serverUrl = NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account)
             titleCurrentFolder = getNavigationTitle()
         }
-
         super.viewWillAppear(animated)
     }
 
     // MARK: - NotificationCenter
 
-    override func initialize() {
-
+    override func initialize(_ notification: NSNotification) {
         if isRoot {
             serverUrl = NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account)
             titleCurrentFolder = getNavigationTitle()
-            reloadDataSourceNetwork(forced: true)
         }
+        super.initialize(notification)
 
-        super.initialize()
+        if let userInfo = notification.userInfo as NSDictionary?, userInfo["atStart"] as? Int == 1 {
+            return
+        }
+
+        reloadDataSource(forced: false)
+        reloadDataSourceNetwork()
     }
 
     // MARK: - DataSource + NC Endpoint
-
-    override func reloadDataSource() {
+    //
+    // forced: do no make the etag of directory test (default)
+    //
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
-        guard !self.isSearching, !self.appDelegate.account.isEmpty, !self.appDelegate.urlBase.isEmpty else { return }
+        guard !isSearching, !appDelegate.account.isEmpty, !appDelegate.urlBase.isEmpty, !serverUrl.isEmpty else { return }
 
-        self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
+        self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
         if self.metadataFolder == nil {
-            self.metadataFolder = NCManageDatabase.shared.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl: self.serverUrl)
+            self.metadataFolder = NCManageDatabase.shared.getMetadataFolder(account: self.appDelegate.account, urlBase: appDelegate.urlBase, serverUrl: serverUrl)
         }
+        let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
 
-        self.dataSource = NCDataSource(
+        // FORCED false: test the directory.etag
+        if !forced, let directory = directory, directory.etag == dataSource.directory?.etag {
+            return
+        }
+
+        dataSource = NCDataSource(
             metadatasSource: self.metadatasSource,
             account: self.appDelegate.account,
+            directory: directory,
             sort: self.layoutForView?.sort,
             ascending: self.layoutForView?.ascending,
             directoryOnTop: self.layoutForView?.directoryOnTop,
@@ -100,34 +111,29 @@ class NCFiles: NCCollectionViewCommon {
 
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
-
-        if isSearching {
+        guard !isSearching else {
             networkSearch()
             return
         }
-
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
 
         networkReadFolder(forced: forced) { tableDirectory, metadatas, metadatasUpdate, metadatasDelete, errorCode, _ in
             if errorCode == 0 {
                 for metadata in metadatas ?? [] {
-                    if !metadata.directory {
-                        if NCManageDatabase.shared.isDownloadMetadata(metadata, download: false) {
-                            NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile)
-                        }
+                    if !metadata.directory, NCManageDatabase.shared.isDownloadMetadata(metadata, download: false) {
+                        NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile)
                     }
                 }
             }
 
             DispatchQueue.main.async {
-                self.refreshControl.endRefreshing()
                 self.isReloadDataSourceNetworkInProgress = false
                 self.richWorkspaceText = tableDirectory?.richWorkspace
+                self.refreshControl.endRefreshing()
+                self.collectionView?.reloadData()
                 if metadatasUpdate?.count ?? 0 > 0 || metadatasDelete?.count ?? 0 > 0 || forced {
-                    self.reloadDataSource()
-                } else {
-                    self.collectionView?.reloadData()
+                    self.reloadDataSource(forced: false)
                 }
             }
         }

+ 34 - 49
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -118,6 +118,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         // Refresh Control
         collectionView.addSubview(refreshControl)
         refreshControl.action(for: .valueChanged) { _ in
+            self.dataSource.clearDirectory()
             self.reloadDataSourceNetwork(forced: true)
         }
 
@@ -133,19 +134,23 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         // Notification
 
-        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-
-        changeTheming()
+        NotificationCenter.default.addObserver(self, selector: #selector(initialize(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(changeThemingWithReloadData), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
     }
 
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
 
-        // ACTIVE
         appDelegate.activeViewController = self
 
-        //
+        layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
+        gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
+        if layoutForView?.layout == NCGlobal.shared.layoutList {
+            collectionView?.collectionViewLayout = listLayout
+        } else {
+            collectionView?.collectionViewLayout = gridLayout
+        }
+
         NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterCloseRichWorkspaceWebView), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeStatusFolderE2EE(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeStatusFolderE2EE), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(setNavigationItem), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadAvatar), object: nil)
@@ -180,16 +185,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         navigationController?.setNavigationBarHidden(false, animated: true)
         setNavigationItem()
 
-        changeTheming()
-        reloadDataSource()
-    }
-
-    override func viewDidAppear(_ animated: Bool) {
-        super.viewDidAppear(animated)
-
-        if !isSearching {
-            reloadDataSourceNetwork()
-        }
+        reloadDataSource(forced: false)
+        reloadDataSourceNetwork()
     }
 
     override func viewWillDisappear(_ animated: Bool) {
@@ -246,15 +243,14 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
-
+        // Toggle Appearance
         changeTheming()
     }
 
     // MARK: - NotificationCenter
 
-    @objc func initialize() {
-
-        if appDelegate.account == "" { return }
+    @objc func initialize(_ notification: NSNotification) {
+        guard !appDelegate.account.isEmpty else { return }
 
         // Search
         if searchController?.isActive ?? false || isSearching {
@@ -284,29 +280,31 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             self.navigationController?.popToRootViewController(animated: false)
         }
 
+        layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
+        gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
+        if layoutForView?.layout == NCGlobal.shared.layoutList {
+            collectionView?.collectionViewLayout = listLayout
+        } else {
+            collectionView?.collectionViewLayout = gridLayout
+        }
+
         setNavigationItem()
-        reloadDataSource()
-        changeTheming()
     }
 
+    @objc func changeThemingWithReloadData() {
+        changeTheming()
+        collectionView.reloadData()
+    }
+    
     @objc func changeTheming() {
 
         view.backgroundColor = NCBrandColor.shared.systemBackground
         collectionView.backgroundColor = NCBrandColor.shared.systemBackground
         refreshControl.tintColor = .gray
 
-        layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
-        gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
-
-        if layoutForView?.layout == NCGlobal.shared.layoutList {
-            collectionView?.collectionViewLayout = listLayout
-        } else {
-            collectionView?.collectionViewLayout = gridLayout
-        }
-
         // IMAGE BACKGROUND
-        if layoutForView?.imageBackgroud != "" {
-            let imagePath = CCUtility.getDirectoryGroup().appendingPathComponent(NCGlobal.shared.appBackground).path + "/" + layoutForView!.imageBackgroud
+        if let layoutForView = layoutForView, layoutForView.imageBackgroud != "" {
+            let imagePath = CCUtility.getDirectoryGroup().appendingPathComponent(NCGlobal.shared.appBackground).path + "/" + layoutForView.imageBackgroud
             do {
                 let data = try Data(contentsOf: URL(fileURLWithPath: imagePath))
                 if let image = UIImage(data: data) {
@@ -335,24 +333,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 collectionView.backgroundColor = NCBrandColor.shared.systemBackground
             }
         }
-
-        collectionView.reloadData()
     }
 
     @objc func reloadDataSource(_ notification: NSNotification) {
-
         reloadDataSource()
     }
 
     @objc func reloadDataSourceNetworkForced(_ notification: NSNotification) {
-
-        guard let userInfo = notification.userInfo as NSDictionary?,
-              let serverUrl = userInfo["serverUrl"] as? String,
-              serverUrl == self.serverUrl
-        else {
-            return
-        }
-
         reloadDataSourceNetwork(forced: true)
     }
 
@@ -435,7 +422,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
 
     @objc func renameFile(_ notification: NSNotification) {
-
         reloadDataSource()
     }
 
@@ -1006,9 +992,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     // MARK: - DataSource + NC Endpoint
 
-    @objc func reloadDataSource() {
-
-        if appDelegate.account == "" { return }
+    @objc func reloadDataSource(forced: Bool = true) {
+        guard !appDelegate.account.isEmpty else { return }
 
         // Get richWorkspace Text
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
@@ -1022,7 +1007,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
 
         // get layout for view
-        layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
+        //layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
 
         // set GroupField for Grid
         if !self.isSearching && layoutForView?.layout == NCGlobal.shared.layoutGrid {

+ 2 - 2
iOSClient/Main/Collection Common/NCSelectableNavigationView.swift

@@ -45,7 +45,7 @@ protocol NCSelectableNavigationView: AnyObject {
 
     var selectActions: [NCMenuAction] { get }
 
-    func reloadDataSource()
+    func reloadDataSource(forced: Bool)
     func setNavigationItem()
 
     func tapSelectMenu()
@@ -136,7 +136,7 @@ extension NCSelectableNavigationView where Self: UIViewController {
             actions.append(.saveMediaAction(selectedMediaMetadatas: selectedMediaMetadatas, completion: tapSelect))
         }
         actions.append(.setAvailableOfflineAction(selectedMetadatas: selectedMetadatas, isAnyOffline: isAnyOffline, viewController: self, completion: {
-            self.reloadDataSource()
+            self.reloadDataSource(forced: true)
             self.tapSelect()
         }))
 

+ 1 - 2
iOSClient/Main/NCMainTabBar.swift

@@ -209,8 +209,7 @@ class NCMainTabBar: UITabBar {
     }
 
     @objc func updateBadgeNumber() {
-
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else { return }
 
         let counterDownload = NCOperationQueue.shared.downloadCount()
         let counterUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d OR status == %d", NCGlobal.shared.metadataStatusWaitUpload, NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading)).count

+ 1 - 2
iOSClient/Media/NCMedia.swift

@@ -471,8 +471,7 @@ extension NCMedia {
     // MARK: - Datasource
 
     @objc func reloadDataSourceWithCompletion(_ completion: @escaping (_ metadatas: [tableMetadata]) -> Void) {
-
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else { return }
 
         if account != appDelegate.account {
             self.metadatas = []

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

@@ -158,7 +158,9 @@ extension NCCollectionViewCommon {
         // OFFLINE
         //
         if !isFolderEncrypted {
-            actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: self, completion: self.reloadDataSource))
+            actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: self, completion: {
+                self.reloadDataSource()
+            }))
         }
 
         //

+ 68 - 1
iOSClient/Menu/NCTrash+Menu.swift

@@ -28,6 +28,62 @@ import FloatingPanel
 import NCCommunication
 
 extension NCTrash {
+    var selectActions: [NCMenuAction] {
+        [
+            NCMenuAction(
+                title: NSLocalizedString("_trash_restore_selected_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "restore"),
+                action: { _ in
+                    self.selectOcId.forEach(self.restoreItem)
+                    self.tapSelect()
+                }
+            ),
+            NCMenuAction(
+                title: NSLocalizedString("_trash_delete_selected_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "trash"),
+                action: { _ in
+                    let alert = UIAlertController(title: NSLocalizedString("_trash_delete_selected_", comment: ""), message: "", preferredStyle: .alert)
+                    alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
+                        self.selectOcId.forEach(self.deleteItem)
+                        self.tapSelect()
+                    }))
+                    alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: { _ in }))
+                    self.present(alert, animated: true, completion: nil)
+                }
+            )
+        ]
+    }
+
+    func toggleMenuMoreHeader() {
+
+        var actions: [NCMenuAction] = []
+
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_trash_restore_all_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "restore"),
+                action: { _ in
+                    self.datasource.forEach({ self.restoreItem(with: $0.fileId) })
+                }
+            )
+        )
+
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_trash_delete_all_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "trash"),
+                action: { _ in
+                    let alert = UIAlertController(title: NSLocalizedString("_trash_delete_all_description_", comment: ""), message: "", preferredStyle: .alert)
+                    alert.addAction(UIAlertAction(title: NSLocalizedString("_trash_delete_all_", comment: ""), style: .destructive, handler: { _ in
+                        self.emptyTrash()
+                    }))
+                    alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
+                    self.present(alert, animated: true, completion: nil)
+                }
+            )
+        )
+        presentMenu(with: actions)
+    }
 
     func toggleMenuMore(with objectId: String, image: UIImage?, isGridCell: Bool) {
 
@@ -35,6 +91,17 @@ extension NCTrash {
             return
         }
 
+        guard isGridCell else {
+            let alert = UIAlertController(title: NSLocalizedString("_want_delete_", comment: ""), message: tableTrash.trashbinFileName, preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
+                self.deleteItem(with: objectId)
+            }))
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
+            self.present(alert, animated: true, completion: nil)
+
+            return
+        }
+
         var actions: [NCMenuAction] = []
 
         var iconHeader: UIImage!
@@ -68,7 +135,7 @@ extension NCTrash {
 
         actions.append(
             NCMenuAction(
-                title: NSLocalizedString("_trash_delete_permanently_", comment: ""),
+                title: NSLocalizedString("_delete_", comment: ""),
                 icon: NCUtility.shared.loadImage(named: "trash"),
                 action: { _ in
                     self.deleteItem(with: objectId)

+ 1 - 2
iOSClient/NCGlobal.swift

@@ -324,14 +324,13 @@ class NCGlobal: NSObject {
     let notificationCenterApplicationDidBecomeActive            = "applicationDidBecomeActive"
     let notificationCenterApplicationWillResignActive           = "applicationWillResignActive"
 
-    @objc let notificationCenterInitialize                      = "initialize"
+    @objc let notificationCenterInitialize                      = "initialize"                      // userInfo?: atStart
     @objc let notificationCenterChangeTheming                   = "changeTheming"
     let notificationCenterRichdocumentGrabFocus                 = "richdocumentGrabFocus"
     let notificationCenterReloadDataNCShare                     = "reloadDataNCShare"
     let notificationCenterCloseRichWorkspaceWebView             = "closeRichWorkspaceWebView"
     let notificationCenterUpdateBadgeNumber                     = "updateBadgeNumber"
     let notificationCenterReloadAvatar                          = "reloadAvatar"
-    let notificationCenterOpenFileViewInFolder                  = "openFileViewInFolder"            // userInfo: serverUrl, fileName
 
     @objc let notificationCenterReloadDataSource                = "reloadDataSource"                // userInfo: ocId?, serverUrl?
     let notificationCenterReloadDataSourceNetworkForced         = "reloadDataSourceNetworkForced"   // userInfo: serverUrl?

+ 4 - 2
iOSClient/Networking/NCAutoUpload.swift

@@ -74,8 +74,10 @@ class NCAutoUpload: NSObject {
     }
 
     private func uploadAssetsNewAndFull(viewController: UIViewController?, selector: String, log: String, completion: @escaping (_ items: Int) -> Void) {
-
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else {
+            completion(0)
+            return
+        }
 
         guard let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", appDelegate.account)) else { return }
         let autoUploadPath = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: account.urlBase, account: account.account)

+ 1 - 2
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -53,8 +53,7 @@ class NCNetworkingProcessUpload: NSObject {
     }
 
     @objc private func process() {
-
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else { return }
 
         var counterUpload: Int = 0
         let sessionSelectors = [NCGlobal.shared.selectorUploadFile, NCGlobal.shared.selectorUploadAutoUpload, NCGlobal.shared.selectorUploadAutoUploadAll]

+ 119 - 136
iOSClient/Networking/NCService.swift

@@ -39,11 +39,11 @@ class NCService: NSObject {
 
         NCManageDatabase.shared.clearAllAvatarLoaded()
 
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else { return }
 
-        self.addInternalTypeIdentifier()
-        self.requestUserProfile()
-        self.requestServerStatus()
+        addInternalTypeIdentifier()
+        requestServerStatus()
+        requestUserProfile()
     }
 
     // MARK: -
@@ -79,180 +79,167 @@ class NCService: NSObject {
         NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: "com.apple.iwork.keynote.key", classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: NCGlobal.shared.editorQuickLook, iconName: NCCommunicationCommon.typeIconFile.ppt.rawValue, name: "keynote")
     }
 
-    private func requestUserProfile() {
+    private func requestServerStatus() {
 
-        if appDelegate.account == "" { return }
+        NCCommunication.shared.getServerStatus(serverUrl: appDelegate.urlBase, queue: NCCommunicationCommon.shared.backgroundQueue) { serverProductName, _, versionMajor, _, _, extendedSupport, errorCode, _ in
+            guard errorCode == 0, extendedSupport == false else {
+                return
+            }
 
-        NCCommunication.shared.getUserProfile(queue: NCCommunicationCommon.shared.backgroundQueue) { account, userProfile, errorCode, errorDescription in
+            if serverProductName == "owncloud" {
+                NCContentPresenter.shared.messageNotification("_warning_", description: "_warning_owncloud_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
+            } else if versionMajor <=  NCGlobal.shared.nextcloud_unsupported_version {
+                NCContentPresenter.shared.messageNotification("_warning_", description: "_warning_unsupported_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
+            }
+        }
+    }
 
-            if errorCode == 0 && account == self.appDelegate.account {
+    private func requestUserProfile() {
+        guard !appDelegate.account.isEmpty else { return }
 
-                // Update User (+ userProfile.id) & active account & account network
-                guard let tableAccount = NCManageDatabase.shared.setAccountUserProfile(userProfile!) else {
-                    NCContentPresenter.shared.messageNotification("Account", description: "Internal error : account not found on DB", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
-                    return
+        NCCommunication.shared.getUserProfile(queue: NCCommunicationCommon.shared.backgroundQueue) { account, userProfile, errorCode, errorDescription in
+            guard errorCode == 0, account == self.appDelegate.account else {
+                NCBrandColor.shared.settingThemingColor(account: account)
+                if errorCode == 401 || errorCode == 403 {
+                    NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
                 }
+                return
+            }
 
-                self.appDelegate.settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId, password: CCUtility.getPassword(tableAccount.account))
-
-                // Synchronize favorite
-                NCNetworking.shared.listingFavoritescompletion(selector: NCGlobal.shared.selectorReadFile) { _, _, _, _ in }
+            // Update User (+ userProfile.id) & active account & account network
+            guard let tableAccount = NCManageDatabase.shared.setAccountUserProfile(userProfile!) else {
+                NCContentPresenter.shared.messageNotification("Account", description: "Internal error : account not found on DB", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
+                return
+            }
 
-                // Synchronize Offline
-                self.synchronizeOffline(account: tableAccount.account)
+            self.appDelegate.settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId, password: CCUtility.getPassword(tableAccount.account))
 
-                // Get Avatar
-                let fileName = tableAccount.userBaseUrl + "-" + self.appDelegate.user + ".png"
-                let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
-                let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
+            // Synchronize favorite
+            NCNetworking.shared.listingFavoritescompletion(selector: NCGlobal.shared.selectorReadFile) { _, _, _, _ in }
 
-                NCCommunication.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, queue: NCCommunicationCommon.shared.backgroundQueue) { _, _, _, etag, errorCode, _ in
+            // Synchronize Offline
+            self.synchronizeOffline(account: tableAccount.account)
 
-                    if let etag = etag, errorCode == 0 {
-                        NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
-                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: nil)
-                    } else if errorCode == NCGlobal.shared.errorNotModified {
+            // Get Avatar
+            let fileName = tableAccount.userBaseUrl + "-" + self.appDelegate.user + ".png"
+            let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
+            let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
+            NCCommunication.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, queue: NCCommunicationCommon.shared.backgroundQueue) { _, _, _, etag, errorCode, _ in
+                guard let etag = etag, errorCode == 0 else {
+                    if errorCode == NCGlobal.shared.errorNotModified {
                         NCManageDatabase.shared.setAvatarLoaded(fileName: fileName)
                     }
+                    return
                 }
-                self.requestServerCapabilities()
-
-            } else {
-
-                if errorCode == 401 || errorCode == 403 {
-                    NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
-                }
+                NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: nil)
             }
-        }
-    }
-
-    private func requestServerStatus() {
-
-        NCCommunication.shared.getServerStatus(serverUrl: appDelegate.urlBase, queue: NCCommunicationCommon.shared.backgroundQueue) { serverProductName, _, versionMajor, _, _, extendedSupport, errorCode, _ in
 
-            if errorCode == 0 && extendedSupport == false {
-
-                if serverProductName == "owncloud" {
-                    NCContentPresenter.shared.messageNotification("_warning_", description: "_warning_owncloud_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
-                } else if versionMajor <=  NCGlobal.shared.nextcloud_unsupported_version {
-                    NCContentPresenter.shared.messageNotification("_warning_", description: "_warning_unsupported_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, priority: .max)
-                }
-            }
+            self.requestServerCapabilities()
         }
     }
 
     private func requestServerCapabilities() {
-
-        if appDelegate.account == "" { return }
+        guard !appDelegate.account.isEmpty else { return }
 
         NCCommunication.shared.getCapabilities(queue: NCCommunicationCommon.shared.backgroundQueue) { account, data, errorCode, errorDescription in
+            guard errorCode == 0, let data = data else {
+                NCBrandColor.shared.settingThemingColor(account: account)
+                if errorCode == 401 || errorCode == 403 {
+                    NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
+                }
+                return
+            }
 
-            if errorCode == 0 && data != nil {
-
-                NCManageDatabase.shared.addCapabilitiesJSon(data!, account: account)
-
-                let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+            NCManageDatabase.shared.addCapabilitiesJSon(data, account: account)
+            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
 
-                // Setup communication
-                if serverVersionMajor > 0 {
-                    NCCommunicationCommon.shared.setup(nextcloudVersion: serverVersionMajor)
-                }
-                NCCommunicationCommon.shared.setup(webDav: NCUtilityFileSystem.shared.getWebDAV(account: account))
+            // Setup communication
+            if serverVersionMajor > 0 {
+                NCCommunicationCommon.shared.setup(nextcloudVersion: serverVersionMajor)
+            }
+            NCCommunicationCommon.shared.setup(webDav: NCUtilityFileSystem.shared.getWebDAV(account: account))
 
-                // Theming
+            // Theming
+            let themingColorNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColor)
+            let themingColorElementNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorElement)
+            let themingColorTextNew = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesThemingColorText)
+            if themingColorNew != NCBrandColor.shared.themingColor || themingColorElementNew != NCBrandColor.shared.themingColorElement || themingColorTextNew != NCBrandColor.shared.themingColorText {
                 NCBrandColor.shared.settingThemingColor(account: account)
+            }
 
-                // File Sharing
-                let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
-                if isFilesSharingEnabled {
-                    NCCommunication.shared.readShares(parameters: NCCShareParameter(), queue: NCCommunicationCommon.shared.backgroundQueue) { account, shares, errorCode, errorDescription in
-                        if errorCode == 0 {
-                            NCManageDatabase.shared.deleteTableShare(account: account)
-                            if shares != nil {
-                                NCManageDatabase.shared.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
-                            }
-                            self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: account)
-                        } else {
-                            NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+            // File Sharing
+            let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
+            if isFilesSharingEnabled {
+                NCCommunication.shared.readShares(parameters: NCCShareParameter(), queue: NCCommunicationCommon.shared.backgroundQueue) { account, shares, errorCode, errorDescription in
+                    if errorCode == 0 {
+                        NCManageDatabase.shared.deleteTableShare(account: account)
+                        if shares != nil {
+                            NCManageDatabase.shared.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
                         }
+                        self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: account)
+                    } else {
+                        NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
                     }
                 }
+            }
 
-                let comments = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesComments, exists: false)
-                let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
-
-                if !isFilesSharingEnabled && !comments && activity == nil {
-                    self.appDelegate.disableSharesView = true
-                } else {
-                    self.appDelegate.disableSharesView = false
-                }
+            let comments = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesComments, exists: false)
+            let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
 
-                // Text direct editor detail
-                if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
-                    NCCommunication.shared.NCTextObtainEditorDetails(queue: NCCommunicationCommon.shared.backgroundQueue) { account, editors, creators, errorCode, _ in
-                        if errorCode == 0 && account == self.appDelegate.account {
-                            NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
-                        }
-                    }
-                }
+            if !isFilesSharingEnabled && !comments && activity == nil {
+                self.appDelegate.disableSharesView = true
+            } else {
+                self.appDelegate.disableSharesView = false
+            }
 
-                // External file Server
-                let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true)
-                if isExternalSitesServerEnabled {
-                    NCCommunication.shared.getExternalSite(queue: NCCommunicationCommon.shared.backgroundQueue) { account, externalSites, errorCode, _ in
-                        if errorCode == 0 && account == self.appDelegate.account {
-                            NCManageDatabase.shared.deleteExternalSites(account: account)
-                            for externalSite in externalSites {
-                                NCManageDatabase.shared.addExternalSites(externalSite, account: account)
-                            }
-                        }
+            // Text direct editor detail
+            if serverVersionMajor >= NCGlobal.shared.nextcloudVersion18 {
+                NCCommunication.shared.NCTextObtainEditorDetails(queue: NCCommunicationCommon.shared.backgroundQueue) { account, editors, creators, errorCode, _ in
+                    if errorCode == 0 && account == self.appDelegate.account {
+                        NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
                     }
-
-                } else {
-                    NCManageDatabase.shared.deleteExternalSites(account: account)
                 }
+            }
 
-                // User Status
-                let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
-                if userStatus {
-                    NCCommunication.shared.getUserStatus(queue: NCCommunicationCommon.shared.backgroundQueue) { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, errorCode, _ in
-                        if errorCode == 0 && account == self.appDelegate.account && userId == self.appDelegate.userId {
-                            NCManageDatabase.shared.setAccountUserStatus(userStatusClearAt: clearAt, userStatusIcon: icon, userStatusMessage: message, userStatusMessageId: messageId, userStatusMessageIsPredefined: messageIsPredefined, userStatusStatus: status, userStatusStatusIsUserDefined: statusIsUserDefined, account: account)
+            // External file Server
+            let isExternalSitesServerEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true)
+            if isExternalSitesServerEnabled {
+                NCCommunication.shared.getExternalSite(queue: NCCommunicationCommon.shared.backgroundQueue) { account, externalSites, errorCode, _ in
+                    if errorCode == 0 && account == self.appDelegate.account {
+                        NCManageDatabase.shared.deleteExternalSites(account: account)
+                        for externalSite in externalSites {
+                            NCManageDatabase.shared.addExternalSites(externalSite, account: account)
                         }
                     }
                 }
+            } else {
+                NCManageDatabase.shared.deleteExternalSites(account: account)
+            }
 
-                // Added UTI for Collabora
-                if let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) {
-                    for mimeType in richdocumentsMimetypes {
-                        NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: mimeType, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: NCGlobal.shared.editorCollabora, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
+            // User Status
+            let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
+            if userStatus {
+                NCCommunication.shared.getUserStatus(queue: NCCommunicationCommon.shared.backgroundQueue) { account, clearAt, icon, message, messageId, messageIsPredefined, status, statusIsUserDefined, userId, errorCode, _ in
+                    if errorCode == 0 && account == self.appDelegate.account && userId == self.appDelegate.userId {
+                        NCManageDatabase.shared.setAccountUserStatus(userStatusClearAt: clearAt, userStatusIcon: icon, userStatusMessage: message, userStatusMessageId: messageId, userStatusMessageIsPredefined: messageIsPredefined, userStatusStatus: status, userStatusStatusIsUserDefined: statusIsUserDefined, account: account)
                     }
                 }
+            }
 
-                // Added UTI for ONLYOFFICE & Text
-                if let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account) {
-                    for directEditing in directEditingCreators {
-                        NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: directEditing.mimetype, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: directEditing.editor, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
-                    }
+            // Added UTI for Collabora
+            if let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes) {
+                for mimeType in richdocumentsMimetypes {
+                    NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: mimeType, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: NCGlobal.shared.editorCollabora, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
                 }
+            }
 
-                //                    Handwerkcloud
-                //                    let isHandwerkcloudEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesHWCEnabled, exists: false)
-                //                    if (isHandwerkcloudEnabled) {
-                //                        self.requestHC()
-                //                    }
-
-            } else if errorCode != 0 {
-
-                NCBrandColor.shared.settingThemingColor(account: account)
-
-                if errorCode == 401 || errorCode == 403 {
-                    NCNetworkingCheckRemoteUser.shared.checkRemoteUser(account: account, errorCode: errorCode, errorDescription: errorDescription)
+            // Added UTI for ONLYOFFICE & Text
+            if let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account) {
+                for directEditing in directEditingCreators {
+                    NCCommunicationCommon.shared.addInternalTypeIdentifier(typeIdentifier: directEditing.mimetype, classFile: NCCommunicationCommon.typeClassFile.document.rawValue, editor: directEditing.editor, iconName: NCCommunicationCommon.typeIconFile.document.rawValue, name: "document")
                 }
-
-            } else {
-                NCBrandColor.shared.settingThemingColor(account: account)
             }
         }
     }
@@ -280,8 +267,4 @@ class NCService: NSObject {
     }
 
     // MARK: - Thirt Part
-
-    private func requestHC() {
-
-    }
 }

+ 1 - 6
iOSClient/Offline/NCOffline.swift

@@ -44,7 +44,7 @@ class NCOffline: NCCollectionViewCommon {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         var ocIds: [String] = []
@@ -89,11 +89,6 @@ class NCOffline: NCCollectionViewCommon {
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
 
-        guard !isSearching else {
-            networkSearch()
-            return
-        }
-
         guard !serverUrl.isEmpty else {
             self.reloadDataSource()
             return

+ 1 - 6
iOSClient/Recent/NCRecent.swift

@@ -44,7 +44,7 @@ class NCRecent: NCCollectionViewCommon {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         DispatchQueue.global().async {
@@ -68,11 +68,6 @@ class NCRecent: NCCollectionViewCommon {
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
 
-        if isSearching {
-            networkSearch()
-            return
-        }
-
         let requestBodyRecent =
         """
         <?xml version=\"1.0\"?>

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -172,7 +172,7 @@
             
             NSInteger logLevel = [CCUtility getLogLevel];
             BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
-            NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
+            NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
             if (isSimulatorOrTestFlight) {
                 [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
             } else {

+ 3 - 3
iOSClient/Settings/NCSettings.m

@@ -414,14 +414,14 @@
         }
         break;
         case 4: {
-                                
+
             NSString *versionServer = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
             NSString *themingName = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
             NSString *themingSlogan = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
 
             NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer];
-            NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
-            
+            NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
+
             NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
             
             sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];

+ 1 - 6
iOSClient/Shares/NCShares.swift

@@ -44,7 +44,7 @@ class NCShares: NCCollectionViewCommon {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         DispatchQueue.global().async {
@@ -79,11 +79,6 @@ class NCShares: NCCollectionViewCommon {
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
 
-        if isSearching {
-            networkSearch()
-            return
-        }
-
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
 

+ 2 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -873,7 +873,8 @@
 "_enter_passphrase_"        = "Enter passphrase (12 words)";
 "_show_more_results_"       = "Show more results";
 "_waiting_for_"             = "Waiting for:";
-"_reachable_wifi_"          = "network reachable via WiFi or cable";
+"_reachable_wifi_"          = "network reachable via Wi-Fi or cable";
+"_ITMS-90076_"              = "Due to a change in the Nextcloud application identifier, the settings and password for accessing your cloud are reset, so please re-enter your account data and check your Settings, we are sorry about what happened but it is not up to us.";
 
 // Video
 "_select_trace_"            = "Select the trace";

+ 4 - 4
iOSClient/Transfers/NCTransfers.swift

@@ -167,7 +167,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         cell.fileUser = metadata.ownerId
         cell.indexPath = indexPath
 
-        cell.imageItem.image = nil
+        cell.imageItem.image = NCBrandColor.cacheImages.file
         cell.imageItem.backgroundColor = nil
 
         cell.labelTitle.text = metadata.fileNameView
@@ -187,7 +187,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
 
         if FileManager().fileExists(atPath: iconImagePath) {
             cell.imageItem.image =  UIImage(contentsOfFile:iconImagePath)
-        } else if FileManager().fileExists(atPath: imagePath) {
+        } else if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue, FileManager().fileExists(atPath: imagePath) {
             if let image = UIImage(contentsOfFile: imagePath), let image = image.resizeImage(size: CGSize(width: NCGlobal.shared.sizeIcon, height: NCGlobal.shared.sizeIcon), isAspectRation: true), let data = image.jpegData(compressionQuality: 0.5) {
                 do {
                     try data.write(to: URL.init(fileURLWithPath: iconImagePath), options: .atomic)
@@ -195,7 +195,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
                 } catch { }
             }
         } else {
-            cell.imageItem.image = NCBrandColor.cacheImages.file
+            cell.imageItem.image = UIImage(named: metadata.iconName)
         }
 
         cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
@@ -271,7 +271,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
 
     // MARK: - DataSource + NC Endpoint
 
-    override func reloadDataSource() {
+    override func reloadDataSource(forced: Bool = true) {
         super.reloadDataSource()
 
         metadatasSource = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "status != %i", NCGlobal.shared.metadataStatusNormal), page: 1, limit: 100, sorted: "sessionTaskIdentifier", ascending: false)

+ 4 - 2
iOSClient/Trash/NCTrash.swift

@@ -166,7 +166,9 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
         sortMenu.toggleMenu(viewController: self, key: NCGlobal.shared.layoutViewTrash, sortButton: sender as? UIButton, serverUrl: "", hideDirectoryOnTop: true)
     }
 
-    func tapButtonMore(_ sender: Any) { }
+    func tapButtonMore(_ sender: Any) {
+        toggleMenuMoreHeader()
+    }
 
     func tapRestoreListItem(with ocId: String, image: UIImage?, sender: Any) {
 
@@ -241,7 +243,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
 
     // MARK: - DataSource
 
-    @objc func reloadDataSource() {
+    @objc func reloadDataSource(forced: Bool = true) {
 
         layoutForView = NCUtility.shared.getLayoutForView(key: NCGlobal.shared.layoutViewTrash, serverUrl: "")
 

+ 6 - 2
iOSClient/Utility/NCUtility.swift

@@ -477,10 +477,14 @@ class NCUtility: NSObject {
         }
     }
 
-    @objc func getVersionApp() -> String {
+    @objc func getVersionApp(withBuild: Bool = true) -> String {
         if let dictionary = Bundle.main.infoDictionary {
             if let version = dictionary["CFBundleShortVersionString"], let build = dictionary["CFBundleVersion"] {
-                return "\(version).\(build)"
+                if withBuild {
+                    return "\(version).\(build)"
+                } else {
+                    return "\(version)"
+                }
             }
         }
         return ""