소스 검색

Merge pull request #2110 from nextcloud/fix/441

Fix/441
Marino Faggiana 2 년 전
부모
커밋
df61eae0c1

+ 12 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -245,6 +245,10 @@
 		F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCF1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76C26A62850D3A500E42BDF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7F67BB81A24D27800EE80DA /* Images.xcassets */; };
+		F76D364628A4F8BF00214537 /* NCActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */; };
+		F76D364728A4F8BF00214537 /* NCActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */; };
+		F76D364828A4F8BF00214537 /* NCActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */; };
+		F76D364928A4F8BF00214537 /* NCActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */; };
 		F76D3CF12428B40E005DFA87 /* NCViewerPDFSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76D3CF02428B40E005DFA87 /* NCViewerPDFSearch.swift */; };
 		F76D3CF32428B94E005DFA87 /* NCViewerPDFSearchCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F76D3CF22428B94E005DFA87 /* NCViewerPDFSearchCell.xib */; };
 		F76D3CF52428D0C1005DFA87 /* NCViewerPDF.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F76D3CF42428D0C0005DFA87 /* NCViewerPDF.storyboard */; };
@@ -735,6 +739,7 @@
 		F769454522E9F1B0000A798A /* NCShareCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCommon.swift; sourceTree = "<group>"; };
 		F769454722E9F20D000A798A /* NCShareNetworking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareNetworking.swift; sourceTree = "<group>"; };
 		F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCBrand.swift; sourceTree = "<group>"; };
+		F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityIndicator.swift; sourceTree = "<group>"; };
 		F76D3CF02428B40E005DFA87 /* NCViewerPDFSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerPDFSearch.swift; sourceTree = "<group>"; };
 		F76D3CF22428B94E005DFA87 /* NCViewerPDFSearchCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCViewerPDFSearchCell.xib; sourceTree = "<group>"; };
 		F76D3CF42428D0C0005DFA87 /* NCViewerPDF.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCViewerPDF.storyboard; sourceTree = "<group>"; };
@@ -1564,6 +1569,7 @@
 				F70968A324212C4E00ED60E5 /* NCLivePhoto.swift */,
 				F707C26421A2DC5200F6181E /* NCStoreReview.swift */,
 				F70BFC7320E0FA7C00C67599 /* NCUtility.swift */,
+				F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */,
 				AF93474B27E34120002537EE /* NCUtility+Image.swift */,
 				AF817EF0274BC781009ED85B /* NCUserBaseUrl.swift */,
 				F74AF3A3247FB6AE00AC767B /* NCUtilityFileSystem.swift */,
@@ -2389,6 +2395,7 @@
 				F785EEA52461A4CF00B3F945 /* CCUtility.m in Sources */,
 				2C1D5D7923E2DE9100334ABB /* NCBrand.swift in Sources */,
 				F770768A263A8A2500A1BA94 /* NCUtilityFileSystem.swift in Sources */,
+				F76D364928A4F8BF00214537 /* NCActivityIndicator.swift in Sources */,
 				F746EC50273906BA0052598D /* NCViewCertificateDetails.swift in Sources */,
 				AF4BF62127562B3F0081CEEF /* NCManageDatabase+Activity.swift in Sources */,
 				F702F2D225EE5B5C008F8E80 /* NCGlobal.swift in Sources */,
@@ -2465,6 +2472,7 @@
 				F7BAADC91ED5A87C00B7EAD4 /* NCDatabase.swift in Sources */,
 				F7D57C8B26317BDE00DE301D /* NCAccountRequest.swift in Sources */,
 				AF22B217277D196700DAB0CC /* NCShareExtension+DataSource.swift in Sources */,
+				F76D364728A4F8BF00214537 /* NCActivityIndicator.swift in Sources */,
 				F780710A1EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */,
 				F79EC77F26316193004E59D6 /* NCRenameFile.swift in Sources */,
 				AF22B208277B4E4C00DAB0CC /* NCCreateFormUploadConflictCell.swift in Sources */,
@@ -2483,6 +2491,7 @@
 				F76673F022C90434007ED366 /* FileProviderUtility.swift in Sources */,
 				F7434B3420E23FD700417916 /* NCDatabase.swift in Sources */,
 				F702F2D125EE5B5C008F8E80 /* NCGlobal.swift in Sources */,
+				F76D364828A4F8BF00214537 /* NCActivityIndicator.swift in Sources */,
 				F7434B3820E2400600417916 /* NCBrand.swift in Sources */,
 				F785EE9E2461A09900B3F945 /* NCNetworking.swift in Sources */,
 				F746EC4F273906B90052598D /* NCViewCertificateDetails.swift in Sources */,
@@ -2636,6 +2645,7 @@
 				AF3FDCC22796ECC300710F60 /* NCTrash+CollectionView.swift in Sources */,
 				F7DFB7F4219C5CA800680748 /* NCCreateFormUploadScanDocument.swift in Sources */,
 				F70D7C3725FFBF82002B9E34 /* NCCollectionViewCommon.swift in Sources */,
+				F76D364628A4F8BF00214537 /* NCActivityIndicator.swift in Sources */,
 				F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */,
 				F7134186259747BA00768D21 /* NCPushNotification.m in Sources */,
 				F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */,
@@ -2997,7 +3007,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 17;
+				CURRENT_PROJECT_VERSION = 18;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -3060,7 +3070,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 17;
+				CURRENT_PROJECT_VERSION = 18;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;

+ 7 - 4
iOSClient/Activity/NCActivity.swift

@@ -286,6 +286,7 @@ extension NCActivity: UITableViewDataSource {
         }
 
         // subject
+        cell.subject.text = activity.subject
         if activity.subjectRich.count > 0 {
 
             var subject = activity.subjectRich
@@ -351,10 +352,12 @@ extension NCActivity {
         guard !isFetchingActivity else { return }
         self.isFetchingActivity = true
 
-        if let height = self.tabBarController?.tabBar.frame.height {
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: -height-20, style: .gray)
+        var bottom: CGFloat = 0
+        if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar {
+            bottom = -mainTabBar.getHight()
         }
-        
+        NCActivityIndicator.shared.start(backgroundView: self.view, bottom: bottom-5, style: .gray)
+
         let dispatchGroup = DispatchGroup()
         loadComments(disptachGroup: dispatchGroup)
 
@@ -366,7 +369,7 @@ extension NCActivity {
 
         dispatchGroup.notify(queue: .main) {
             self.loadDataSource()
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
 
             // otherwise is triggered again
             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

+ 6 - 3
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -23,6 +23,7 @@
 
 import Foundation
 import NCCommunication
+import FloatingPanel
 
 class NCActivityCollectionViewCell: UICollectionViewCell {
 
@@ -143,7 +144,9 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
 
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(activitySubjectRich.id, fileNameView: activitySubjectRich.name)!
 
-            NCUtility.shared.startActivityIndicator(backgroundView: (appDelegate.window?.rootViewController?.view)!, blurEffect: true)
+            if let backgroundView = appDelegate.window?.rootViewController?.view {
+                NCActivityIndicator.shared.start(backgroundView: backgroundView)
+            }
 
             NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
 
@@ -161,7 +164,7 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
 
                     NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName) { account, metadata, errorCode, _ in
 
-                        NCUtility.shared.stopActivityIndicator()
+                        NCActivityIndicator.shared.stop()
 
                         if account == self.appDelegate.account && errorCode == 0 {
 
@@ -180,7 +183,7 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
 
                 } else {
 
-                    NCUtility.shared.stopActivityIndicator()
+                    NCActivityIndicator.shared.stop()
                 }
             }
         }

+ 9 - 9
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -417,7 +417,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
 
         } else {
 
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: true)
+            NCActivityIndicator.shared.start(backgroundView: self.view)
 
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.dismissAndUpload(metadataForUpload)
@@ -429,7 +429,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
 
         if metadatas != nil && metadatas!.count > 0 {
 
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: true)
+            NCActivityIndicator.shared.start(backgroundView: self.view)
 
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.dismissAndUpload(metadatas![0])
@@ -440,7 +440,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
     func dismissAndUpload(_ metadata: tableMetadata) {
 
         guard let fileNameGenerateExport = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) else {
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
             return
         }
@@ -456,7 +456,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
 
                 let request = VNRecognizeTextRequest { request, _ in
                     guard let observations = request.results as? [VNRecognizedTextObservation] else {
-                        NCUtility.shared.stopActivityIndicator()
+                        NCActivityIndicator.shared.stop()
                         return
                     }
                     for observation in observations {
@@ -477,7 +477,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             do {
                 try textFile.write(to: fileUrl, atomically: true, encoding: .utf8)
             } catch {
-                NCUtility.shared.stopActivityIndicator()
+                NCActivityIndicator.shared.stop()
                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
                 return
             }
@@ -513,7 +513,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
 
                     let request = VNRecognizeTextRequest { request, _ in
                         guard let observations = request.results as? [VNRecognizedTextObservation] else {
-                            NCUtility.shared.stopActivityIndicator()
+                            NCActivityIndicator.shared.stop()
                             return
                         }
                         for observation in observations {
@@ -559,7 +559,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             let image = changeCompressionImage(self.arrayImages[0])
 
             guard let data = image.jpegData(compressionQuality: CGFloat(0.5)) else {
-                NCUtility.shared.stopActivityIndicator()
+                NCActivityIndicator.shared.stop()
                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
                 return
             }
@@ -567,14 +567,14 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             do {
                 try data.write(to: fileUrl, options: .atomic)
             } catch {
-                NCUtility.shared.stopActivityIndicator()
+                NCActivityIndicator.shared.stop()
                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
                 return
             }
         }
         metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNameGenerateExport)
 
-        NCUtility.shared.stopActivityIndicator()
+        NCActivityIndicator.shared.stop()
 
         appDelegate.networkingProcessUpload?.createProcessUploads(metadatas: [metadata])
 

+ 2 - 2
iOSClient/Main/NCFunctionCenter.swift

@@ -179,9 +179,9 @@ import Photos
     func openShare(viewController: UIViewController, metadata: tableMetadata, indexPage: NCGlobal.NCSharePagingIndex) {
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
-        NCUtility.shared.startActivityIndicator(backgroundView: viewController.view, blurEffect: false)
+        NCActivityIndicator.shared.start(backgroundView: viewController.view)
         NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, queue: .main) { account, metadata, errorCode, errorDescription in
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             if let metadata = metadata, errorCode == 0 {
                 let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as! UINavigationController
                 let shareViewController = shareNavigationController.topViewController as! NCSharePaging

+ 6 - 2
iOSClient/Main/NCMainTabBar.swift

@@ -28,6 +28,7 @@ class NCMainTabBar: UITabBar {
     private var fillColor: UIColor!
     private var shapeLayer: CALayer?
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    private let centerButtonY: CGFloat = -28
 
     public var menuRect: CGRect {
         get {
@@ -173,9 +174,8 @@ class NCMainTabBar: UITabBar {
         if let centerButton = self.viewWithTag(99) {
             centerButton.removeFromSuperview()
         }
-        let centerButtonHeight: CGFloat = 57
-        let centerButtonY: CGFloat = -28
 
+        let centerButtonHeight: CGFloat = 57
         let centerButton = UIButton(frame: CGRect(x: (self.bounds.width / 2)-(centerButtonHeight/2), y: centerButtonY, width: centerButtonHeight, height: centerButtonHeight))
 
         centerButton.setTitle("", for: .normal)
@@ -230,4 +230,8 @@ class NCMainTabBar: UITabBar {
             return nil
         }
     }
+
+    func getHight() -> CGFloat {
+        return (frame.size.height - centerButtonY)
+    }
 }

+ 5 - 3
iOSClient/Media/NCMedia.swift

@@ -523,14 +523,16 @@ extension NCMedia {
             greaterDate = Calendar.current.date(byAdding: .day, value: value, to: lessDate)!
         }
 
-        if let height = self.tabBarController?.tabBar.frame.height {
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: -height-20, style: .gray)
+        var bottom: CGFloat = 0
+        if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar {
+            bottom = -mainTabBar.getHight()
         }
+        NCActivityIndicator.shared.start(backgroundView: self.view, bottom: bottom-5, style: .gray)
 
         NCCommunication.shared.searchMedia(path: mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), timeout: 300) { account, files, errorCode, errorDescription in
 
             self.oldInProgress = false
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             self.collectionView.reloadData()
 
             if errorCode == 0 && account == self.appDelegate.account {

+ 2 - 2
iOSClient/Networking/NCAutoUpload.swift

@@ -62,9 +62,9 @@ class NCAutoUpload: NSObject {
             guard hasPermission else { return }
 
             NCContentPresenter.shared.messageNotification("_attention_", description: "_create_full_upload_", delay: NCGlobal.shared.dismissAfterSecondLong, type: .info, errorCode: NCGlobal.shared.errorNoError, priority: .max)
-            NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: true)
+            NCActivityIndicator.shared.start()
             self.uploadAssetsNewAndFull(viewController: viewController, selector: NCGlobal.shared.selectorUploadAutoUploadAll, log: log) { _ in
-                NCUtility.shared.stopActivityIndicator()
+                NCActivityIndicator.shared.stop()
             }
         }
     }

+ 0 - 4
iOSClient/Notification/NCNotification.swift

@@ -272,8 +272,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
     func getNetwokingNotification() {
 
-        NCUtility.shared.startActivityIndicator(backgroundView: self.navigationController?.view, blurEffect: true)
-
         NCCommunication.shared.getNotifications { account, notifications, errorCode, _ in
 
             if errorCode == 0 && account == self.appDelegate.account {
@@ -290,8 +288,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
                 self.reloadDatasource()
             }
-
-            NCUtility.shared.stopActivityIndicator()
         }
     }
 }

+ 2 - 2
iOSClient/Rename file/NCRenameFile.swift

@@ -231,11 +231,11 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
 
     func renameMetadata(_ metadata: tableMetadata, fileNameNew: String) {
 
-        NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: true)
+        NCActivityIndicator.shared.start()
 
         NCNetworking.shared.renameMetadata(metadata, fileNameNew: fileNameNew, viewController: self) { errorCode, errorDescription in
 
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
 
             if errorCode == 0 {
 

+ 4 - 4
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -37,12 +37,12 @@ import NCCommunication
 
         guard let directEditingCreator = NCManageDatabase.shared.getDirectEditingCreators(predicate: NSPredicate(format: "account == %@ AND editor == 'text'", appDelegate.account))?.first else { return }
 
-        NCUtility.shared.startActivityIndicator(backgroundView: viewController.view, blurEffect: true)
+        NCActivityIndicator.shared.start(backgroundView: viewController.view)
 
         let fileNamePath = CCUtility.returnFileNamePath(fromFileName: NCGlobal.shared.fileNameRichWorkspace, serverUrl: serverUrl, urlBase: appDelegate.urlBase, account: appDelegate.account)!
         NCCommunication.shared.NCTextCreateFile(fileNamePath: fileNamePath, editorId: directEditingCreator.editor, creatorId: directEditingCreator.identifier, templateId: "") { account, url, errorCode, errorMessage in
 
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
 
             if errorCode == 0 && account == self.appDelegate.account {
 
@@ -72,12 +72,12 @@ import NCCommunication
 
             if metadata.url == "" {
 
-                NCUtility.shared.startActivityIndicator(backgroundView: viewController.view, blurEffect: true)
+                NCActivityIndicator.shared.start(backgroundView: viewController.view)
 
                 let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: appDelegate.urlBase, account: appDelegate.account)!
                 NCCommunication.shared.NCTextOpenFile(fileNamePath: fileNamePath, editor: "text") { account, url, errorCode, errorMessage in
 
-                    NCUtility.shared.stopActivityIndicator()
+                    NCActivityIndicator.shared.stop()
 
                     if errorCode == 0 && account == self.appDelegate.account {
 

+ 2 - 2
iOSClient/Settings/CCAdvanced.m

@@ -404,7 +404,7 @@
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitialize object:nil userInfo:nil];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-        [[NCUtility shared] stopActivityIndicator];
+        [[NCActivityIndicator shared] stop];
         [self calculateSize];
     });
 }
@@ -416,7 +416,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 top:0 style: UIActivityIndicatorViewStyleWhiteLarge];
+        [[NCActivityIndicator shared] startActivityWithBackgroundView:nil style: UIActivityIndicatorViewStyleWhiteLarge];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             [self clearCache];
         });

+ 10 - 10
iOSClient/Share/NCShareNetworking.swift

@@ -43,14 +43,14 @@ class NCShareNetworking: NSObject {
 
     func readShare(showLoadingIndicator: Bool) {
         if showLoadingIndicator {
-            NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: false)
+            NCActivityIndicator.shared.start(backgroundView: view)
         }
 
         let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: urlBase, account: metadata.account)!
         let parameter = NCCShareParameter(path: filenamePath)
         NCCommunication.shared.readShares(parameters: parameter) { account, shares, errorCode, errorDescription in
             if showLoadingIndicator {
-                NCUtility.shared.stopActivityIndicator()
+                NCActivityIndicator.shared.stop()
             }
 
              if errorCode == 0, let shares = shares {
@@ -71,11 +71,11 @@ class NCShareNetworking: NSObject {
         // Library update needed:
         // https://github.com/nextcloud/ios-communication-library/pull/104
 
-        NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: false)
+        NCActivityIndicator.shared.start(backgroundView: view)
         let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: urlBase, account: metadata.account)!
 
         NCCommunication.shared.createShare(path: filenamePath, shareType: option.shareType, shareWith: option.shareWith, password: option.password, permissions: option.permissions) { (account, share, errorCode, errorDescription) in
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             if errorCode == 0, let share = share {
                 option.idShare = share.idShare
                 NCManageDatabase.shared.addShare(urlBase: self.urlBase, account: self.metadata.account, shares: [share])
@@ -91,9 +91,9 @@ class NCShareNetworking: NSObject {
     }
 
     func unShare(idShare: Int) {
-        NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: false)
+        NCActivityIndicator.shared.start(backgroundView: view)
         NCCommunication.shared.deleteShare(idShare: idShare) { account, errorCode, errorDescription in
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             if errorCode == 0 {
                 NCManageDatabase.shared.deleteTableShare(account: account, idShare: idShare)
                 self.delegate?.unShareCompleted()
@@ -104,9 +104,9 @@ class NCShareNetworking: NSObject {
     }
 
     func updateShare(option: NCTableShareable) {
-        NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: false)
+        NCActivityIndicator.shared.start(backgroundView: view)
         NCCommunication.shared.updateShare(idShare: option.idShare, password: option.password, expireDate: option.expDateString, permissions: option.permissions, note: option.note, label: option.label, hideDownload: option.hideDownload) { account, share, errorCode, errorDescription in
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             if errorCode == 0, let share = share {
                 NCManageDatabase.shared.addShare(urlBase: self.urlBase, account: self.metadata.account, shares: [share])
                 self.appDelegate.shares = NCManageDatabase.shared.getTableShares(account: self.metadata.account)
@@ -119,9 +119,9 @@ class NCShareNetworking: NSObject {
     }
 
     func getSharees(searchString: String) {
-        NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: false)
+        NCActivityIndicator.shared.start(backgroundView: view)
         NCCommunication.shared.searchSharees(search: searchString) { _, sharees, errorCode, errorDescription in
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
             if errorCode == 0 {
                 self.delegate?.getSharees(sharees: sharees)
             } else {

+ 148 - 0
iOSClient/Utility/NCActivityIndicator.swift

@@ -0,0 +1,148 @@
+//
+//  NCActivityIndicator.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 11/08/22.
+//  Copyright © 2022 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+import UIKit
+
+class NCActivityIndicator: NSObject {
+    @objc static let shared: NCActivityIndicator = {
+        let instance = NCActivityIndicator()
+        return instance
+    }()
+
+    private var activityIndicator: UIActivityIndicatorView?
+    private var viewActivityIndicator: UIView?
+    private var viewBackgroundActivityIndicator: UIView?
+
+    @objc func startActivity(backgroundView: UIView?, style: UIActivityIndicatorView.Style) {
+        start(backgroundView: backgroundView, style: style)
+    }
+
+    func start(backgroundView: UIView? = nil, bottom: CGFloat? = nil, top: CGFloat? = nil, style: UIActivityIndicatorView.Style = .whiteLarge) {
+
+        if self.activityIndicator != nil { stop() }
+
+        DispatchQueue.main.async {
+
+            self.activityIndicator = UIActivityIndicatorView(style: style)
+            guard let activityIndicator = self.activityIndicator, self.viewBackgroundActivityIndicator == nil else { return }
+
+            activityIndicator.color = NCBrandColor.shared.label
+            activityIndicator.hidesWhenStopped = true
+            activityIndicator.translatesAutoresizingMaskIntoConstraints = false
+
+            var sizeActivityIndicator = activityIndicator.frame.height
+            if backgroundView == nil {
+                sizeActivityIndicator += 50
+            }
+
+            self.viewActivityIndicator = UIView(frame: CGRect(x: 0, y: 0, width: sizeActivityIndicator, height: sizeActivityIndicator))
+            self.viewActivityIndicator?.translatesAutoresizingMaskIntoConstraints = false
+            self.viewActivityIndicator?.layer.cornerRadius = 10
+            self.viewActivityIndicator?.layer.masksToBounds = true
+            self.viewActivityIndicator?.backgroundColor = .clear
+
+            #if !EXTENSION
+            if backgroundView == nil {
+                if let window = UIApplication.shared.keyWindow {
+                    self.viewBackgroundActivityIndicator?.removeFromSuperview()
+                    self.viewBackgroundActivityIndicator = NCViewActivityIndicator(frame: window.bounds)
+                    window.addSubview(self.viewBackgroundActivityIndicator!)
+                    self.viewBackgroundActivityIndicator?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+                    self.viewBackgroundActivityIndicator?.backgroundColor = .clear
+                }
+            } else {
+                self.viewBackgroundActivityIndicator = backgroundView
+            }
+            #else
+            self.viewBackgroundActivityIndicator = backgroundView
+            #endif
+
+            // VIEW ACTIVITY INDICATOR
+
+            guard let viewActivityIndicator = self.viewActivityIndicator else { return }
+            viewActivityIndicator.addSubview(activityIndicator)
+
+            if backgroundView == nil {
+                let blurEffect = UIBlurEffect(style: .regular)
+                let blurEffectView = UIVisualEffectView(effect: blurEffect)
+                blurEffectView.frame = viewActivityIndicator.frame
+                viewActivityIndicator.insertSubview(blurEffectView, at: 0)
+            }
+
+            NSLayoutConstraint.activate([
+                viewActivityIndicator.widthAnchor.constraint(equalToConstant: sizeActivityIndicator),
+                viewActivityIndicator.heightAnchor.constraint(equalToConstant: sizeActivityIndicator),
+                activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
+                activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
+            ])
+
+            // BACKGROUD VIEW ACTIVITY INDICATOR
+
+            guard let viewBackgroundActivityIndicator = self.viewBackgroundActivityIndicator else { return }
+            viewBackgroundActivityIndicator.addSubview(viewActivityIndicator)
+
+            if let constant = bottom {
+                viewActivityIndicator.bottomAnchor.constraint(equalTo: viewBackgroundActivityIndicator.bottomAnchor, constant: constant).isActive = true
+            } else if let constant = top {
+                viewActivityIndicator.topAnchor.constraint(equalTo: viewBackgroundActivityIndicator.topAnchor, constant: constant).isActive = true
+            } else {
+                viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor).isActive = true
+            }
+            viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor).isActive = true
+
+            activityIndicator.startAnimating()
+        }
+    }
+
+    @objc func stop() {
+
+        DispatchQueue.main.async {
+
+            self.activityIndicator?.stopAnimating()
+            self.activityIndicator?.removeFromSuperview()
+            self.activityIndicator = nil
+
+            self.viewActivityIndicator?.removeFromSuperview()
+            self.viewActivityIndicator = nil
+
+            if self.viewBackgroundActivityIndicator is NCViewActivityIndicator {
+                self.viewBackgroundActivityIndicator?.removeFromSuperview()
+            }
+            self.viewBackgroundActivityIndicator = nil
+        }
+    }
+}
+
+class NCViewActivityIndicator: UIView {
+
+    // MARK: - View Life Cycle
+
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+    }
+
+    required init?(coder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+}

+ 0 - 125
iOSClient/Utility/NCUtility.swift

@@ -37,10 +37,6 @@ class NCUtility: NSObject {
         return instance
     }()
 
-    private var activityIndicator: UIActivityIndicatorView?
-    private var viewActivityIndicator: UIView?
-    private var viewBackgroundActivityIndicator: UIView?
-
     func setLayoutForView(key: String, serverUrl: String, layoutForView: NCGlobal.layoutForViewType) {
 
         let string =  layoutForView.layout + "|" + layoutForView.sort + "|" + "\(layoutForView.ascending)" + "|" + layoutForView.groupBy + "|" + "\(layoutForView.directoryOnTop)" + "|" + layoutForView.titleButtonHeader + "|" + "\(layoutForView.itemForLine)"
@@ -706,112 +702,6 @@ class NCUtility: NSObject {
         return avatarImage
     }
 
-    // MARK: -
-
-    @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, top: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
-
-        if self.activityIndicator != nil {
-            stopActivityIndicator()
-        }
-
-        DispatchQueue.main.async {
-
-            self.activityIndicator = UIActivityIndicatorView(style: style)
-            guard let activityIndicator = self.activityIndicator else { return }
-            if self.viewBackgroundActivityIndicator != nil { return }
-
-            activityIndicator.color = NCBrandColor.shared.label
-            activityIndicator.hidesWhenStopped = true
-            activityIndicator.translatesAutoresizingMaskIntoConstraints = false
-
-            let sizeActivityIndicator = activityIndicator.frame.height + 50
-
-            self.viewActivityIndicator = UIView(frame: CGRect(x: 0, y: 0, width: sizeActivityIndicator, height: sizeActivityIndicator))
-            self.viewActivityIndicator?.translatesAutoresizingMaskIntoConstraints = false
-            self.viewActivityIndicator?.layer.cornerRadius = 10
-            self.viewActivityIndicator?.layer.masksToBounds = true
-            self.viewActivityIndicator?.backgroundColor = .clear
-
-            #if !EXTENSION
-            if backgroundView == nil {
-                if let window = UIApplication.shared.keyWindow {
-                    self.viewBackgroundActivityIndicator?.removeFromSuperview()
-                    self.viewBackgroundActivityIndicator = NCViewActivityIndicator(frame: window.bounds)
-                    window.addSubview(self.viewBackgroundActivityIndicator!)
-                    self.viewBackgroundActivityIndicator?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-                    self.viewBackgroundActivityIndicator?.backgroundColor = .clear
-                }
-            } else {
-                self.viewBackgroundActivityIndicator = backgroundView
-            }
-            #else
-            self.viewBackgroundActivityIndicator = backgroundView
-            #endif
-
-            // VIEW ACTIVITY INDICATOR
-
-            guard let viewActivityIndicator = self.viewActivityIndicator else { return }
-            viewActivityIndicator.addSubview(activityIndicator)
-
-            if blurEffect {
-                let blurEffect = UIBlurEffect(style: .regular)
-                let blurEffectView = UIVisualEffectView(effect: blurEffect)
-                blurEffectView.frame = viewActivityIndicator.frame
-                viewActivityIndicator.insertSubview(blurEffectView, at: 0)
-            }
-
-            NSLayoutConstraint.activate([
-                viewActivityIndicator.widthAnchor.constraint(equalToConstant: sizeActivityIndicator),
-                viewActivityIndicator.heightAnchor.constraint(equalToConstant: sizeActivityIndicator),
-                activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
-                activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
-            ])
-
-            // BACKGROUD VIEW ACTIVITY INDICATOR
-
-            guard let viewBackgroundActivityIndicator = self.viewBackgroundActivityIndicator else { return }
-            viewBackgroundActivityIndicator.addSubview(viewActivityIndicator)
-
-            if bottom < 0 {
-                NSLayoutConstraint.activate([
-                    viewActivityIndicator.bottomAnchor.constraint(equalTo: viewBackgroundActivityIndicator.bottomAnchor, constant: bottom)
-                ])
-            } else if top > 0 {
-                NSLayoutConstraint.activate([
-                    viewActivityIndicator.topAnchor.constraint(equalTo: viewBackgroundActivityIndicator.topAnchor, constant: top)
-                ])
-            } else {
-                NSLayoutConstraint.activate([
-                    viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor)
-                ])
-            }
-
-            NSLayoutConstraint.activate([
-                viewActivityIndicator.centerXAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerXAnchor)
-            ])
-
-            activityIndicator.startAnimating()
-        }
-    }
-
-    @objc func stopActivityIndicator() {
-
-        DispatchQueue.main.async {
-
-            self.activityIndicator?.stopAnimating()
-            self.activityIndicator?.removeFromSuperview()
-            self.activityIndicator = nil
-
-            self.viewActivityIndicator?.removeFromSuperview()
-            self.viewActivityIndicator = nil
-
-            if self.viewBackgroundActivityIndicator is NCViewActivityIndicator {
-                self.viewBackgroundActivityIndicator?.removeFromSuperview()
-            }
-            self.viewBackgroundActivityIndicator = nil
-        }
-    }
-
     /*
     Facebook's comparison algorithm:
     */
@@ -1053,18 +943,3 @@ class NCUtility: NSObject {
         return emailPred.evaluate(with: email)
     }
 }
-
-// MARK: -
-
-class NCViewActivityIndicator: UIView {
-
-    // MARK: - View Life Cycle
-
-    override init(frame: CGRect) {
-        super.init(frame: frame)
-    }
-
-    required init?(coder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-}

+ 4 - 4
iOSClient/Viewer/NCViewer.swift

@@ -101,10 +101,10 @@ class NCViewer: NSObject {
 
                 if metadata.url == "" {
 
-                    NCUtility.shared.startActivityIndicator(backgroundView: viewController.view, blurEffect: true)
+                    NCActivityIndicator.shared.start(backgroundView: viewController.view)
                     NCCommunication.shared.createUrlRichdocuments(fileID: metadata.fileId) { account, url, errorCode, errorDescription in
 
-                        NCUtility.shared.stopActivityIndicator()
+                        NCActivityIndicator.shared.stop()
 
                         if errorCode == 0 && account == self.appDelegate.account && url != nil {
 
@@ -166,10 +166,10 @@ class NCViewer: NSObject {
                             customUserAgent = NCUtility.shared.getCustomUserAgentNCText()
                         }
 
-                        NCUtility.shared.startActivityIndicator(backgroundView: viewController.view, blurEffect: true)
+                        NCActivityIndicator.shared.start(backgroundView: viewController.view)
                         NCCommunication.shared.NCTextOpenFile(fileNamePath: fileNamePath, editor: editor, customUserAgent: customUserAgent) { account, url, errorCode, errorMessage in
 
-                            NCUtility.shared.stopActivityIndicator()
+                            NCActivityIndicator.shared.stop()
 
                             if errorCode == 0 && account == self.appDelegate.account && url != nil {
 

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

@@ -194,7 +194,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     }
 
     public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
-        NCUtility.shared.stopActivityIndicator()
+        NCActivityIndicator.shared.stop()
     }
 }
 

+ 2 - 4
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -276,9 +276,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
               fileName == self.metadata.fileName
         else { return }
 
-        if let height = self.navigationController?.navigationBar.frame.height {
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, top: height+50 , style: .gray)
-        }
+        NCActivityIndicator.shared.start()
     }
 
     @objc func uploadedFile(_ notification: NSNotification) {
@@ -293,7 +291,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
             return
         }
 
-        NCUtility.shared.stopActivityIndicator()
+        NCActivityIndicator.shared.stop()
 
         if errorCode == 0 {
             pdfDocument = PDFDocument(url: URL(fileURLWithPath: filePath))

+ 3 - 3
iOSClient/Viewer/NCViewerProviderContextMenu.swift

@@ -178,7 +178,7 @@ class NCViewerProviderContextMenu: UIViewController {
         else { return }
 
         if ocId == self.metadata?.ocId || ocId == self.metadataLivePhoto?.ocId {
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false)
+            NCActivityIndicator.shared.start(backgroundView: self.view)
         }
     }
 
@@ -203,7 +203,7 @@ class NCViewerProviderContextMenu: UIViewController {
             viewVideo(metadata: metadata)
         }
         if ocId == self.metadata?.ocId || ocId == self.metadataLivePhoto?.ocId {
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
         }
     }
 
@@ -214,7 +214,7 @@ class NCViewerProviderContextMenu: UIViewController {
         else { return }
 
         if ocId == self.metadata?.ocId || ocId == self.metadataLivePhoto?.ocId {
-            NCUtility.shared.stopActivityIndicator()
+            NCActivityIndicator.shared.stop()
         }
     }
 

+ 3 - 3
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -192,7 +192,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
                         guard let url = URL(string: urlString) else { return }
                         let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + metadata.fileNameWithoutExt
 
-                        NCUtility.shared.startActivityIndicator(backgroundView: view, blurEffect: true)
+                        NCActivityIndicator.shared.start(backgroundView: view)
 
                         NCCommunication.shared.download(serverUrlFileName: url, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
 
@@ -202,7 +202,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
 
                         }, completionHandler: { account, _, _, _, allHeaderFields, error, errorCode, errorDescription in
 
-                            NCUtility.shared.stopActivityIndicator()
+                            NCActivityIndicator.shared.stop()
 
                             if errorCode == 0 && account == self.metadata.account {
 
@@ -332,7 +332,7 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
     }
 
     public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
-        NCUtility.shared.stopActivityIndicator()
+        NCActivityIndicator.shared.stop()
     }
 }