瀏覽代碼

Merge pull request #2173 from nextcloud/generalImprovements

General improvements
Marino Faggiana 2 年之前
父節點
當前提交
5ddced9f54

+ 19 - 19
Nextcloud.xcodeproj/project.pbxproj

@@ -181,6 +181,7 @@
 		F7346E2528B0FEFA006CE2D2 /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2428B0FEFA006CE2D2 /* UICKeyChainStore */; };
 		F7346E2728B0FFF2006CE2D2 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2628B0FFF2006CE2D2 /* Realm */; };
 		F7346E2928B0FFF2006CE2D2 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F7346E2828B0FFF2006CE2D2 /* RealmSwift */; };
+		F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */ = {isa = PBXBuildFile; productRef = F734B06528E75C0100E180D5 /* TLPhotoPicker */; };
 		F7362A1F220C853A005101B5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7362A1E220C853A005101B5 /* LaunchScreen.storyboard */; };
 		F7381EE1218218C9000B1560 /* NCOffline.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7381EDA218218C9000B1560 /* NCOffline.swift */; };
 		F7381EE5218218C9000B1560 /* NCOffline.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7381EDE218218C9000B1560 /* NCOffline.storyboard */; };
@@ -277,7 +278,6 @@
 		F76DA963277B760E0082465B /* Queuer in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA962277B760E0082465B /* Queuer */; };
 		F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA965277B76F30082465B /* UICKeyChainStore */; };
 		F76DA969277B77EA0082465B /* DropDown in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA968277B77EA0082465B /* DropDown */; };
-		F76DA96F277B78AE0082465B /* TLPhotoPicker in Frameworks */ = {isa = PBXBuildFile; productRef = F76DA96E277B78AE0082465B /* TLPhotoPicker */; };
 		F7707687263A853700A1BA94 /* NCContentPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F765608E23BF813500765969 /* NCContentPresenter.swift */; };
 		F7707689263A896A00A1BA94 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extensions.swift */; };
 		F770768A263A8A2500A1BA94 /* NCUtilityFileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F74AF3A3247FB6AE00AC767B /* NCUtilityFileSystem.swift */; };
@@ -1162,11 +1162,11 @@
 				F7ED547C25EEA65400956C55 /* QRCodeReader in Frameworks */,
 				F788ECC7263AAAFA00ADC67F /* MarkdownKit in Frameworks */,
 				F7BB7E4727A18C56009B9F29 /* Parchment in Frameworks */,
+				F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */,
 				F770768E263A8C3400A1BA94 /* FloatingPanel in Frameworks */,
 				F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */,
 				F7E572FD278F146C00F8C99E /* OpenSSL.xcframework in Frameworks */,
 				F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */,
-				F76DA96F277B78AE0082465B /* TLPhotoPicker in Frameworks */,
 				F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */,
 				F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */,
 				F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */,
@@ -2303,13 +2303,13 @@
 				F76DA962277B760E0082465B /* Queuer */,
 				F76DA965277B76F30082465B /* UICKeyChainStore */,
 				F76DA968277B77EA0082465B /* DropDown */,
-				F76DA96E277B78AE0082465B /* TLPhotoPicker */,
 				F710FC79277B7D0000AA9FBF /* Realm */,
 				F710FC7B277B7D0000AA9FBF /* RealmSwift */,
 				F7BB7E4627A18C56009B9F29 /* Parchment */,
 				F758A01127A7F03E0069468B /* JGProgressHUD */,
 				F753BA92281FD8020015BFB6 /* EasyTipView */,
 				F72AD70C28C24B93006CB92D /* NextcloudKit */,
+				F734B06528E75C0100E180D5 /* TLPhotoPicker */,
 			);
 			productName = "Crypto Cloud";
 			productReference = F7CE8AFA1DC1F8D8009CAE48 /* Nextcloud.app */;
@@ -2431,12 +2431,12 @@
 				F76DA961277B760E0082465B /* XCRemoteSwiftPackageReference "Queuer" */,
 				F76DA964277B76F10082465B /* XCRemoteSwiftPackageReference "UICKeyChainStore" */,
 				F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */,
-				F76DA96D277B78AE0082465B /* XCRemoteSwiftPackageReference "TLPhotoPicker" */,
 				F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */,
 				F7BB7E4527A18C56009B9F29 /* XCRemoteSwiftPackageReference "Parchment" */,
 				F72CD01027A7E92400E59476 /* XCRemoteSwiftPackageReference "JGProgressHUD" */,
 				F753BA91281FD8010015BFB6 /* XCRemoteSwiftPackageReference "EasyTipView" */,
 				F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */,
+				F734B06428E75C0100E180D5 /* XCRemoteSwiftPackageReference "TLPhotoPicker" */,
 			);
 			productRefGroup = F7F67B9F1A24D27800EE80DA;
 			projectDirPath = "";
@@ -3403,7 +3403,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3465,7 +3465,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3600,6 +3600,14 @@
 				minimumVersion = 3.7.2;
 			};
 		};
+		F734B06428E75C0100E180D5 /* XCRemoteSwiftPackageReference "TLPhotoPicker" */ = {
+			isa = XCRemoteSwiftPackageReference;
+			repositoryURL = "https://github.com/marinofaggiana/TLPhotoPicker";
+			requirement = {
+				branch = master;
+				kind = branch;
+			};
+		};
 		F73ADD1A265546880069EA0D /* XCRemoteSwiftPackageReference "SwiftEntryKit" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/huri000/SwiftEntryKit";
@@ -3664,14 +3672,6 @@
 				kind = branch;
 			};
 		};
-		F76DA96D277B78AE0082465B /* XCRemoteSwiftPackageReference "TLPhotoPicker" */ = {
-			isa = XCRemoteSwiftPackageReference;
-			repositoryURL = "https://github.com/tilltue/TLPhotoPicker";
-			requirement = {
-				kind = upToNextMajorVersion;
-				minimumVersion = 2.0.0;
-			};
-		};
 		F770768C263A8C3400A1BA94 /* XCRemoteSwiftPackageReference "FloatingPanel" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/scenee/FloatingPanel";
@@ -3810,6 +3810,11 @@
 			package = F710FC78277B7CFF00AA9FBF /* XCRemoteSwiftPackageReference "realm-swift" */;
 			productName = RealmSwift;
 		};
+		F734B06528E75C0100E180D5 /* TLPhotoPicker */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = F734B06428E75C0100E180D5 /* XCRemoteSwiftPackageReference "TLPhotoPicker" */;
+			productName = TLPhotoPicker;
+		};
 		F73ADD1B265546890069EA0D /* SwiftEntryKit */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F73ADD1A265546880069EA0D /* XCRemoteSwiftPackageReference "SwiftEntryKit" */;
@@ -3880,11 +3885,6 @@
 			package = F76DA967277B77E90082465B /* XCRemoteSwiftPackageReference "DropDown" */;
 			productName = DropDown;
 		};
-		F76DA96E277B78AE0082465B /* TLPhotoPicker */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = F76DA96D277B78AE0082465B /* XCRemoteSwiftPackageReference "TLPhotoPicker" */;
-			productName = TLPhotoPicker;
-		};
 		F770768D263A8C3400A1BA94 /* FloatingPanel */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F770768C263A8C3400A1BA94 /* XCRemoteSwiftPackageReference "FloatingPanel" */;

+ 30 - 44
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -24,6 +24,7 @@
 import Foundation
 import NextcloudKit
 import FloatingPanel
+import JGProgressHUD
 
 class NCActivityCollectionViewCell: UICollectionViewCell {
 
@@ -140,54 +141,39 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
                 }
             }
 
-            var pathComponents = activityPreview.link.components(separatedBy: "?")
-            pathComponents = pathComponents[1].components(separatedBy: "&")
-            var serverUrlFileName = pathComponents[0].replacingOccurrences(of: "dir=", with: "").removingPercentEncoding!
-            serverUrlFileName = NCUtilityFileSystem.shared.getHomeServer(account: activityPreview.account) + serverUrlFileName + "/" + activitySubjectRich.name
-            let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(activitySubjectRich.id, fileNameView: activitySubjectRich.name)!
-
-            if let backgroundView = appDelegate.window?.rootViewController?.view {
-                NCActivityIndicator.shared.start(backgroundView: backgroundView)
+            let hud = JGProgressHUD()
+            hud.indicatorView = JGProgressHUDRingIndicatorView()
+            if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
+                indicatorView.ringWidth = 1.5
             }
-
-            NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
-
-            }, taskHandler: { _ in
-
-            }, progressHandler: { _ in
-
-            }) { account, _, _, _, _, _, error in
-
-                if account == self.appDelegate.account && error == .success {
-
-                    let serverUrl = (serverUrlFileName as NSString).deletingLastPathComponent
-                    let fileName = (serverUrlFileName as NSString).lastPathComponent
-                    let serverUrlFileName = serverUrl + "/" + fileName
-
-                    NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName) { account, metadata, error in
-
-                        NCActivityIndicator.shared.stop()
-
-                        DispatchQueue.main.async {
-                            if account == self.appDelegate.account, error == .success, let metadata = metadata {
-
-                                // move from id to oc:id + instanceid (ocId)
-                                let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
-                                let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata.ocId
-
-                                CCUtility.moveFile(atPath: atPath, toPath: toPath)
-
-                                NCManageDatabase.shared.addMetadata(metadata)
-                                if let viewController = self.viewController {
-                                    NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
-                                }
+            guard let view = appDelegate.window?.rootViewController?.view else { return }
+            hud.show(in: view)
+
+            NextcloudKit.shared.getFileFromFileId(fileId: String(activityPreview.fileId)) { account, file, data, error in
+                if let file = file {
+
+                    let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: file.e2eEncrypted, account: account)
+                    NCManageDatabase.shared.addMetadata(metadata)
+
+                    let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
+                    let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+
+                    NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
+                    }, taskHandler: { _ in
+                    }, progressHandler: { progress in
+                        hud.progress = Float(progress.fractionCompleted)
+                    }) { account, _, _, _, _, _, error in
+                        hud.dismiss()
+                        if account == self.appDelegate.account && error == .success {
+                            NCManageDatabase.shared.addLocalFile(metadata: metadata)
+                            if let viewController = self.viewController {
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
                             }
                         }
                     }
-
-                } else {
-
-                    NCActivityIndicator.shared.stop()
+                } else if error != .success {
+                    hud.dismiss()
+                    NCContentPresenter.shared.showError(error: error)
                 }
             }
         }

+ 15 - 37
iOSClient/AppDelegate.swift

@@ -63,8 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var errorITMS90076: Bool = false
 
     private var privacyProtectionWindow: UIWindow?
-    private var autoUploadInprogress: Bool = false
-    
+
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 
         let userAgent = CCUtility.getUserAgent() as String
@@ -153,7 +152,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize, userInfo:["atStart":1])
 
         // Process upload
-        networkingProcessUpload = NCNetworkingProcessUpload()
+        if UIApplication.shared.applicationState != .background {
+            networkingProcessUpload = NCNetworkingProcessUpload()
+        }
 
         // Push Notification & display notification
         application.registerForRemoteNotifications()
@@ -243,13 +244,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         // Initialize Auto upload
-        if !autoUploadInprogress {
-            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
-                self.autoUploadInprogress = false
-            }
-        } else {
-            NKCommon.shared.writeLog("Auto upload already in progress.")
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
         }
 
         // Required unsubscribing / subscribing
@@ -333,14 +329,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCPushNotification.shared().pushNotification()
 
         // Start Auto Upload
-        if !autoUploadInprogress {
-            autoUploadInprogress = true
-            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
-                self.autoUploadInprogress = false
-            }
-        } else {
-            NKCommon.shared.writeLog("Auto upload already in progress.")
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
         }
 
         // Start services
@@ -403,16 +393,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         NKCommon.shared.writeLog("Start handler refresh task [Auto upload]")
-
-        if !autoUploadInprogress {
-            autoUploadInprogress = true
-            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-                NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
-                self.autoUploadInprogress = false
-                task.setTaskCompleted(success: true)
-            }
-        } else {
-            NKCommon.shared.writeLog("Auto upload already in progress.")
+        
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
+            task.setTaskCompleted(success: true)
         }
     }
 
@@ -426,15 +410,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
         NKCommon.shared.writeLog("Start handler processing task [Auto upload]")
 
-        if !autoUploadInprogress {
-            autoUploadInprogress = true
-            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-                NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
-                self.autoUploadInprogress = false
-                task.setTaskCompleted(success: true)
-            }
-        } else {
-            NKCommon.shared.writeLog("Auto upload already in progress.")
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
+            task.setTaskCompleted(success: true)
         }
     }
 

+ 22 - 6
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -212,17 +212,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if !appDelegate.isSearchingMode {
             reloadDataSourceNetwork()
         }
+
+        //FIXME: iPAD PDF landscape mode iOS 16
+        DispatchQueue.main.async {
+            self.collectionView?.collectionViewLayout.invalidateLayout()
+        }
     }
 
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
 
-        // TIP
-        if self is NCFiles, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
-            if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
-                self.tipView?.show(forView: view)
-            }
-        }
+        showTip()
     }
 
     override func viewWillDisappear(_ animated: Bool) {
@@ -267,6 +267,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         self.collectionView?.collectionViewLayout.invalidateLayout()
         self.collectionView?.reloadData()
+        self.tipView?.dismiss()
+        
+        coordinator.animate(alongsideTransition: nil) { _ in
+            self.showTip()
+        }
     }
 
     override var canBecomeFirstResponder: Bool {
@@ -629,6 +634,17 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
 
+    // MARK: - Tip
+
+    func showTip() {
+
+        if self is NCFiles, self.view.window != nil, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
+            if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
+                self.tipView?.show(forView: view)
+            }
+        }
+    }
+
     // MARK: - Layout
 
     @objc func setNavigationItem() {

+ 1 - 3
iOSClient/Media/NCMedia.swift

@@ -146,9 +146,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
 
-        coordinator.animate(alongsideTransition: nil) { _ in
-            self.reloadDataThenPerform { }
-        }
+        self.collectionView?.collectionViewLayout.invalidateLayout()
     }
 
     override var preferredStatusBarStyle: UIStatusBarStyle {

+ 4 - 0
iOSClient/NCGlobal.swift

@@ -322,6 +322,10 @@ class NCGlobal: NSObject {
     let metadataStatusUploading: Int                = 3
     let metadataStatusUploadError: Int              = 4
 
+    // Upload Operation Background
+    //
+    let maxConcurrentOperationUpload                = 10
+
     // Notification Center
     //
     @objc let notificationCenterApplicationDidEnterBackground   = "applicationDidEnterBackground"

+ 1 - 4
iOSClient/Networking/NCAutoUpload.swift

@@ -191,7 +191,6 @@ class NCAutoUpload: NSObject {
 
         var metadatasForUpload: [tableMetadata] = []
         var numStartUpload: Int = 0
-        let maxConcurrentOperationUpload = 5
 
         for metadata in metadatas {
             if NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ && serverUrl == %@ && fileName == %@ && session != ''", metadata.account, metadata.serverUrl, metadata.fileName)) != nil {
@@ -201,10 +200,8 @@ class NCAutoUpload: NSObject {
         }
         NCManageDatabase.shared.addMetadatas(metadatasForUpload)
 
-        // Max file in Uploadading
-
         let metadatasInUpload = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d OR status == %d", NCGlobal.shared.metadataStatusInUpload, NCGlobal.shared.metadataStatusUploading))
-        let counterUpload = maxConcurrentOperationUpload - metadatasInUpload.count
+        let counterUpload = NCGlobal.shared.maxConcurrentOperationUpload - metadatasInUpload.count
         if counterUpload <= 0 {
             return completion(0)
         }

+ 12 - 3
iOSClient/Networking/NCNetworking.swift

@@ -423,9 +423,18 @@ import Photos
                 }
             }
         } else {
-            uploadFileInBackground(metadata: metadata, start: start) { error in
-                DispatchQueue.main.async {
-                    completion(error)
+            isInTaskUploadBackground(fileName: metadata.fileName) { exists in
+                if exists {
+                    NKCommon.shared.writeLog("[INFO] Upload already in progress.")
+                    DispatchQueue.main.async {
+                        completion(NKError(errorCode: 0, errorDescription: ""))
+                    }
+                } else {
+                    self.uploadFileInBackground(metadata: metadata, start: start) { error in
+                        DispatchQueue.main.async {
+                            completion(error)
+                        }
+                    }
                 }
             }
         }

+ 4 - 6
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -30,8 +30,6 @@ class NCNetworkingProcessUpload: NSObject {
 
     var timerProcess: Timer?
 
-    let maxConcurrentOperationUpload = 5
-
     override init() {
         super.init()
         startTimer()
@@ -73,9 +71,9 @@ class NCNetworkingProcessUpload: NSObject {
         NCNetworking.shared.getOcIdInBackgroundSession(queue: DispatchQueue.global(), completion: { listOcId in
 
             for sessionSelector in sessionSelectors {
-                if counterUpload < self.maxConcurrentOperationUpload {
+                if counterUpload < NCGlobal.shared.maxConcurrentOperationUpload {
 
-                    let limit = self.maxConcurrentOperationUpload - counterUpload
+                    let limit = NCGlobal.shared.maxConcurrentOperationUpload - counterUpload
                     let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "sessionSelector == %@ AND status == %d", sessionSelector, NCGlobal.shared.metadataStatusWaitUpload), page: 1, limit: limit, sorted: "date", ascending: true)
                     if metadatas.count > 0 {
                         NKCommon.shared.writeLog("PROCESS-UPLOAD find \(metadatas.count) items")
@@ -103,7 +101,7 @@ class NCNetworkingProcessUpload: NSObject {
                         // Is already in upload E2EE / CHUNK ? exit [ ONLY ONE IN QUEUE ]
                         for metadata in metadatasUpload {
                             if metadata.chunk || metadata.e2eEncrypted {
-                                counterUpload = self.maxConcurrentOperationUpload
+                                counterUpload = NCGlobal.shared.maxConcurrentOperationUpload
                                 continue
                             }
                         }
@@ -125,7 +123,7 @@ class NCNetworkingProcessUpload: NSObject {
                                     NCNetworking.shared.upload(metadata: metadata)
                                 }
                                 if metadata.e2eEncrypted || metadata.chunk {
-                                    counterUpload = self.maxConcurrentOperationUpload
+                                    counterUpload = NCGlobal.shared.maxConcurrentOperationUpload
                                 } else {
                                     counterUpload += 1
                                 }

+ 18 - 1
iOSClient/ScanDocument/NCScan.swift

@@ -117,12 +117,29 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
 
-        // TIP
+        showTip()
+    }
+
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.viewWillTransition(to: size, with: coordinator)
+
+        self.tipView?.dismiss()
+        coordinator.animate(alongsideTransition: nil) { _ in
+            self.showTip()
+        }
+    }
+
+    // MARK: - Tip
+
+    func showTip() {
+
         if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCScanAddImage) {
             self.tipView?.show(forView: add, withinSuperview: self.view)
         }
     }
 
+    // MARK: -
+
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
 

+ 35 - 33
iOSClient/Settings/NCSettings.m

@@ -101,21 +101,27 @@
     [section addFormRow:row];
     
     // Section : E2EEncryption --------------------------------------------------------------
-        
-    section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
-    [form addFormSection:section];
-    
-    // EndToEnd Encryption
-    NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)];
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
-    row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-    [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
-    row.action.viewControllerClass = [NCManageEndToEndEncryption class];
-    
-    [section addFormRow:row];
-    
+
+    BOOL isE2EEEnabled = [[NCManageDatabase shared] getCapabilitiesServerBoolWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEEnabled exists:false];
+    NSString *versionE2EE = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEApiVersion];
+
+    if (isE2EEEnabled == YES && [versionE2EE isEqual:[[NCGlobal shared] e2eeVersion]]) {
+
+        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
+        [form addFormSection:section];
+
+        // EndToEnd Encryption
+        NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)];
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
+        row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
+        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
+        [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
+        [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
+        row.action.viewControllerClass = [NCManageEndToEndEncryption class];
+
+        [section addFormRow:row];
+    }
+
     // Section Advanced -------------------------------------------------
     
     section = [XLFormSectionDescriptor formSection];
@@ -217,6 +223,8 @@
     if (passcodeSettingsViewController.view.window != nil) {
         [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
     }
+
+    [[self navigationController] popToRootViewControllerAnimated:false];
 }
 
 #pragma mark -
@@ -406,27 +414,21 @@
 - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
 {
     NSString *sectionName;
-    
-    switch (section)
-    {
-        case 1: {
-            sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
-        }
-        break;
-        case 4: {
+    NSInteger numSections = [tableView numberOfSections] - 1;
 
-            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];
+    if (section == 1) {
+        sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
+    } else if (section == numSections) {
+        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] getVersionAppWithBuild:true]];
+        NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer];
+        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];
-        }
-        break;
+        NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
+
+        sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
     }
     return sectionName;
 }

+ 1 - 1
iOSClient/Utility/NCActivityIndicator.swift

@@ -38,7 +38,7 @@ class NCActivityIndicator: NSObject {
         start(backgroundView: backgroundView, style: style)
     }
 
-    func start(backgroundView: UIView? = nil, bottom: CGFloat? = nil, top: CGFloat? = nil, style: UIActivityIndicatorView.Style = .whiteLarge) {
+    func start(backgroundView: UIView? = nil, bottom: CGFloat? = nil, top: CGFloat? = nil, style: UIActivityIndicatorView.Style = .large) {
 
         if self.activityIndicator != nil { stop() }
 

+ 13 - 6
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -192,10 +192,7 @@ class NCViewerMedia: UIViewController {
             viewerMediaPage?.clearCommandCenter()
         }
 
-        // TIP
-        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerMediaDetailView), let view = self.navigationController?.navigationBar {
-            self.tipView?.show(forView: view)
-        }
+        showTip()
 
         NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
     }
@@ -210,7 +207,6 @@ class NCViewerMedia: UIViewController {
         super.viewWillTransition(to: size, with: coordinator)
 
         self.tipView?.dismiss()
-
         coordinator.animate(alongsideTransition: { context in
             // back to the original size
             self.scrollView.zoom(to: CGRect(x: 0, y: 0, width: self.scrollView.bounds.width, height: self.scrollView.bounds.height), animated: false)
@@ -220,7 +216,18 @@ class NCViewerMedia: UIViewController {
                     self.openDetail()
                 }
             }
-        }) { _ in }
+        }, completion: { context in
+            self.showTip()
+        })
+    }
+
+    // MARK: - Tip
+
+    func showTip() {
+
+        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerMediaDetailView), let view = self.navigationController?.navigationBar {
+            self.tipView?.show(forView: view)
+        }
     }
 
     // MARK: - Image

+ 48 - 57
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -45,6 +45,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     private let thumbnailViewWidth: CGFloat = 80
     private let thumbnailPadding: CGFloat = 2
     private let animateDuration: TimeInterval = 0.3
+    private let pageViewtopAnchor: CGFloat = UIDevice.current.userInterfaceIdiom == .phone ? 10 : 30
 
     private var defaultBackgroundColor: UIColor = .clear
 
@@ -72,11 +73,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         // PDF VIEW
 
-        if UIDevice.current.userInterfaceIdiom == .phone {
-            pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
-        } else {
-            pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width-thumbnailViewWidth, height: view.frame.height))
-        }
+        pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
         pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleLeftMargin]
         pdfView.document = pdfDocument
         pdfView.autoScales = true
@@ -107,11 +104,8 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         pdfThumbnailView.layoutMode = .vertical
         pdfThumbnailView.thumbnailSize = CGSize(width: thumbnailViewHeight, height: thumbnailViewHeight)
         pdfThumbnailView.backgroundColor = .clear
-        if UIDevice.current.userInterfaceIdiom == .phone {
-            self.pdfThumbnailScrollView.isHidden = true
-        } else {
-            self.pdfThumbnailScrollView.isHidden = false
-        }
+
+        pdfThumbnailScrollView.isHidden = true
         pdfThumbnailScrollView.addSubview(pdfThumbnailView)
 
         NSLayoutConstraint.activate([
@@ -140,7 +134,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         view.addSubview(pageView)
 
         NSLayoutConstraint.activate([
-            pageView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10),
+            pageView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: pageViewtopAnchor),
             pageView.heightAnchor.constraint(equalToConstant: 30),
             pageView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 10)
         ])
@@ -198,25 +192,22 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         NotificationCenter.default.addObserver(self, selector: #selector(handlePageChange), name: Notification.Name.PDFViewPageChanged, object: nil)
 
         // Tip
-        if UIDevice.current.userInterfaceIdiom == .phone && !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerPDFThumbnail){
-
-            var preferences = EasyTipView.Preferences()
-            preferences.drawing.foregroundColor = .white
-            preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
-            preferences.drawing.textAlignment = .left
-            preferences.drawing.arrowPosition = .right
-            preferences.drawing.cornerRadius = 10
+        var preferences = EasyTipView.Preferences()
+        preferences.drawing.foregroundColor = .white
+        preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
+        preferences.drawing.textAlignment = .left
+        preferences.drawing.arrowPosition = .right
+        preferences.drawing.cornerRadius = 10
 
-            preferences.positioning.bubbleInsets.right = UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0
+        preferences.positioning.bubbleInsets.right = UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0
 
-            preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
-            preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
-            preferences.animating.showInitialAlpha = 0
-            preferences.animating.showDuration = 1.5
-            preferences.animating.dismissDuration = 1.5
+        preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
+        preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
+        preferences.animating.showInitialAlpha = 0
+        preferences.animating.showDuration = 1.5
+        preferences.animating.dismissDuration = 1.5
 
-            tipView = EasyTipView(text: NSLocalizedString("_tip_pdf_thumbnails_", comment: ""), preferences: preferences, delegate: self)
-        }
+        tipView = EasyTipView(text: NSLocalizedString("_tip_pdf_thumbnails_", comment: ""), preferences: preferences, delegate: self)
 
         setConstraints()
         handlePageChange()
@@ -225,7 +216,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
 
-        self.tipView?.show(forView: self.pdfThumbnailScrollView, withinSuperview: self.view)
+        showTip()
     }
 
     @objc func viewUnload() {
@@ -236,15 +227,13 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
 
+        tipView?.dismiss()
         coordinator.animate(alongsideTransition: { context in
-            if UIDevice.current.userInterfaceIdiom == .phone {
-                // Close
-                self.tipView?.dismiss()
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
-                self.pdfThumbnailScrollView.isHidden = true
-            }
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+            self.pdfThumbnailScrollView.isHidden = true
         }, completion: { context in
             self.setConstraints()
+            self.showTip()
         })
     }
 
@@ -263,6 +252,15 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         NotificationCenter.default.removeObserver(self, name: Notification.Name.PDFViewPageChanged, object: nil)
     }
 
+    // MARK: - Tip
+
+    func showTip() {
+
+        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerPDFThumbnail) {
+            self.tipView?.show(forView: self.pdfThumbnailScrollView, withinSuperview: self.view)
+        }
+    }
+
     // MARK: - NotificationCenter
 
     @objc func uploadStartFile(_ notification: NSNotification) {
@@ -406,24 +404,22 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     @objc func gestureOpenPdfThumbnail(_ recognizer: UIScreenEdgePanGestureRecognizer) {
         guard let pdfDocument = pdfView.document, !pdfDocument.isLocked else { return }
 
-        if UIDevice.current.userInterfaceIdiom == .phone && self.pdfThumbnailScrollView.isHidden {
-            if let tipView = self.tipView {
-                tipView.dismiss()
-                NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerPDFThumbnail)
-                self.tipView = nil
-            }
-            self.pdfThumbnailScrollView.isHidden = false
-            self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
-            UIView.animate(withDuration: animateDuration, animations: {
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
-                self.view.layoutIfNeeded()
-            })
+        if let tipView = self.tipView {
+            tipView.dismiss()
+            NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerPDFThumbnail)
+            self.tipView = nil
         }
+        self.pdfThumbnailScrollView.isHidden = false
+        self.pdfThumbnailScrollViewWidthAnchor?.constant = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
+        UIView.animate(withDuration: animateDuration, animations: {
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
+            self.view.layoutIfNeeded()
+        })
     }
 
     @objc func gestureClosePdfThumbnail(_ recognizer: UIScreenEdgePanGestureRecognizer) {
 
-        if recognizer.state == .recognized && UIDevice.current.userInterfaceIdiom == .phone && !self.pdfThumbnailScrollView.isHidden {
+        if recognizer.state == .recognized && !self.pdfThumbnailScrollView.isHidden {
             UIView.animate(withDuration: animateDuration) {
                 self.pdfThumbnailScrollViewTrailingAnchor?.constant = self.thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
                 self.view.layoutIfNeeded()
@@ -440,16 +436,11 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         let widthThumbnail = thumbnailViewWidth + (UIApplication.shared.keyWindow?.safeAreaInsets.right ?? 0)
 
         UIView.animate(withDuration: animateDuration, animations: {
-            if UIDevice.current.userInterfaceIdiom == .phone {
-                // Close
-                self.pdfThumbnailScrollView.isHidden = true
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = widthThumbnail
-                self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
-            } else {
-                // Open
-                self.pdfThumbnailScrollViewTrailingAnchor?.constant = 0
-                self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
-            }
+            // Close
+            self.pdfThumbnailScrollView.isHidden = true
+            self.pdfThumbnailScrollViewTrailingAnchor?.constant = widthThumbnail
+            self.pdfThumbnailScrollViewWidthAnchor?.constant = widthThumbnail
+
             self.view.layoutIfNeeded()
             self.pdfView.autoScales = true
         })