Browse Source

Merge branch 'develop'

marinofaggiana 4 years ago
parent
commit
958959bd0a
100 changed files with 1857 additions and 2633 deletions
  1. 0 9
      CHANGELOG.md
  2. 0 1
      Cartfile
  3. 10 10
      File Provider Extension/FileProviderData.swift
  4. 1 1
      File Provider Extension/FileProviderDomain.swift
  5. 25 25
      File Provider Extension/FileProviderEnumerator.swift
  6. 20 20
      File Provider Extension/FileProviderExtension+Actions.swift
  7. 14 14
      File Provider Extension/FileProviderExtension.swift
  8. 2 2
      File Provider Extension/FileProviderItem.swift
  9. 5 5
      File Provider Extension/FileProviderUtility.swift
  10. 0 19
      Libraries external/PKDownloadButton/CALayer+PKDownloadButtonAnimations.h
  11. 0 60
      Libraries external/PKDownloadButton/CALayer+PKDownloadButtonAnimations.m
  12. 0 18
      Libraries external/PKDownloadButton/NSLayoutConstraint+PKDownloadButton.h
  13. 0 99
      Libraries external/PKDownloadButton/NSLayoutConstraint+PKDownloadButton.m
  14. 0 20
      Libraries external/PKDownloadButton/PKBorderedButton.h
  15. 0 49
      Libraries external/PKDownloadButton/PKBorderedButton.m
  16. 0 20
      Libraries external/PKDownloadButton/PKCircleProgressView.h
  17. 0 180
      Libraries external/PKDownloadButton/PKCircleProgressView.m
  18. 0 18
      Libraries external/PKDownloadButton/PKCircleView.h
  19. 0 91
      Libraries external/PKDownloadButton/PKCircleView.m
  20. 0 52
      Libraries external/PKDownloadButton/PKDownloadButton.h
  21. 0 219
      Libraries external/PKDownloadButton/PKDownloadButton.m
  22. 0 42
      Libraries external/PKDownloadButton/PKMacros.h
  23. 0 25
      Libraries external/PKDownloadButton/PKPendingView.h
  24. 0 134
      Libraries external/PKDownloadButton/PKPendingView.m
  25. 0 18
      Libraries external/PKDownloadButton/PKStopDownloadButton.h
  26. 0 96
      Libraries external/PKDownloadButton/PKStopDownloadButton.m
  27. 0 16
      Libraries external/PKDownloadButton/UIImage+PKDownloadButton.h
  28. 0 49
      Libraries external/PKDownloadButton/UIImage+PKDownloadButton.m
  29. 246 251
      Nextcloud.xcodeproj/project.pbxproj
  30. 6 6
      Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  31. 2 2
      Notification Service Extension/NotificationService.swift
  32. 17 17
      Share/NCSelectDestination.m
  33. 18 18
      Share/ShareViewController.m
  34. 27 17
      iOSClient/Activity/NCActivity.swift
  35. 5 30
      iOSClient/AppDelegate.h
  36. 78 380
      iOSClient/AppDelegate.m
  37. 1 1
      iOSClient/AutoUpload/NCAutoUpload.h
  38. 95 98
      iOSClient/AutoUpload/NCAutoUpload.m
  39. 8 8
      iOSClient/Brand/Intro/NCIntroViewController.swift
  40. 80 3
      iOSClient/Brand/NCBrand.swift
  41. 4 4
      iOSClient/BrowserWeb/NCBrowserWeb.storyboard
  42. 9 0
      iOSClient/BrowserWeb/NCBrowserWeb.swift
  43. 34 43
      iOSClient/CCGlobal.h
  44. 4 4
      iOSClient/Data/NCDataSource.swift
  45. 27 1
      iOSClient/Data/NCDatabase.swift
  46. 3 0
      iOSClient/Data/NCElementsJSON.swift
  47. 127 22
      iOSClient/Data/NCManageDatabase.swift
  48. 98 10
      iOSClient/Diagnostics/NCCapabilitiesViewController.storyboard
  49. 72 35
      iOSClient/Diagnostics/NCCapabilitiesViewController.swift
  50. 1 1
      iOSClient/EmptyView/NCEmptyDataSet.swift
  51. 0 9
      iOSClient/Favorites/NCFavorite.storyboard
  52. 7 7
      iOSClient/Favorites/NCFavorite.swift
  53. 0 9
      iOSClient/FileViewInFolder/NCFileViewInFolder.storyboard
  54. 8 7
      iOSClient/FileViewInFolder/NCFileViewInFolder.swift
  55. 0 9
      iOSClient/Files/NCFiles.storyboard
  56. 8 8
      iOSClient/Files/NCFiles.swift
  57. 15 0
      iOSClient/Images.xcassets/audioOff.imageset/Contents.json
  58. 53 0
      iOSClient/Images.xcassets/audioOff.imageset/audioOff.pdf
  59. 15 0
      iOSClient/Images.xcassets/audioOn.imageset/Contents.json
  60. 52 0
      iOSClient/Images.xcassets/audioOn.imageset/audioOn.pdf
  61. 0 23
      iOSClient/Images.xcassets/bkempty.imageset/Contents.json
  62. BIN
      iOSClient/Images.xcassets/bkempty.imageset/bkempty.png
  63. BIN
      iOSClient/Images.xcassets/bkempty.imageset/bkempty@2x.png
  64. BIN
      iOSClient/Images.xcassets/bkempty.imageset/bkempty@3x.png
  65. 0 23
      iOSClient/Images.xcassets/bkfull.imageset/Contents.json
  66. BIN
      iOSClient/Images.xcassets/bkfull.imageset/bkfull.png
  67. BIN
      iOSClient/Images.xcassets/bkfull.imageset/bkfull@2x.png
  68. BIN
      iOSClient/Images.xcassets/bkfull.imageset/bkfull@3x.png
  69. 15 0
      iOSClient/Images.xcassets/closeVideo.imageset/Contents.json
  70. BIN
      iOSClient/Images.xcassets/closeVideo.imageset/closeVideo.pdf
  71. 15 0
      iOSClient/Images.xcassets/comments.imageset/Contents.json
  72. BIN
      iOSClient/Images.xcassets/comments.imageset/comments.pdf
  73. 15 0
      iOSClient/Images.xcassets/favoriteSmall.imageset/Contents.json
  74. BIN
      iOSClient/Images.xcassets/favoriteSmall.imageset/videoFavoriteOn.pdf
  75. 15 0
      iOSClient/Images.xcassets/noPreview.imageset/Contents.json
  76. 54 0
      iOSClient/Images.xcassets/noPreview.imageset/noPreview.pdf
  77. 15 0
      iOSClient/Images.xcassets/noPreviewAudio.imageset/Contents.json
  78. 55 0
      iOSClient/Images.xcassets/noPreviewAudio.imageset/noPreviewAudio.pdf
  79. 15 0
      iOSClient/Images.xcassets/noPreviewVideo.imageset/Contents.json
  80. 52 0
      iOSClient/Images.xcassets/noPreviewVideo.imageset/noPreviewVideo.pdf
  81. 15 0
      iOSClient/Images.xcassets/userStatusAway.imageset/Contents.json
  82. BIN
      iOSClient/Images.xcassets/userStatusAway.imageset/userStatusAway.pdf
  83. 15 0
      iOSClient/Images.xcassets/userStatusDnd.imageset/Contents.json
  84. BIN
      iOSClient/Images.xcassets/userStatusDnd.imageset/userStatusDnd.pdf
  85. 15 0
      iOSClient/Images.xcassets/userStatusOffline.imageset/Contents.json
  86. BIN
      iOSClient/Images.xcassets/userStatusOffline.imageset/offline.pdf
  87. 15 0
      iOSClient/Images.xcassets/userStatusOnline.imageset/Contents.json
  88. BIN
      iOSClient/Images.xcassets/userStatusOnline.imageset/online.pdf
  89. 15 15
      iOSClient/Login/CCLogin.m
  90. 13 13
      iOSClient/Login/NCAppConfigView.swift
  91. 19 17
      iOSClient/Login/NCLoginWeb.swift
  92. 4 4
      iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift
  93. 0 43
      iOSClient/Main/AppDelegate+Swift.swift
  94. 102 38
      iOSClient/Main/Colleaction Common/NCCollectionCommon.swift
  95. 135 87
      iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift
  96. 1 1
      iOSClient/Main/Colleaction Common/NCGridCell.swift
  97. 1 1
      iOSClient/Main/Colleaction Common/NCListCell.swift
  98. 33 31
      iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift
  99. 3 3
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  100. 23 22
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

+ 0 - 9
CHANGELOG.md

@@ -6,15 +6,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 ## [Unreleased]
 
-## [3.0.14] - 2020-11-24
-- See https://github.com/nextcloud/ios/releases/tag/3.0.14
-
-## [3.0.13] - 2020-11-14
-- See https://github.com/nextcloud/ios/releases/tag/3.0.13
-
-## [3.0.12] - 2020-11-06
-- See https://github.com/nextcloud/ios/releases/tag/3.0.12
-
 ## [3.0.11] - 2020-10-22
 - See https://github.com/nextcloud/ios/releases/tag/3.0.11
 

+ 0 - 1
Cartfile

@@ -2,7 +2,6 @@ github "tilltue/TLPhotoPicker" "2.1.3"
 github "kishikawakatsumi/UICKeyChainStore"
 github "jdg/MBProgressHUD" "1.1.0"
 github "SVGKit/SVGKit" "3.x"
-github "WeTransfer/WeScan" "1.2.0"
 github "malcommac/SwiftRichString"
 github "yannickl/QRCodeReader.swift" "10.1.1"
 github "weichsel/ZIPFoundation" "0.9.10"

+ 10 - 10
File Provider Extension/FileProviderData.swift

@@ -52,7 +52,7 @@ class fileProviderData: NSObject {
     var fileProviderSignalUpdateWorkingSetItem: [NSFileProviderItemIdentifier: FileProviderItem] = [:]
    
     // UserDefaults
-    var ncUserDefaults = UserDefaults(suiteName: NCBrandOptions.sharedInstance.capabilitiesGroups)
+    var ncUserDefaults = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroups)
     
     // Error
     enum FileProviderError: Error {
@@ -64,7 +64,7 @@ class fileProviderData: NSObject {
     
     func setupAccount(domain: NSFileProviderDomain?, providerExtension: NSFileProviderExtension) -> tableAccount? {
                 
-        if CCUtility.getDisableFilesApp() || NCBrandOptions.sharedInstance.disable_openin_file {
+        if CCUtility.getDisableFilesApp() || NCBrandOptions.shared.disable_openin_file {
             return nil
         }
         
@@ -78,8 +78,8 @@ class fileProviderData: NSObject {
         // NO DOMAIN -> Set default account
         if domain == nil {
             
-            guard let accountActive = NCManageDatabase.sharedInstance.getAccountActive() else { return nil }
-            let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+            guard let accountActive = NCManageDatabase.shared.getAccountActive() else { return nil }
+            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
             let webDav = NCUtility.shared.getWebDAV(account: accountActive.account)
             
             account = accountActive.account
@@ -93,7 +93,7 @@ class fileProviderData: NSObject {
         }
         
         // DOMAIN
-        let accounts = NCManageDatabase.sharedInstance.getAllAccount()
+        let accounts = NCManageDatabase.shared.getAllAccount()
         if accounts.count == 0 { return nil }
         
         for accountActive in accounts {
@@ -102,7 +102,7 @@ class fileProviderData: NSObject {
             let accountDomain = accountActive.userID + " (" + host + ")"
             if accountDomain == domain!.identifier.rawValue {
                 
-                let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+                let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
                 let webDav = NCUtility.shared.getWebDAV(account: accountActive.account)
                 
                 account = accountActive.account
@@ -124,7 +124,7 @@ class fileProviderData: NSObject {
     @discardableResult
     func signalEnumerator(ocId: String, delete: Bool = false, update: Bool = false) -> FileProviderItem? {
         
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) else { return nil }
+        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return nil }
                 
         guard let parentItemIdentifier = fileProviderUtility.shared.getParentItemIdentifier(metadata: metadata) else { return nil }
         
@@ -159,12 +159,12 @@ class fileProviderData: NSObject {
          
          var updateWorkingSet = false
          let oldListFavoriteIdentifierRank = listFavoriteIdentifierRank
-         listFavoriteIdentifierRank = NCManageDatabase.sharedInstance.getTableMetadatasDirectoryFavoriteIdentifierRank(account: account)
+         listFavoriteIdentifierRank = NCManageDatabase.shared.getTableMetadatasDirectoryFavoriteIdentifierRank(account: account)
          
          // (ADD)
          for (identifier, _) in listFavoriteIdentifierRank {
              
-             guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", identifier)) else { continue }
+             guard let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "ocId == %@", identifier)) else { continue }
              guard let parentItemIdentifier = fileProviderUtility.sharedInstance.getParentItemIdentifier(metadata: metadata, homeServerUrl: homeServerUrl) else { continue }
              let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
                  
@@ -177,7 +177,7 @@ class fileProviderData: NSObject {
              
              if !listFavoriteIdentifierRank.keys.contains(identifier) {
                  
-                 guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "ocId == %@", identifier)) else { continue }
+                 guard let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "ocId == %@", identifier)) else { continue }
                  let itemIdentifier = fileProviderUtility.sharedInstance.getItemIdentifier(metadata: metadata)
                  
                  fileProviderSignalDeleteWorkingSetItemIdentifier[itemIdentifier] = itemIdentifier

+ 1 - 1
File Provider Extension/FileProviderDomain.swift

@@ -31,7 +31,7 @@ class FileProviderDomain: NSObject {
             
             var domains:[String] = []
             let pathRelativeToDocumentStorage = NSFileProviderManager.default.documentStorageURL.absoluteString
-            let accounts = NCManageDatabase.sharedInstance.getAllAccount()
+            let accounts = NCManageDatabase.shared.getAllAccount()
             
             for domain in fileProviderDomain {
                 domains.append(domain.identifier.rawValue)

+ 25 - 25
File Provider Extension/FileProviderEnumerator.swift

@@ -40,7 +40,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             
             let metadata = fileProviderUtility.shared.getTableMetadataFromItemIdentifier(enumeratedItemIdentifier)
             if metadata != nil  {
-                if let directorySource = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata!.account, metadata!.serverUrl))  {
+                if let directorySource = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata!.account, metadata!.serverUrl))  {
                     serverUrl = directorySource.serverUrl + "/" + metadata!.fileName
                 }
             }
@@ -63,19 +63,19 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             var itemIdentifierMetadata: [NSFileProviderItemIdentifier: tableMetadata] = [:]
             
             // ***** Tags *****
-            let tags = NCManageDatabase.sharedInstance.getTags(predicate: NSPredicate(format: "account == %@", fileProviderData.shared.account))
+            let tags = NCManageDatabase.shared.getTags(predicate: NSPredicate(format: "account == %@", fileProviderData.shared.account))
             for tag in tags {
                 
-                guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(tag.ocId)  else { continue }
+                guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(tag.ocId)  else { continue }
                 fileProviderUtility.shared.createocIdentifierOnFileSystem(metadata: metadata)
                 itemIdentifierMetadata[fileProviderUtility.shared.getItemIdentifier(metadata: metadata)] = metadata
             }
             
             // ***** Favorite *****
-            fileProviderData.shared.listFavoriteIdentifierRank = NCManageDatabase.sharedInstance.getTableMetadatasDirectoryFavoriteIdentifierRank(account: fileProviderData.shared.account)
+            fileProviderData.shared.listFavoriteIdentifierRank = NCManageDatabase.shared.getTableMetadatasDirectoryFavoriteIdentifierRank(account: fileProviderData.shared.account)
             for (identifier, _) in fileProviderData.shared.listFavoriteIdentifierRank {
                 
-                guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(identifier) else { continue }
+                guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(identifier) else { continue }
                 itemIdentifierMetadata[fileProviderUtility.shared.getItemIdentifier(metadata: metadata)] = metadata
             }
             
@@ -95,7 +95,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
         
         /*** ServerUrl ***/
                 
-            let paginationEndpoint = NCManageDatabase.sharedInstance.getCapabilitiesServerString(account: fileProviderData.shared.account, elements: NCElementsJSON.shared.capabilitiesPaginationEndpoint)
+            let paginationEndpoint = NCManageDatabase.shared.getCapabilitiesServerString(account: fileProviderData.shared.account, elements: NCElementsJSON.shared.capabilitiesPaginationEndpoint)
             
             guard let serverUrl = serverUrl else {
                 observer.finishEnumerating(upTo: nil)
@@ -219,7 +219,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
         
         var directoryEtag: String?
         
-        if let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl)) {
+        if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl)) {
             directoryEtag = tableDirectory.etag
         }
             
@@ -231,24 +231,24 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
                     
                     if errorCode == 0 {
                         DispatchQueue.global().async {
-                            NCManageDatabase.sharedInstance.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: true, account: account) { (metadataFolder, metadatasFolder, metadatas) in
-                                let metadatasResult = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", account, serverUrl, k_metadataStatusNormal))
-                                NCManageDatabase.sharedInstance.updateMetadatas(metadatas, metadatasResult: metadatasResult)
+                            NCManageDatabase.shared.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: true, account: account) { (metadataFolder, metadatasFolder, metadatas) in
+                                let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", account, serverUrl, k_metadataStatusNormal))
+                                NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult)
                                 for metadata in metadatasFolder {
                                     let serverUrl = metadata.serverUrl + "/" + metadata.fileNameView
-                                    NCManageDatabase.sharedInstance.addDirectory(encrypted: metadata.e2eEncrypted, favorite: metadata.favorite, ocId: metadata.ocId, fileId: metadata.fileId, etag: nil, permissions: metadata.permissions, serverUrl: serverUrl, richWorkspace: metadata.richWorkspace, account: metadata.account)
+                                    NCManageDatabase.shared.addDirectory(encrypted: metadata.e2eEncrypted, favorite: metadata.favorite, ocId: metadata.ocId, fileId: metadata.fileId, etag: nil, permissions: metadata.permissions, serverUrl: serverUrl, richWorkspace: metadata.richWorkspace, account: metadata.account)
                                 }
-                                let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
+                                let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
                                 completionHandler(metadatas)
                             }
                         }
                     } else {
-                        let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
+                        let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
                         completionHandler(metadatas)
                     }
                 }
             } else {
-                let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
+                let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
                 completionHandler(metadatas)
             }
         }
@@ -263,7 +263,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
         }
         var directoryEtag: String?
         
-        if let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl)) {
+        if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl)) {
             if page == 1 {
                 directoryEtag = tableDirectory.etag
             }
@@ -274,33 +274,33 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
             if errorCode == 0 && files.count == 1 && directoryEtag != files.first?.etag {
                 
                 if page == 1 {
-                    let metadataFolder = NCManageDatabase.sharedInstance.convertNCFileToMetadata(files[0], isEncrypted: false, account: account)
-                    NCManageDatabase.sharedInstance.addMetadata(metadataFolder)
-                    NCManageDatabase.sharedInstance.addDirectory(encrypted: metadataFolder.e2eEncrypted, favorite: metadataFolder.favorite, ocId: metadataFolder.ocId, fileId: metadataFolder.fileId, etag: metadataFolder.etag, permissions: metadataFolder.permissions, serverUrl: serverUrl, richWorkspace: metadataFolder.richWorkspace, account: metadataFolder.account)
+                    let metadataFolder = NCManageDatabase.shared.convertNCFileToMetadata(files[0], isEncrypted: false, account: account)
+                    NCManageDatabase.shared.addMetadata(metadataFolder)
+                    NCManageDatabase.shared.addDirectory(encrypted: metadataFolder.e2eEncrypted, favorite: metadataFolder.favorite, ocId: metadataFolder.ocId, fileId: metadataFolder.fileId, etag: metadataFolder.etag, permissions: metadataFolder.permissions, serverUrl: serverUrl, richWorkspace: metadataFolder.richWorkspace, account: metadataFolder.account)
                 }
                                 
                 NCCommunication.shared.iosHelper(fileNamePath: fileNamePath, serverUrl: serverUrl, offset: offset, limit: limit) { (account, files, errorCode, errorDescription) in
                      
                     if errorCode == 0 {
                         DispatchQueue.global().async {
-                            NCManageDatabase.sharedInstance.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: false, account: account) { (metadataFolder, metadatasFolder, metadatas) in
-                                let metadatasResult = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", fileProviderData.shared.account, serverUrl, k_metadataStatusNormal), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
-                                NCManageDatabase.sharedInstance.updateMetadatas(metadatas, metadatasResult: metadatasResult)
+                            NCManageDatabase.shared.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: false, account: account) { (metadataFolder, metadatasFolder, metadatas) in
+                                let metadatasResult = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", fileProviderData.shared.account, serverUrl, k_metadataStatusNormal), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
+                                NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult)
                                 for metadata in metadatasFolder {
                                     let serverUrl = metadata.serverUrl + "/" + metadata.fileNameView
-                                    NCManageDatabase.sharedInstance.addDirectory(encrypted: metadata.e2eEncrypted, favorite: metadata.favorite, ocId: metadata.ocId, fileId: metadata.fileId, etag: nil, permissions: metadata.permissions, serverUrl: serverUrl, richWorkspace: nil, account: metadata.account)
+                                    NCManageDatabase.shared.addDirectory(encrypted: metadata.e2eEncrypted, favorite: metadata.favorite, ocId: metadata.ocId, fileId: metadata.fileId, etag: nil, permissions: metadata.permissions, serverUrl: serverUrl, richWorkspace: nil, account: metadata.account)
                                 }
-                                let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
+                                let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
                                 completionHandler(metadatas)
                             }
                         }
                     } else {
-                        let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
+                        let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), page: page, limit: fileProviderData.shared.itemForPage, sorted: "fileName", ascending: true)
                         completionHandler(metadatas)
                     }
                 }
             } else {
-                let metadatas = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
+                let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.account, serverUrl), sorted: "fileName", ascending: true)
                 completionHandler(metadatas)
             }
         }

+ 20 - 20
File Provider Extension/FileProviderExtension+Actions.swift

@@ -45,12 +45,12 @@ extension FileProviderExtension {
                     if errorCode == 0 && files.count > 0 {
                         
                         let file = files.first!
-                        let metadata = NCManageDatabase.sharedInstance.convertNCFileToMetadata(file, isEncrypted: false, account: fileProviderData.shared.account)
+                        let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: false, account: fileProviderData.shared.account)
             
-                        NCManageDatabase.sharedInstance.addDirectory(encrypted: false, favorite: false, ocId: ocId!, fileId: metadata.fileId, etag: metadata.etag, permissions: metadata.permissions, serverUrl: serverUrlFileName, richWorkspace: metadata.richWorkspace, account: metadata.account)
-                        NCManageDatabase.sharedInstance.addMetadata(metadata)
+                        NCManageDatabase.shared.addDirectory(encrypted: false, favorite: false, ocId: ocId!, fileId: metadata.fileId, etag: metadata.etag, permissions: metadata.permissions, serverUrl: serverUrlFileName, richWorkspace: metadata.richWorkspace, account: metadata.account)
+                        NCManageDatabase.shared.addMetadata(metadata)
                         
-                        guard let metadataInsert = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId!) else {
+                        guard let metadataInsert = NCManageDatabase.shared.getMetadataFromOcId(ocId!) else {
                             completionHandler(nil, NSFileProviderError(.noSuchItem))
                             return
                         }
@@ -100,11 +100,11 @@ extension FileProviderExtension {
                 
                 if isDirectory {
                     let dirForDelete = CCUtility.stringAppendServerUrl(serverUrl, addFileName: fileName)
-                    NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: dirForDelete!, account: account)
+                    NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: dirForDelete!, account: account)
                 }
                 
-                NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
-                NCManageDatabase.sharedInstance.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId))
+                NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
+                NCManageDatabase.shared.deleteLocalFile(predicate: NSPredicate(format: "ocId == %@", ocId))
                 
                 completionHandler(nil)
 
@@ -142,13 +142,13 @@ extension FileProviderExtension {
             if errorCode == 0 {
                 
                 if metadataFrom.directory {
-                    NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: serverUrlFrom, account: account)
-                    NCManageDatabase.sharedInstance.renameDirectory(ocId: ocIdFrom, serverUrl: serverUrlTo)                    
+                    NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: serverUrlFrom, account: account)
+                    NCManageDatabase.shared.renameDirectory(ocId: ocIdFrom, serverUrl: serverUrlTo)                    
                 }
                 
-                NCManageDatabase.sharedInstance.moveMetadata(ocId: ocIdFrom, serverUrlTo: serverUrlTo)
+                NCManageDatabase.shared.moveMetadata(ocId: ocIdFrom, serverUrlTo: serverUrlTo)
                 
-                guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocIdFrom) else {
+                guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocIdFrom) else {
                     completionHandler(nil, NSFileProviderError(.noSuchItem))
                     return
                 }
@@ -169,7 +169,7 @@ extension FileProviderExtension {
             return
         }
         
-        guard let directoryTable = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) else {
+        guard let directoryTable = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) else {
             completionHandler(nil, NSFileProviderError(.noSuchItem))
             return
         }
@@ -184,16 +184,16 @@ extension FileProviderExtension {
             if errorCode == 0 {
                 
                 // Rename metadata
-                NCManageDatabase.sharedInstance.renameMetadata(fileNameTo: itemName, ocId: ocId)
+                NCManageDatabase.shared.renameMetadata(fileNameTo: itemName, ocId: ocId)
                 
-                guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) else {
+                guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
                     completionHandler(nil, NSFileProviderError(.noSuchItem))
                     return
                 }
                 
                 if metadata.directory {
                     
-                    NCManageDatabase.sharedInstance.setDirectory(serverUrl: fileNamePathFrom, serverUrlTo: fileNamePathTo, etag: nil, ocId: nil, fileId: nil, encrypted: directoryTable.e2eEncrypted, richWorkspace: nil, account: account)
+                    NCManageDatabase.shared.setDirectory(serverUrl: fileNamePathFrom, serverUrlTo: fileNamePathTo, etag: nil, ocId: nil, fileId: nil, encrypted: directoryTable.e2eEncrypted, richWorkspace: nil, account: account)
                     
                 } else {
                     
@@ -206,7 +206,7 @@ extension FileProviderExtension {
                     
                     _ = fileProviderUtility.shared.moveFile(CCUtility.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag), toPath: CCUtility.getDirectoryProviderStorageIconOcId(itemIdentifier.rawValue, etag: metadata.etag))
                     
-                    NCManageDatabase.sharedInstance.setLocalFile(ocId: ocId, fileName: itemName, etag: nil)
+                    NCManageDatabase.shared.setLocalFile(ocId: ocId, fileName: itemName, etag: nil)
                 }
                 
                 guard let parentItemIdentifier = fileProviderUtility.shared.getParentItemIdentifier(metadata: metadata) else {
@@ -250,7 +250,7 @@ extension FileProviderExtension {
                 
                 if errorCode == 0 {
                     
-                    guard let metadataTemp = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) else {
+                    guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
                         completionHandler(nil, NSFileProviderError(.noSuchItem))
                         return
                     }
@@ -258,14 +258,14 @@ extension FileProviderExtension {
                     
                     // Change DB
                     metadata.favorite = favorite
-                    NCManageDatabase.sharedInstance.addMetadata(metadata)
+                    NCManageDatabase.shared.addMetadata(metadata)
                     
                     let item = fileProviderData.shared.signalEnumerator(ocId: metadata.ocId)
                     completionHandler(item, nil)
                     
                 } else {
                     
-                    guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) else {
+                    guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
                         completionHandler(nil, NSFileProviderError(.noSuchItem))
                         return
                     }
@@ -290,7 +290,7 @@ extension FileProviderExtension {
         let account = metadataForTag.account
         
         // Add, Remove (nil)
-        NCManageDatabase.sharedInstance.addTag(ocId, tagIOS: tagData, account: account)
+        NCManageDatabase.shared.addTag(ocId, tagIOS: tagData, account: account)
         
         let item = fileProviderData.shared.signalEnumerator(ocId: ocId)
         completionHandler(item, nil)

+ 14 - 14
File Provider Extension/FileProviderExtension.swift

@@ -198,7 +198,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
             return
         }
         
-        let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+        let tableLocalFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         if tableLocalFile != nil && CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) && tableLocalFile?.etag == metadata.etag  {
             completionHandler(nil)
             return
@@ -208,7 +208,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileName)!
         
         // Update status
-        NCManageDatabase.sharedInstance.setMetadataStatus(ocId: metadata.ocId, status: Int(k_metadataStatusDownloading))
+        NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: Int(k_metadataStatusDownloading))
         fileProviderData.shared.signalEnumerator(ocId: metadata.ocId, update: true)
         
         NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath,  requestHandler: { (request) in
@@ -235,14 +235,14 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 metadata.date = date ?? NSDate()
                 metadata.etag = etag ?? ""
                 
-                NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
-                NCManageDatabase.sharedInstance.addMetadata(metadata)
+                NCManageDatabase.shared.addLocalFile(metadata: metadata)
+                NCManageDatabase.shared.addMetadata(metadata)
                 
                 completionHandler(nil)
                 
             } else if errorCode == 200 {
                 
-                NCManageDatabase.sharedInstance.setMetadataStatus(ocId: metadata.ocId, status: Int(k_metadataStatusNormal))
+                NCManageDatabase.shared.setMetadataStatus(ocId: metadata.ocId, status: Int(k_metadataStatusNormal))
                 
                 completionHandler(nil)
 
@@ -250,7 +250,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 
                 metadata.status = Int(k_metadataStatusDownloadError)
                 metadata.sessionError = errorDescription
-                NCManageDatabase.sharedInstance.addMetadata(metadata)
+                NCManageDatabase.shared.addMetadata(metadata)
 
                 completionHandler(NSFileProviderError(.noSuchItem))
             }
@@ -274,7 +274,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
             let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
             CCUtility.copyFile(atPath: atPath, toPath: toPath)
         }
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) else { return }
+        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else { return }
 
         let serverUrlFileName = metadata.serverUrl + "/" + fileName
         let fileNameLocalPath = url.path
@@ -349,12 +349,12 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 
                 fileURL.stopAccessingSecurityScopedResource()
                                 
-                let metadata = NCManageDatabase.sharedInstance.createMetadata(account: fileProviderData.shared.account, fileName: fileName, ocId: ocIdTemp, serverUrl: tableDirectory.serverUrl, urlBase: fileProviderData.shared.accountUrlBase, url: "", contentType: "", livePhoto: false)
+                let metadata = NCManageDatabase.shared.createMetadata(account: fileProviderData.shared.account, fileName: fileName, ocId: ocIdTemp, serverUrl: tableDirectory.serverUrl, urlBase: fileProviderData.shared.accountUrlBase, url: "", contentType: "", livePhoto: false)
                 metadata.session = NCNetworking.shared.sessionIdentifierBackgroundExtension
                 metadata.size = size
                 metadata.status = Int(k_metadataStatusUploading)
                 
-                NCManageDatabase.sharedInstance.addMetadata(metadata)
+                NCManageDatabase.shared.addMetadata(metadata)
                 
                 let serverUrlFileName = tableDirectory.serverUrl + "/" + fileName
                 let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName)!
@@ -376,7 +376,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
     func uploadComplete(fileName: String, serverUrl: String, ocId: String?, etag: String?, date: NSDate?, size: Int64, description: String?, task: URLSessionTask, errorCode: Int, errorDescription: String) {
                 
         guard let ocIdTemp = description else { return }
-        guard let metadataTemp = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocIdTemp) else { return }
+        guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocIdTemp) else { return }
         let metadata = tableMetadata.init(value: metadataTemp)
         
         let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp, fileNameView: fileName))
@@ -403,13 +403,13 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
             metadata.size = Double(size)
             metadata.status = Int(k_metadataStatusNormal)
                   
-            NCManageDatabase.sharedInstance.addMetadata(metadata)
-            NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
+            NCManageDatabase.shared.addMetadata(metadata)
+            NCManageDatabase.shared.addLocalFile(metadata: metadata)
             
             // New file
             if ocId != ocIdTemp {
             
-                NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
+                NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
                 
                 // File system
                 let atPath = CCUtility.getDirectoryProviderStorageOcId(ocIdTemp)
@@ -421,7 +421,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
             
         } else {
             
-            NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
+            NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocIdTemp))
             
             fileProviderData.shared.signalEnumerator(ocId: ocIdTemp, delete: true)
         }

+ 2 - 2
File Provider Extension/FileProviderItem.swift

@@ -79,7 +79,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
     }
     
     var tagData: Data? {
-        if let tableTag = NCManageDatabase.sharedInstance.getTag(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
+        if let tableTag = NCManageDatabase.shared.getTag(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
             return tableTag.tagIOS
         } else {
             return nil
@@ -123,7 +123,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
     }
 
     var isUploaded: Bool {
-        if NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) != nil {
+        if NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) != nil {
             return true
         } else {
             return false

+ 5 - 5
File Provider Extension/FileProviderUtility.swift

@@ -32,13 +32,13 @@ class fileProviderUtility: NSObject {
     func getAccountFromItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) -> String? {
         
         let ocId = itemIdentifier.rawValue
-        return NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId)?.account
+        return NCManageDatabase.shared.getMetadataFromOcId(ocId)?.account
     }
     
     func getTableMetadataFromItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) -> tableMetadata? {
         
         let ocId = itemIdentifier.rawValue
-        return NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId)
+        return NCManageDatabase.shared.getMetadataFromOcId(ocId)
     }
 
     func getItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier {
@@ -60,12 +60,12 @@ class fileProviderUtility: NSObject {
     func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier? {
         
         let homeServerUrl = NCUtility.shared.getHomeServer(urlBase: metadata.urlBase, account: metadata.account)
-        if let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl))  {
+        if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl))  {
             if directory.serverUrl == homeServerUrl {
                 return NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue)
             } else {
                 // get the metadata.ocId of parent Directory
-                if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(directory.ocId) {
+                if let metadata = NCManageDatabase.shared.getMetadataFromOcId(directory.ocId) {
                     let identifier = getItemIdentifier(metadata: metadata)
                     return identifier
                 }
@@ -89,7 +89,7 @@ class fileProviderUtility: NSObject {
             predicate = NSPredicate(format: "ocId == %@", metadata.ocId)
         }
         
-        guard let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: predicate) else { return nil }
+        guard let directory = NCManageDatabase.shared.getTableDirectory(predicate: predicate) else { return nil }
         
         return directory
     }

+ 0 - 19
Libraries external/PKDownloadButton/CALayer+PKDownloadButtonAnimations.h

@@ -1,19 +0,0 @@
-//
-//  CALayer+PKDownloadButtonAnimations.h
-//  Download
-//
-//  Created by Pavel on 31/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <QuartzCore/QuartzCore.h>
-
-@interface CALayer (PKDownloadButtonAnimations)
-
-- (void)addRotationAnimationWithKey:(NSString *)animationKey
-               fullRotationDuration:(NSTimeInterval)fullRotationDuration;
-- (void)removeRotationAnimationWithKey:(NSString *)animationKey;
-- (void)removeRotationAnimationWithKey:(NSString *)animationKey
-                  fullRotationDuration:(NSTimeInterval)fullRotationDuration;
-
-@end

+ 0 - 60
Libraries external/PKDownloadButton/CALayer+PKDownloadButtonAnimations.m

@@ -1,60 +0,0 @@
-//
-//  CALayer+PKDownloadButtonAnimations.m
-//  Download
-//
-//  Created by Pavel on 31/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "CALayer+PKDownloadButtonAnimations.h"
-
-static NSString *kRorationEndKey = @"PKLayerRorationEndKey";
-
-@implementation CALayer (PKDownloadButtonAnimations)
-
-- (void)addRotationAnimationWithKey:(NSString *)animationKey fullRotationDuration:(NSTimeInterval)fullRotationDuration {
-    NSNumber *fromValue = [self.presentationLayer valueForKeyPath:@"transform.rotation"];
-    [self removeAnimationForKey:kRorationEndKey];
-    
-    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
-    rotationAnimation.fromValue = fromValue;
-    rotationAnimation.toValue = @([rotationAnimation.fromValue floatValue] + (2. * M_PI));
-    rotationAnimation.duration = fullRotationDuration;
-    rotationAnimation.repeatCount = HUGE_VALF;
-    rotationAnimation.removedOnCompletion = NO;
-    
-    [self addAnimation:rotationAnimation forKey:animationKey];
-}
-
-- (void)removeRotationAnimationWithKey:(NSString *)animationKey {
-    [self removeRotationAnimationWithKey:animationKey fullRotationDuration:0.0];
-}
-
-- (void)removeRotationAnimationWithKey:(NSString *)animationKey fullRotationDuration:(NSTimeInterval)fullRotationDuration {
-    NSNumber *fromValue = [self.presentationLayer valueForKeyPath:@"transform.rotation"];
-    NSNumber *toValue = @((fromValue.doubleValue < 0.0) ? 0.0 : 2.0 * M_PI);
-    
-    [self removeAnimationForKey:animationKey];
-    
-    const NSTimeInterval animationDuration = ABS(toValue.doubleValue - fromValue.doubleValue) * (fullRotationDuration / (2.0 * M_PI));
-    
-    if (fromValue.doubleValue != 0.0 && ![fromValue isEqualToNumber:toValue] && animationDuration > 0.0) {
-        [CATransaction begin];
-        CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
-        rotationAnimation.fromValue = fromValue;
-        rotationAnimation.toValue = toValue;
-        rotationAnimation.duration = animationDuration;
-        
-        [CATransaction setCompletionBlock:^{
-            [self removeAnimationForKey:kRorationEndKey];
-        }];
-        
-        [self addAnimation:rotationAnimation forKey:kRorationEndKey];
-        [CATransaction commit];
-    }
-    else {
-        [self removeAnimationForKey:kRorationEndKey];
-    }
-}
-
-@end

+ 0 - 18
Libraries external/PKDownloadButton/NSLayoutConstraint+PKDownloadButton.h

@@ -1,18 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface NSLayoutConstraint (PKDownloadButton)
-
-+ (NSArray *)constraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets;
-+ (NSArray *)horizontalConstraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets;
-+ (NSArray *)verticalConstraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets;
-+ (NSLayoutConstraint *)constraintForView:(UIView *)view withWidth:(CGFloat)width;
-+ (NSLayoutConstraint *)constraintForView:(UIView *)view withHeight:(CGFloat)height;
-+ (NSArray *)constraintsForView:(UIView *)view withSize:(CGSize)size;
-+ (NSArray *)constraintsWithVisualFormat:(NSString *)format views:(NSDictionary *)views;
-+ (NSLayoutConstraint *)constraintForCenterByYView:(UIView *)overlay withView:(UIView *)view;
-+ (NSLayoutConstraint *)constraintForCenterByXView:(UIView *)overlay withView:(UIView *)view;
-// Constraints for center view above it's superview
-+ (NSArray *)constraintsForCenterView:(UIView *)overlay;
-+ (NSArray *)constraintsForCenterView:(UIView *)overlay withView:(UIView *)view;
-
-@end

+ 0 - 99
Libraries external/PKDownloadButton/NSLayoutConstraint+PKDownloadButton.m

@@ -1,99 +0,0 @@
-#import "NSLayoutConstraint+PKDownloadButton.h"
-
-@implementation NSLayoutConstraint (PKDownloadButton)
-
-+ (NSArray *)constraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets {
-    NSArray *horizontalConstraints = [self horizontalConstraintsForWrappedSubview:view withInsets:insets];
-    NSArray *verticalConstraints = [self verticalConstraintsForWrappedSubview:view withInsets:insets];
-    NSMutableArray *resultArray = [NSMutableArray arrayWithCapacity:[horizontalConstraints count] + [verticalConstraints count]];
-    [resultArray addObjectsFromArray:horizontalConstraints];
-    [resultArray addObjectsFromArray:verticalConstraints];
-    return resultArray;
-}
-
-+ (NSArray *)horizontalConstraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets {
-    NSString *horizontalConstraintsFormat = [NSString stringWithFormat:@"H:|-(%d)-[view]-(%d)-|",
-                                             (int)insets.left,
-                                             (int)roundf(insets.right)];
-    NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:horizontalConstraintsFormat
-                                                                             options:0
-                                                                             metrics:nil
-                                                                               views:NSDictionaryOfVariableBindings(view)];
-    return horizontalConstraints;
-}
-
-+ (NSArray *)verticalConstraintsForWrappedSubview:(UIView *)view withInsets:(UIEdgeInsets)insets {
-    NSString *verticalConstraintsFormat = [NSString stringWithFormat:@"V:|-(%d)-[view]-(%d)-|", (int)insets.top, (int)insets.bottom];
-    NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:verticalConstraintsFormat
-                                                                           options:0
-                                                                           metrics:nil
-                                                                             views:NSDictionaryOfVariableBindings(view)];
-    return verticalConstraints;
-}
-
-+ (NSLayoutConstraint *)constraintForView:(UIView *)view withWidth:(CGFloat)width {
-    return [NSLayoutConstraint constraintWithItem:view
-                                        attribute:NSLayoutAttributeWidth
-                                        relatedBy:NSLayoutRelationEqual
-                                           toItem:nil
-                                        attribute:NSLayoutAttributeNotAnAttribute
-                                       multiplier:1.0
-                                         constant:width];
-}
-
-+ (NSLayoutConstraint *)constraintForView:(UIView *)view withHeight:(CGFloat)height {
-    return [NSLayoutConstraint constraintWithItem:view
-                                        attribute:NSLayoutAttributeHeight
-                                        relatedBy:NSLayoutRelationEqual
-                                           toItem:nil
-                                        attribute:NSLayoutAttributeNotAnAttribute
-                                       multiplier:1.0
-                                         constant:height];
-}
-
-+ (NSArray *)constraintsForView:(UIView *)view withSize:(CGSize)size {
-    NSLayoutConstraint *width = [NSLayoutConstraint constraintForView:view
-                                                            withWidth:size.width];
-    NSLayoutConstraint *height = [NSLayoutConstraint constraintForView:view
-                                                             withHeight:size.height];
-    return @[width, height];
-}
-
-+ (NSArray *)constraintsWithVisualFormat:(NSString *)format views:(NSDictionary *)views {
-    return [self constraintsWithVisualFormat:format options:0 metrics:nil views:views];
-}
-
-+ (NSLayoutConstraint *)constraintForCenterByXView:(UIView *)overlay withView:(UIView *)view {
-    return [NSLayoutConstraint constraintWithItem:overlay
-                                          attribute:NSLayoutAttributeCenterX
-                                          relatedBy:NSLayoutRelationEqual
-                                             toItem:view
-                                          attribute:NSLayoutAttributeCenterX
-                                         multiplier:1.0
-                                           constant:0.0];
-}
-
-+ (NSLayoutConstraint *)constraintForCenterByYView:(UIView *)overlay withView:(UIView *)view {
-    return [NSLayoutConstraint constraintWithItem:overlay
-                                          attribute:NSLayoutAttributeCenterY
-                                          relatedBy:NSLayoutRelationEqual
-                                             toItem:view
-                                          attribute:NSLayoutAttributeCenterY
-                                         multiplier:1.0
-                                           constant:0.0];
-}
-
-+ (NSArray *)constraintsForCenterView:(UIView *)overlay {
-    return [self constraintsForCenterView:overlay withView:overlay.superview];
-}
-
-+ (NSArray *)constraintsForCenterView:(UIView *)overlay withView:(UIView *)view {
-    NSMutableArray *constraints = [NSMutableArray array];
-    
-    [constraints addObject:[self constraintForCenterByXView:overlay withView:view]];
-    [constraints addObject:[self constraintForCenterByYView:overlay withView:view]];
-    
-    return constraints;
-}
-
-@end

+ 0 - 20
Libraries external/PKDownloadButton/PKBorderedButton.h

@@ -1,20 +0,0 @@
-//
-//  PKBorderedButton.h
-//  Pods
-//
-//  Created by Holden, Ryan on 2/7/16.
-//
-//
-
-#import <UIKit/UIKit.h>
-
-@interface PKBorderedButton : UIButton
-
-@property (nonatomic) CGFloat cornerRadius;
-@property (nonatomic) CGFloat lineWidth;
-
-- (void)configureDefaultAppearance;
-
-- (void)cleanDefaultAppearance;
-
-@end

+ 0 - 49
Libraries external/PKDownloadButton/PKBorderedButton.m

@@ -1,49 +0,0 @@
-//
-//  PKBorderedButton.m
-//  Pods
-//
-//  Created by Holden, Ryan on 2/7/16.
-//
-//
-
-#import "PKBorderedButton.h"
-#import "UIImage+PKDownloadButton.h"
-
-@implementation PKBorderedButton
-
-- (void)setCornerRadius:(CGFloat)cornerRadius {
-    _cornerRadius = cornerRadius;
-    [self updateBackgroundImage];
-}
-
-- (void)setLineWidth:(CGFloat)lineWidth {
-    _lineWidth = lineWidth;
-    [self updateBackgroundImage];
-}
-
-- (void)configureDefaultAppearance {
-    [self setCornerRadius:4];
-    [self setLineWidth:1];
-}
-
-- (void)updateBackgroundImage {
-    [self setBackgroundImage:[UIImage borderedImageWithFill:nil radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
-                    forState:UIControlStateNormal];
-
-    [self setBackgroundImage:[UIImage borderedImageWithFill:self.tintColor radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
-                    forState:UIControlStateHighlighted];
-}
-
-- (void)tintColorDidChange {
-    [super tintColorDidChange];
-    [self updateBackgroundImage];
-}
-
-- (void)cleanDefaultAppearance {
-    [self setBackgroundImage:nil forState:UIControlStateNormal];
-    [self setBackgroundImage:nil forState:UIControlStateHighlighted];
-    [self setAttributedTitle:nil forState:UIControlStateNormal];
-    [self setAttributedTitle:nil forState:UIControlStateHighlighted];
-}
-
-@end

+ 0 - 20
Libraries external/PKDownloadButton/PKCircleProgressView.h

@@ -1,20 +0,0 @@
-//
-//  PKCircleProgressView.h
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-IB_DESIGNABLE
-@interface PKCircleProgressView : UIView
-
-@property (nonatomic, assign) IBInspectable CGFloat progress; /// 0.f - 1.0f
-@property (nonatomic, assign) IBInspectable CGFloat filledLineWidth; /// 0.f +
-@property (nonatomic, assign) IBInspectable CGFloat emptyLineWidth; /// 0.f +
-@property (nonatomic, assign) IBInspectable CGFloat radius; /// 0.f +
-@property (nonatomic, assign) IBInspectable BOOL filledLineStyleOuter;
-
-@end

+ 0 - 180
Libraries external/PKDownloadButton/PKCircleProgressView.m

@@ -1,180 +0,0 @@
-//
-//  PKCircleProgressView.m
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "PKCircleProgressView.h"
-#import "PKCircleView.h"
-#import "NSLayoutConstraint+PKDownloadButton.h"
-
-static const CGFloat kDefaultRaduis = 13.f;
-static const CGFloat kDefaultFilledLineWidth = 3.f;
-static const CGFloat kDefaultEmptyLineWidth = 1.f;
-static const CGFloat kStartAngle = M_PI * 1.5;
-
-@interface PKCircleProgressView ()
-
-@property (nonatomic, assign) CGFloat startAngle;
-@property (nonatomic, assign) CGFloat endAngle;
-
-@property (nonatomic, weak) PKCircleView *emptyLineCircleView;
-@property (nonatomic, weak) PKCircleView *filledLineCircleView;
-
-@property (nonatomic, weak) NSLayoutConstraint *emptyLineCircleWidth;
-@property (nonatomic, weak) NSLayoutConstraint *emptyLineCircleHeight;
-
-@property (nonatomic, weak) NSLayoutConstraint *filledLineCircleWidth;
-@property (nonatomic, weak) NSLayoutConstraint *filledLineCircleHeight;
-
-@property (nonatomic, assign) CGFloat emptyLineCircleSize;
-@property (nonatomic, assign) CGFloat filledLineCircleSize;
-
-- (PKCircleView *)createEmptyLineCircleView;
-- (PKCircleView *)createFilledLineCircleView;
-
-- (NSArray *)createCircleConstraints;
-
-@end
-
-static PKCircleProgressView *CommonInit(PKCircleProgressView *self) {
-    if (self != nil) {
-        self.backgroundColor = [UIColor clearColor];
-        self.startAngle = kStartAngle;
-        self.endAngle = self.startAngle + (M_PI * 2);
-        self.clipsToBounds = NO;
-        
-        PKCircleView *emptyLineCircleView = [self createEmptyLineCircleView];
-        self.emptyLineCircleView = emptyLineCircleView;
-        emptyLineCircleView.translatesAutoresizingMaskIntoConstraints = NO;
-        [self addSubview:emptyLineCircleView];
-        
-        PKCircleView *filledLineCircleView = [self createFilledLineCircleView];
-        self.filledLineCircleView = filledLineCircleView;
-        filledLineCircleView.translatesAutoresizingMaskIntoConstraints = NO;
-        [self addSubview:filledLineCircleView];
-        
-        [self addConstraints:[self createCircleConstraints]];
-        
-        self.emptyLineWidth = kDefaultEmptyLineWidth;
-        self.filledLineWidth = kDefaultFilledLineWidth;
-        self.radius = kDefaultRaduis;
-    }
-    return self;
-}
-
-@implementation PKCircleProgressView
-
-#pragma mark - initilaization / deallocation
-
-- (id)initWithCoder:(NSCoder *)decoder {
-    return CommonInit([super initWithCoder:decoder]);
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
-    return CommonInit([super initWithFrame:frame]);
-}
-
-#pragma mark - properties
-
-- (void)setEmptyLineCircleSize:(CGFloat)emptyLineCircleSize {
-    self.emptyLineCircleWidth.constant = emptyLineCircleSize;
-    self.emptyLineCircleHeight.constant = emptyLineCircleSize;
-}
-
-- (void)setFilledLineCircleSize:(CGFloat)filledLineCircleSize {
-    self.filledLineCircleWidth.constant = filledLineCircleSize;
-    self.filledLineCircleHeight.constant = filledLineCircleSize;
-}
-
-- (void)setProgress:(CGFloat)progress {
-    _progress = progress;
-    self.filledLineCircleView.startAngleRadians = self.startAngle;
-    self.filledLineCircleView.endAngleRadians = (self.endAngle - self.startAngle) * progress + self.startAngle;
-    
-    [self setNeedsDisplay];
-}
-
-- (void)setFilledLineWidth:(CGFloat)filledLineWidth {
-    _filledLineWidth = filledLineWidth;
-    self.filledLineCircleView.lineWidth = filledLineWidth;
-    [self setNeedsUpdateConstraints];
-}
-
-- (void)setEmptyLineWidth:(CGFloat)emptyLineWidth {
-    _emptyLineWidth = emptyLineWidth;
-    self.emptyLineCircleView.lineWidth = emptyLineWidth;
-    [self setNeedsUpdateConstraints];
-}
-
-- (void)setRadius:(CGFloat)radius {
-    _radius = radius;
-    [self setNeedsUpdateConstraints];
-}
-
-- (void)setFilledLineStyleOuter:(BOOL)filledLineStyleOuter {
-    _filledLineStyleOuter = filledLineStyleOuter;
-    [self setNeedsUpdateConstraints];
-}
-
-#pragma mark - UIView
-
-- (void)updateConstraints {
-    [super updateConstraints];
-    self.emptyLineCircleSize = self.radius * 2.f;
-    CGFloat deltaRaduis = 0.f;
-    if (self.filledLineStyleOuter) {
-        deltaRaduis = - self.emptyLineCircleView.lineWidth / 2.f + self.filledLineCircleView.lineWidth;
-    }
-    else {
-        deltaRaduis = - self.emptyLineCircleView.lineWidth / 2.f;
-    }
-    self.filledLineCircleSize = self.radius * 2.f + deltaRaduis * 2.f;
-}
-
-#pragma mark - private methods
-
-- (PKCircleView *)createEmptyLineCircleView {
-    PKCircleView *emptyCircelView = [[PKCircleView alloc] init];
-    
-    NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintForView:emptyCircelView
-                                                                      withWidth:0.f];
-    self.emptyLineCircleWidth = widthConstraint;
-    [emptyCircelView addConstraint:widthConstraint];
-    
-    NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintForView:emptyCircelView
-                                                                      withHeight:0.f];
-    self.emptyLineCircleHeight = heightConstraint;
-    [emptyCircelView addConstraint:heightConstraint];
-    
-    return emptyCircelView;
-}
-
-- (PKCircleView *)createFilledLineCircleView {
-    PKCircleView *filledCircelView = [[PKCircleView alloc] init];
-    
-    NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintForView:filledCircelView
-                                                                      withWidth:0.f];
-    self.filledLineCircleWidth = widthConstraint;
-    [filledCircelView addConstraint:widthConstraint];
-    
-    NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintForView:filledCircelView
-                                                                      withHeight:0.f];
-    self.filledLineCircleHeight = heightConstraint;
-    [filledCircelView addConstraint:heightConstraint];
-    
-    return filledCircelView;
-}
-
-- (NSArray *)createCircleConstraints {
-    NSMutableArray *constraints = [NSMutableArray array];
-    [constraints addObjectsFromArray:[NSLayoutConstraint constraintsForCenterView:self.emptyLineCircleView
-                                                                         withView:self]];
-    [constraints addObjectsFromArray:[NSLayoutConstraint constraintsForWrappedSubview:self.filledLineCircleView
-                                                                           withInsets:UIEdgeInsetsZero]];
-    return constraints;
-}
-
-@end

+ 0 - 18
Libraries external/PKDownloadButton/PKCircleView.h

@@ -1,18 +0,0 @@
-//
-//  PKCircleView.h
-//  Download
-//
-//  Created by Pavel on 30/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-IB_DESIGNABLE
-@interface PKCircleView : UIView
-
-@property (nonatomic, assign) IBInspectable CGFloat startAngleRadians;
-@property (nonatomic, assign) IBInspectable CGFloat endAngleRadians;
-@property (nonatomic, assign) IBInspectable CGFloat lineWidth;
-
-@end

+ 0 - 91
Libraries external/PKDownloadButton/PKCircleView.m

@@ -1,91 +0,0 @@
-//
-//  PKCircleView.m
-//  Download
-//
-//  Created by Pavel on 30/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "PKCircleView.h"
-
-static const CGFloat kDefaultLineWidth = 1.f;
-
-@interface PKCircleView ()
-
-- (void)drawCircleRadius:(CGFloat)radius
-                    rect:(CGRect)rect
-              startAngle:(CGFloat)startAngle
-                endAngle:(CGFloat)endAngel
-               lineWidth:(CGFloat)lineWidth;
-
-@end
-
-static PKCircleView *CommonInit(PKCircleView *self) {
-    if (self != nil) {
-        self.backgroundColor = [UIColor clearColor];
-        self.startAngleRadians = M_PI * 1.5;
-        self.endAngleRadians = self.startAngleRadians + (M_PI * 2);
-        self.lineWidth = kDefaultLineWidth;
-    }
-    return self;
-}
-
-@implementation PKCircleView
-
-#pragma mark - initialization
-
-- (id)initWithCoder:(NSCoder *)decoder {
-    return CommonInit([super initWithCoder:decoder]);
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
-    return CommonInit([super initWithFrame:frame]);
-}
-
-#pragma mark - properties
-
-- (void)setLineWidth:(CGFloat)lineWidth {
-    _lineWidth = lineWidth;
-    [self setNeedsDisplay];
-}
-
-- (void)setStartAngleRadians:(CGFloat)startAngleRadians {
-    _startAngleRadians = startAngleRadians;
-    [self setNeedsDisplay];
-}
-
-- (void)setEndAngleRadians:(CGFloat)endAngleRadians {
-    _endAngleRadians = endAngleRadians;
-    [self setNeedsDisplay];
-}
-
-#pragma mark - UIView
-
-- (void)drawRect:(CGRect)rect {
-    [self drawCircleRadius:MIN(rect.size.width / 2, rect.size.height / 2) - self.lineWidth / 2.f
-                      rect:rect
-                startAngle:self.startAngleRadians
-                  endAngle:self.endAngleRadians
-                 lineWidth:self.lineWidth];
-}
-
-#pragma mark - private methods
-
-- (void)drawCircleRadius:(CGFloat)radius
-                    rect:(CGRect)rect
-              startAngle:(CGFloat)startAngle
-                endAngle:(CGFloat)endAngel
-               lineWidth:(CGFloat)lineWidth {
-    UIBezierPath* bezierPath = [UIBezierPath bezierPath];
-    [self.tintColor setStroke];
-    [bezierPath addArcWithCenter:CGPointMake(rect.size.width / 2, rect.size.height / 2)
-                          radius:radius
-                      startAngle:startAngle
-                        endAngle:endAngel
-                       clockwise:YES];
-    
-    bezierPath.lineWidth = lineWidth;
-    [bezierPath stroke];
-}
-
-@end

+ 0 - 52
Libraries external/PKDownloadButton/PKDownloadButton.h

@@ -1,52 +0,0 @@
-//
-//  PKDownloadButton.h
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-#import "PKStopDownloadButton.h"
-#import "PKBorderedButton.h"
-#import "PKCircleProgressView.h"
-#import "PKPendingView.h"
-
-typedef NS_ENUM(NSUInteger, PKDownloadButtonState) {
-    kPKDownloadButtonState_StartDownload,
-    kPKDownloadButtonState_Pending,
-    kPKDownloadButtonState_Downloading,
-    kPKDownloadButtonState_Downloaded
-};
-
-@class PKDownloadButton;
-
-typedef void(^DownloadButtonTappedCallback)(PKDownloadButton *downloadButton, PKDownloadButtonState state);
-
-@protocol PKDownloadButtonDelegate <NSObject>
-
-- (void)downloadButtonTapped:(PKDownloadButton *)downloadButton
-                currentState:(PKDownloadButtonState)state;
-
-@end
-
-IB_DESIGNABLE
-@interface PKDownloadButton : UIView
-
-@property (nonatomic, weak) IBOutlet id <PKDownloadButtonDelegate> delegate;
-@property (nonatomic, copy) DownloadButtonTappedCallback callback;
-
-@property (nonatomic, weak, readonly) PKBorderedButton *startDownloadButton;
-@property (nonatomic, weak, readonly) PKStopDownloadButton *stopDownloadButton;
-@property (nonatomic, weak, readonly) PKBorderedButton *downloadedButton;
-@property (nonatomic, weak, readonly) PKPendingView *pendingView;
-
-@property (nonatomic, assign) PKDownloadButtonState state;
-
--(void)updateStartDownloadButtonText:(NSString *)title;
--(void)updateDownloadedButtonText:(NSString *)title;
--(void)updateStartDownloadButtonText:(NSString *)title font:(UIFont *)font;
--(void)updateDownloadedButtonText:(NSString *)title font:(UIFont *)font;
-
-@end

+ 0 - 219
Libraries external/PKDownloadButton/PKDownloadButton.m

@@ -1,219 +0,0 @@
-//
-//  PKDownloadButton.m
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "PKDownloadButton.h"
-#import "PKMacros.h"
-#import "NSLayoutConstraint+PKDownloadButton.h"
-#import "UIImage+PKDownloadButton.h"
-#import "PKPendingView.h"
-
-@interface PKDownloadButton ()
-
-@property (nonatomic, weak) PKBorderedButton *startDownloadButton;
-@property (nonatomic, weak) PKStopDownloadButton *stopDownloadButton;
-@property (nonatomic, weak) PKBorderedButton *downloadedButton;
-@property (nonatomic, weak) PKPendingView *pendingView;
-
-@property (nonatomic, strong) NSMutableArray *stateViews;
-
-- (PKBorderedButton *)createStartDownloadButton;
-- (PKStopDownloadButton *)createStopDownloadButton;
-- (PKBorderedButton *)createDownloadedButton;
-- (PKPendingView *)createPendingView;
-
-- (void)currentButtonTapped:(id)sender;
-
-- (void)createSubviews;
-- (NSArray *)createConstraints;
-
-@end
-
-static PKDownloadButton *CommonInit(PKDownloadButton *self) {
-    if (self != nil) {
-        [self createSubviews];
-        [self addConstraints:[self createConstraints]];
-        
-        self.state = kPKDownloadButtonState_StartDownload;
-        self.backgroundColor = [UIColor clearColor];
-    }
-    return self;
-}
-
-@implementation PKDownloadButton
-
-#pragma mark - Properties
-
-- (void)setState:(PKDownloadButtonState)state {
-    _state = state;
-    
-    [self.stateViews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
-        SafeObjClassCast(UIView, view, obj);
-        view.hidden = YES;
-    }];
-    
-    switch (state) {
-        case kPKDownloadButtonState_StartDownload:
-            self.startDownloadButton.hidden = NO;
-            break;
-        case kPKDownloadButtonState_Pending:
-            self.pendingView.hidden = NO;
-            [self.pendingView startSpin];
-            break;
-        case kPKDownloadButtonState_Downloading:
-            self.stopDownloadButton.hidden = NO;
-            self.stopDownloadButton.progress = 0.f;
-            break;
-        case kPKDownloadButtonState_Downloaded:
-            self.downloadedButton.hidden = NO;
-            break;
-        default:
-            NSAssert(NO, @"unsupported state");
-            break;
-    }
-}
-
-#pragma mark - Initialization
-
-- (id)initWithCoder:(NSCoder *)decoder {
-    return CommonInit([super initWithCoder:decoder]);
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
-    return CommonInit([super initWithFrame:frame]);
-}
-
-- (void)tintColorDidChange {
-	[super tintColorDidChange];
-	
-    [self updateButton:self.startDownloadButton title:[self.startDownloadButton titleForState:UIControlStateNormal] font:self.startDownloadButton.titleLabel.font];
-	[self updateButton:self.downloadedButton title:[self.downloadedButton titleForState:UIControlStateNormal] font:self.downloadedButton.titleLabel.font];
-}
-
-
-#pragma mark - appearance
-
--(void)updateStartDownloadButtonText:(NSString *)title {
-    [self updateButton:self.startDownloadButton title:title];
-}
-
--(void)updateDownloadedButtonText:(NSString *)title {
-    [self updateButton:self.downloadedButton title:title];
-}
-
-
--(void)updateStartDownloadButtonText:(NSString *)title font:(UIFont *)font {
-    [self updateButton:self.startDownloadButton title:title font: font];
-}
-
--(void)updateDownloadedButtonText:(NSString *)title font:(UIFont *)font {
-    [self updateButton:self.downloadedButton title:title font: font];
-}
-
-
-- (void)updateButton:(UIButton *)button title:(NSString *)title {
-    [self updateButton:button title:title font:[UIFont systemFontOfSize:14.f]];
-}
-
-- (void)updateButton:(UIButton *)button title:(NSString *)title font:(UIFont *)font {
-    if (title == nil) {
-        title = @"";
-    }
-    
-    [button setTitle:title forState:UIControlStateNormal];
-    [button setTitleColor:self.tintColor forState:UIControlStateNormal];
-    [button setTitleColor:UIColor.whiteColor forState:UIControlStateHighlighted];
-    
-    button.titleLabel.font = font;
-}
-
-#pragma mark - private methods
-
-- (PKBorderedButton *)createStartDownloadButton {
-    PKBorderedButton *startDownloadButton = [PKBorderedButton buttonWithType:UIButtonTypeCustom];
-    [startDownloadButton configureDefaultAppearance];
-    
-	[self updateButton:startDownloadButton title:@"DOWNLOAD"];
-	
-    [startDownloadButton addTarget:self
-                            action:@selector(currentButtonTapped:)
-                  forControlEvents:UIControlEventTouchUpInside];
-    return startDownloadButton;
-}
-
-- (PKStopDownloadButton *)createStopDownloadButton {
-    PKStopDownloadButton *stopDownloadButton = [[PKStopDownloadButton alloc] init];
-    [stopDownloadButton.stopButton addTarget:self action:@selector(currentButtonTapped:)
-                            forControlEvents:UIControlEventTouchUpInside];
-    return stopDownloadButton;
-}
-
-- (PKBorderedButton *)createDownloadedButton {
-    PKBorderedButton *downloadedButton = [PKBorderedButton buttonWithType:UIButtonTypeCustom];
-    [downloadedButton configureDefaultAppearance];
-
-	[self updateButton:downloadedButton title:@"REMOVE"];
-    
-    [downloadedButton addTarget:self
-                         action:@selector(currentButtonTapped:)
-               forControlEvents:UIControlEventTouchUpInside];
-    return downloadedButton;
-}
-
-- (PKPendingView *)createPendingView {
-    PKPendingView *pendingView = [[PKPendingView alloc] init];
-    [pendingView addTarget:self action:@selector(currentButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
-    return pendingView;
-}
-
-- (void)currentButtonTapped:(id)sender {
-    [self.delegate downloadButtonTapped:self currentState:self.state];
-    BlockSafeRun(self.callback, self, self.state);
-}
-
-- (void)createSubviews {
-    self.stateViews = (__bridge_transfer NSMutableArray *)CFArrayCreateMutable(nil, 0, nil);
-    
-    PKBorderedButton *startDownloadButton = [self createStartDownloadButton];
-    startDownloadButton.translatesAutoresizingMaskIntoConstraints = NO;
-    [self addSubview:startDownloadButton];
-    self.startDownloadButton = startDownloadButton;
-    [self.stateViews addObject:startDownloadButton];
-    
-    PKStopDownloadButton *stopDownloadButton = [self createStopDownloadButton];
-    stopDownloadButton.translatesAutoresizingMaskIntoConstraints = NO;
-    [self addSubview:stopDownloadButton];
-    self.stopDownloadButton = stopDownloadButton;
-    [self.stateViews addObject:stopDownloadButton];
-    
-    PKBorderedButton *downloadedButton = [self createDownloadedButton];
-    downloadedButton.translatesAutoresizingMaskIntoConstraints = NO;
-    [self addSubview:downloadedButton];
-    self.downloadedButton = downloadedButton;
-    [self.stateViews addObject:downloadedButton];
-    
-    PKPendingView *pendingView = [self createPendingView];
-    pendingView.translatesAutoresizingMaskIntoConstraints = NO;
-    [self addSubview:pendingView];
-    self.pendingView = pendingView;
-    [self.stateViews addObject:pendingView];
-}
-
-- (NSArray *)createConstraints {
-    NSMutableArray *constraints = [NSMutableArray array];
-    
-    [self.stateViews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
-        SafeObjClassCast(UIView, view, obj);
-        [constraints addObjectsFromArray:[NSLayoutConstraint constraintsForWrappedSubview:view
-                                                                               withInsets:UIEdgeInsetsZero]];
-    }];
-    
-    return constraints;
-}
-
-@end
-

+ 0 - 42
Libraries external/PKDownloadButton/PKMacros.h

@@ -1,42 +0,0 @@
-//
-//  PKMacros.h
-//  Download
-//
-//  Created by Pavel on 30/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#ifndef Download_PKMacros_h
-#define Download_PKMacros_h
-
-#pragma mark - Block helpers
-
-#define BlockSafeRun(block_, ...) do { if ((block_) != NULL) (block_)(__VA_ARGS__); } while (NO)
-#define BlockSafeRunEx(defaultValue_, block_, ...) (((block_) != NULL) ? (block_)(__VA_ARGS__) : (defaultValue_))
-#define BlockSafeRunOnTargetQueue(queue, block, ...) do { if ((block) != NULL) dispatch_async(queue, ^{ (block)(__VA_ARGS__); }); } while (0)
-#define BlockSafeRunOnMainQueue(block, ...) BlockSafeRunOnTargetQueue(dispatch_get_main_queue(), (block), __VA_ARGS__)
-
-#if __has_feature(objc_arc)
-#define BlockWeakObject(o) __typeof__(o) __weak
-#define BlockWeakSelf BlockWeakObject(self)
-#define BlockStrongObject(o) __typeof__(o) __strong
-#define BlockStrongSelf BlockStrongObject(self)
-#define WeakifySelf BlockWeakSelf ___weakSelf___ = self; do {} while (0)
-#define StrongifySelf BlockStrongSelf self = ___weakSelf___; do {} while (0)
-
-#endif // __has_feature(objc_arc)
-
-#define SafeObjClassCast(destClass_, resultObj_, originalObj_) \
-destClass_ *resultObj_ = (destClass_ *)originalObj_;\
-NSAssert2((resultObj_) == nil || [(resultObj_) isKindOfClass:[destClass_ class]],\
-@"Incorrect cast: original object (%@) could not be casted to the destination class (%@)", \
-(originalObj_), NSStringFromClass([destClass_ class]))
-
-#define SafeObjProtocolCast(destProtocol_, resultObj_, originalObj_) \
-id <destProtocol_> resultObj_ = (id <destProtocol_>)originalObj_;\
-NSAssert2((resultObj_) == nil || [(resultObj_) conformsToProtocol:@protocol(destProtocol_)],\
-@"Incorrect cast: original object (%@) could not be casted to the destination protocol (%@)", \
-(originalObj_), NSStringFromProtocol(@protocol(destProtocol_)))
-
-
-#endif // Download_PKMacros_h

+ 0 - 25
Libraries external/PKDownloadButton/PKPendingView.h

@@ -1,25 +0,0 @@
-//
-//  PKPendingView.h
-//  Download
-//
-//  Created by Pavel on 30/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import "PKCircleView.h"
-
-IB_DESIGNABLE
-@interface PKPendingView : UIControl
-
-@property (nonatomic, weak, readonly) PKCircleView *circleView;
-
-@property (nonatomic, assign) IBInspectable CGFloat radius;
-@property (nonatomic, assign) IBInspectable CGFloat lineWidth;
-@property (nonatomic, assign) IBInspectable CGFloat emptyLineRadians;
-@property (nonatomic, assign) IBInspectable CGFloat spinTime;
-
-- (void)startSpin;
-- (void)stopSpin;
-
-@end

+ 0 - 134
Libraries external/PKDownloadButton/PKPendingView.m

@@ -1,134 +0,0 @@
-//
-//  PKPendingView.m
-//  Download
-//
-//  Created by Pavel on 30/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "PKPendingView.h"
-#import "NSLayoutConstraint+PKDownloadButton.h"
-#import "CALayer+PKDownloadButtonAnimations.h"
-
-static NSString *const kSpinAnimationKey = @"PKSpin";
-static const CGFloat kDefaultRaduis = 13.f;
-static const CGFloat kDefaultEmptyLineRadians = 0.4f;
-static const CGFloat kDefaultSpinTime = 1.f;
-
-@interface PKPendingView ()
-
-@property (nonatomic, weak) PKCircleView *circleView;
-@property (nonatomic, weak) NSLayoutConstraint *width;
-@property (nonatomic, weak) NSLayoutConstraint *height;
-@property (nonatomic, assign) BOOL isSpinning;
-
-- (PKCircleView *)createCircleView;
-
-- (NSArray *)createConstraints;
-
-@end
-
-static PKPendingView *CommonInit(PKPendingView *self) {
-    if (self != nil) {
-        PKCircleView *circleView = [self createCircleView];
-        circleView.translatesAutoresizingMaskIntoConstraints = NO;
-        [self addSubview:circleView];
-        self.circleView = circleView;
-        self.circleView.userInteractionEnabled = NO;
-        [self addConstraints:[self createConstraints]];
-        
-        self.emptyLineRadians = kDefaultEmptyLineRadians;
-        self.radius = kDefaultRaduis;
-        self.clipsToBounds = NO;
-        
-        self.spinTime = kDefaultSpinTime;
-        [self startSpin];
-    }
-    return self;
-}
-
-@implementation PKPendingView
-
-#pragma mark - initialization
-
-- (id)initWithCoder:(NSCoder *)decoder {
-    return CommonInit([super initWithCoder:decoder]);
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
-    return CommonInit([super initWithFrame:frame]);
-}
-
-#pragma mark - properties
-
-- (void)setSpinTime:(CGFloat)spinTime {
-    _spinTime = spinTime;
-    [self.circleView.layer removeRotationAnimationWithKey:kSpinAnimationKey];
-    if (self.isSpinning) {
-        [self startSpin];
-    }
-}
-
-- (void)setRadius:(CGFloat)radius {
-    self.width.constant = radius * 2;
-    self.height.constant = radius * 2;
-    [self setNeedsLayout];
-}
-
-- (void)setLineWidth:(CGFloat)lineWidth {
-    self.circleView.lineWidth = lineWidth;
-    [self setNeedsDisplay];
-}
-
-- (CGFloat)lineWidth {
-    return self.circleView.lineWidth;
-}
-
-- (void)setEmptyLineRadians:(CGFloat)emptyLineRadians {
-    _emptyLineRadians = emptyLineRadians;
-    self.circleView.startAngleRadians = 1.5f * M_PI + emptyLineRadians / 2.f;
-    self.circleView.endAngleRadians = self.circleView.startAngleRadians + 2 * M_PI - emptyLineRadians;
-    [self setNeedsDisplay];
-}
-
-- (void)setTintColor:(UIColor *)tintColor {
-    self.circleView.tintColor = tintColor;
-    [self setNeedsDisplay];
-}
-
-#pragma mark - private methods
-
-- (PKCircleView *)createCircleView {
-    PKCircleView *circleView = [[PKCircleView alloc] init];
-    NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintForView:circleView
-                                                                      withHeight:0.f];
-    NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintForView:circleView
-                                                                      withWidth:0.f];
-    
-    [circleView addConstraints:@[heightConstraint, widthConstraint]];
-    
-    self.width = widthConstraint;
-    self.height = heightConstraint;
-    
-    return circleView;
-}
-
-- (NSArray *)createConstraints {
-    NSMutableArray *constraints = [NSMutableArray array];
-    [constraints addObjectsFromArray:[NSLayoutConstraint constraintsForWrappedSubview:self.circleView
-                                                                           withInsets:UIEdgeInsetsZero]];
-    return constraints;
-}
-
-- (void)startSpin {
-    self.isSpinning = YES;
-    [self.circleView.layer addRotationAnimationWithKey:kSpinAnimationKey
-                                  fullRotationDuration:self.spinTime];
-}
-
-- (void)stopSpin {
-    [self.circleView.layer removeRotationAnimationWithKey:kSpinAnimationKey];
-    self.isSpinning = NO;
-}
-
-@end

+ 0 - 18
Libraries external/PKDownloadButton/PKStopDownloadButton.h

@@ -1,18 +0,0 @@
-//
-//  PKStopDownloadButton.h
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import "PKCircleProgressView.h"
-
-IB_DESIGNABLE
-@interface PKStopDownloadButton : PKCircleProgressView
-
-@property (nonatomic, assign) IBInspectable CGFloat stopButtonWidth;
-@property (nonatomic, weak, readonly) UIButton *stopButton;
-
-@end

+ 0 - 96
Libraries external/PKDownloadButton/PKStopDownloadButton.m

@@ -1,96 +0,0 @@
-//
-//  PKStopDownloadButton.m
-//  PKDownloadButton
-//
-//  Created by Pavel on 28/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "PKStopDownloadButton.h"
-#import "NSLayoutConstraint+PKDownloadButton.h"
-#import "UIImage+PKDownloadButton.h"
-
-static const CGFloat kDefaultStopButtonWidth = 8.f;
-
-@interface PKStopDownloadButton ()
-
-@property (nonatomic, weak) UIButton *stopButton;
-
-- (UIButton *)createStopButton;
-- (NSArray *)createStopButtonConstraints;
-- (void)updateAppearance;
-- (PKCircleProgressView *)createCircleProgressView;
-
-@end
-
-static PKStopDownloadButton *CommonInit(PKStopDownloadButton *self) {
-    if (self != nil) {
-        UIButton *stopButton = [self createStopButton];
-        stopButton.translatesAutoresizingMaskIntoConstraints = NO;
-        [self addSubview:stopButton];
-        self.stopButton = stopButton;
-        
-        [self addConstraints:[self createStopButtonConstraints]];
-        [self updateAppearance];
-        [self setNeedsDisplay];
-    }
-    return self;
-}
-
-@implementation PKStopDownloadButton
-
-#pragma mark - properties
-
-- (void)setStopButtonWidth:(CGFloat)stopButtonWidth {
-    _stopButtonWidth = stopButtonWidth;
-    [self.stopButton setImage:[UIImage stopImageOfSize:stopButtonWidth
-                                                 color:self.tintColor]
-                     forState:UIControlStateNormal];
-    [self setNeedsDisplay];
-}
-
-#pragma mark - initialization
-
-- (instancetype)initWithCoder:(NSCoder *)decoder {
-    return CommonInit([super initWithCoder:decoder]);
-}
-
-- (instancetype)initWithFrame:(CGRect)frame {
-    return CommonInit([super initWithFrame:frame]);
-}
-
-#pragma mark - private methods
-
-- (UIButton *)createStopButton {
-    UIButton *stopButton = [UIButton buttonWithType:UIButtonTypeCustom];
-	stopButton.tintColor = [UIColor clearColor];
-    _stopButtonWidth = kDefaultStopButtonWidth;
-    return stopButton;
-}
-
-- (NSArray *)createStopButtonConstraints {
-    NSMutableArray *constraints = [NSMutableArray array];
-    [constraints addObjectsFromArray:[NSLayoutConstraint constraintsForWrappedSubview:self.stopButton
-                                                                           withInsets:UIEdgeInsetsZero]];
-    
-    return constraints;
-}
-
-- (PKCircleProgressView *)createCircleProgressView {
-    PKCircleProgressView *circleProgressView = [[PKCircleProgressView alloc] init];
-    
-    return circleProgressView;
-}
-
-#pragma mark - appearance
-
-- (void)updateAppearance {
-	[self.stopButton setImage:[UIImage stopImageOfSize:_stopButtonWidth color:self.tintColor]
-				forState:UIControlStateNormal];
-}
-
-- (void)tintColorDidChange {
-	[super tintColorDidChange];
-	[self updateAppearance];
-}
-@end

+ 0 - 16
Libraries external/PKDownloadButton/UIImage+PKDownloadButton.h

@@ -1,16 +0,0 @@
-//
-//  UIImage+PKDownloadButton.h
-//  Download
-//
-//  Created by Pavel on 31/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface UIImage (PKDownloadButton)
-
-+ (UIImage *)stopImageOfSize:(CGFloat)size color:(UIColor *)color;
-+ (UIImage *)borderedImageWithFill:(UIColor *)fillColor radius:(CGFloat)radius lineColor:(UIColor *)lineColor lineWidth:(CGFloat)lineWidth;
-
-@end

+ 0 - 49
Libraries external/PKDownloadButton/UIImage+PKDownloadButton.m

@@ -1,49 +0,0 @@
-//
-//  UIImage+PKDownloadButton.m
-//  Download
-//
-//  Created by Pavel on 31/05/15.
-//  Copyright (c) 2015 Katunin. All rights reserved.
-//
-
-#import "UIImage+PKDownloadButton.h"
-
-@implementation UIImage (PKDownloadButton)
-
-+ (UIImage *)stopImageOfSize:(CGFloat)size color:(UIColor *)color {
-    UIGraphicsBeginImageContextWithOptions(CGSizeMake(size, size), NO, 1.0f);
-    
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    [color setStroke];
-    
-    CGRect stopImageRect = CGRectMake(0.f, 0.f, size, size);
-    CGContextSetFillColorWithColor(context, color.CGColor);
-    CGContextAddRect(context, stopImageRect);
-    CGContextFillRect(context, stopImageRect);
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    
-    UIGraphicsEndImageContext();
-    return image;
-}
-
-+ (UIImage *)borderedImageWithFill:(UIColor *)fillColor radius:(CGFloat)radius lineColor:(UIColor *)lineColor lineWidth:(CGFloat)lineWidth {
-
-    UIGraphicsBeginImageContextWithOptions(CGSizeMake(radius * 2, radius * 2), NO, 0.0f);
-
-    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(lineWidth,lineWidth,(radius - lineWidth) * 2, (radius - lineWidth) * 2)
-                                                          cornerRadius:radius];
-    bezierPath.lineWidth = lineWidth;
-
-    if (lineColor) [lineColor setStroke];
-    if (fillColor) [fillColor setFill];
-
-    [bezierPath stroke];
-    
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-
-    UIGraphicsEndImageContext();
-
-    return [image resizableImageWithCapInsets:UIEdgeInsetsMake(radius, radius, radius, radius)];
-}
-
-@end

File diff suppressed because it is too large
+ 246 - 251
Nextcloud.xcodeproj/project.pbxproj


+ 6 - 6
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -15,8 +15,8 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "3abaa65cf70f7dfa8a7d0df2277d4eda14d7cfd1",
-          "version": "0.84.0"
+          "revision": "2adb1b594afd7c48eea57b30c987297c1fe7b8bc",
+          "version": "0.85.0"
         }
       },
       {
@@ -33,8 +33,8 @@
         "repositoryURL": "https://github.com/realm/realm-cocoa",
         "state": {
           "branch": null,
-          "revision": "96d5d28f9fd35bd5b109da376bfdc3194cd2794a",
-          "version": "5.4.8"
+          "revision": "7094961907423ae3f0050c21b91d871393cb3f1f",
+          "version": "10.2.0"
         }
       },
       {
@@ -42,8 +42,8 @@
         "repositoryURL": "https://github.com/realm/realm-core",
         "state": {
           "branch": null,
-          "revision": "612057010f5521d41559970306054f4c5b12632a",
-          "version": "6.1.4"
+          "revision": "596fe8985a2bcdf3c6ecb0a7a8712b9ac5480c79",
+          "version": "10.1.3"
         }
       },
       {

+ 2 - 2
Notification Service Extension/NotificationService.swift

@@ -35,12 +35,12 @@ class NotificationService: UNNotificationServiceExtension {
             bestAttemptContent.body = "Nextcloud notification"
             do {
                 let message = bestAttemptContent.userInfo["subject"] as! String
-                let tableAccounts = NCManageDatabase.sharedInstance.getAllAccount()
+                let tableAccounts = NCManageDatabase.shared.getAllAccount()
                 for tableAccount in tableAccounts {
                     guard let privateKey = CCUtility.getPushNotificationPrivateKey(tableAccount.account) else {
                         continue
                     }
-                    guard let decryptedMessage = NCPushNotificationEncryption.sharedInstance().decryptPushNotification(message, withDevicePrivateKey: privateKey) else {
+                    guard let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey) else {
                         continue
                     }
                     guard let data = decryptedMessage.data(using: .utf8) else {

+ 17 - 17
Share/NCSelectDestination.m

@@ -47,7 +47,7 @@
 {
     [super viewDidLoad];
     
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
     
     if (tableAccount) {
         
@@ -79,7 +79,7 @@
         UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0,0, self.navigationItem.titleView.frame.size.width, 40)];
         label.text = self.passMetadata.fileNameView;
         
-        label.textColor = NCBrandColor.sharedInstance.brandText;
+        label.textColor = NCBrandColor.shared.brandText;
         
         label.backgroundColor =[UIColor clearColor];
         label.textAlignment = NSTextAlignmentCenter;
@@ -88,11 +88,11 @@
     
     // TableView : at the end of rows nothing
     self.tableView.tableFooterView = [UIView new];
-    self.tableView.separatorColor =  NCBrandColor.sharedInstance.separator;
+    self.tableView.separatorColor =  NCBrandColor.shared.separator;
 
     // get auto upload folder
-    _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
-    _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectoryWithUrlBase:urlBase account:account];
+    _autoUploadFileName = [[NCManageDatabase shared] getAccountAutoUploadFileName];
+    _autoUploadDirectory = [[NCManageDatabase shared] getAccountAutoUploadDirectoryWithUrlBase:urlBase account:account];
     
     [self readFolder];
 }
@@ -102,10 +102,10 @@
 {
     [super viewWillAppear:animated];
     
-    self.navigationController.navigationBar.barTintColor = NCBrandColor.sharedInstance.brandElement;
-    self.navigationController.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText;
+    self.navigationController.navigationBar.barTintColor = NCBrandColor.shared.brandElement;
+    self.navigationController.navigationBar.tintColor = NCBrandColor.shared.brandText;
     
-    self.navigationController.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;
+    self.navigationController.toolbar.barTintColor = NCBrandColor.shared.tabBar;
     self.navigationController.toolbar.tintColor = [UIColor grayColor];
     
     if (self.hideCreateFolder) {
@@ -118,8 +118,8 @@
         [self.move setTintColor: [UIColor clearColor]];
     }
     
-    self.view.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
-    self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
+    self.view.backgroundColor = NCBrandColor.shared.backgroundView;
+    self.tableView.backgroundColor = NCBrandColor.shared.backgroundView;
 }
 
 // MARK: - IBAction
@@ -225,7 +225,7 @@
         }
     }
     
-    NSArray *result = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:predicateDataSource];
+    NSArray *result = [[NCManageDatabase shared] getMetadatasWithPredicate:predicateDataSource];
     
     if (result)
         return [result count];
@@ -242,24 +242,24 @@
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
     }
     
-    tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row];
+    tableMetadata *metadata = [[NCManageDatabase shared] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row];
     
     // Create Directory Provider Storage ocId
     [CCUtility getDirectoryProviderStorageOcId:metadata.ocId];
     
     // colors
-    cell.textLabel.textColor = NCBrandColor.sharedInstance.textView;
+    cell.textLabel.textColor = NCBrandColor.shared.textView;
     
     cell.detailTextLabel.text = @"";
     
     if (metadata.directory) {
     
         if (metadata.e2eEncrypted)
-            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderEncrypted"] multiplier:2 color:NCBrandColor.sharedInstance.brandElement];
+            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderEncrypted"] multiplier:2 color:NCBrandColor.shared.brandElement];
         else if ([metadata.fileName isEqualToString:_autoUploadFileName] && [self.serverUrl isEqualToString:_autoUploadDirectory])
-            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderAutomaticUpload"] multiplier:2 color:NCBrandColor.sharedInstance.brandElement];
+            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderAutomaticUpload"] multiplier:2 color:NCBrandColor.shared.brandElement];
         else
-            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:NCBrandColor.sharedInstance.brandElement];
+            cell.imageView.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:NCBrandColor.shared.brandElement];
         
     } else {
         
@@ -284,7 +284,7 @@
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row ];
+    tableMetadata *metadata = [[NCManageDatabase shared] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row ];
     
     if (metadata.directory) {
         

+ 18 - 18
Share/ShareViewController.m

@@ -50,7 +50,7 @@
 
 -(void)viewDidLoad
 {
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
     
     if (tableAccount == nil) {
         
@@ -61,7 +61,7 @@
         
     } else {
         
-        NSInteger serverVersionMajor = [[NCManageDatabase sharedInstance] getCapabilitiesServerIntWithAccount:tableAccount.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
+        NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:tableAccount.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
         NSString *webDav = [[NCUtility shared] getWebDAVWithAccount:tableAccount.account];
         
         // Networking
@@ -107,8 +107,8 @@
 {
     [super viewWillAppear:animated];
         
-    self.view.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
-    self.shareTable.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
+    self.view.backgroundColor = NCBrandColor.shared.backgroundView;
+    self.shareTable.backgroundColor = NCBrandColor.shared.backgroundView;
 }
 
 - (void)closeShareViewController
@@ -176,16 +176,16 @@
 - (void)navigationBarToolBar
 {
     // Theming
-    if ([NCBrandOptions sharedInstance].use_themingColor) {
-        NSString *themingColor = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColor];
-        NSString *themingColorElement = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
-        NSString *themingColorText = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorText];
+    if ([NCBrandOptions shared].use_themingColor) {
+        NSString *themingColor = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColor];
+        NSString *themingColorElement = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
+        NSString *themingColorText = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorText];
         [CCGraphics settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
     }
-    self.navigationController.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand;
-    self.navigationController.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText;
+    self.navigationController.navigationBar.barTintColor = NCBrandColor.shared.brand;
+    self.navigationController.navigationBar.tintColor = NCBrandColor.shared.brandText;
     
-    self.toolBar.barTintColor = NCBrandColor.sharedInstance.tabBar;
+    self.toolBar.barTintColor = NCBrandColor.shared.tabBar;
     self.toolBar.tintColor = [UIColor grayColor];
     
     // Upload
@@ -197,7 +197,7 @@
     // Title
     [self.navigationController.navigationBar setTitleTextAttributes: @{NSForegroundColorAttributeName:self.navigationController.navigationBar.tintColor}];
     
-    self.navigationItem.title = [NCBrandOptions sharedInstance].brand;
+    self.navigationItem.title = [NCBrandOptions shared].brand;
     self.navigationItem.leftBarButtonItem = leftButtonCancel;
     self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:rightButtonUpload, nil];
     self.navigationItem.hidesBackButton = YES;
@@ -247,7 +247,7 @@
 {
     if ([self.filesName count] > 0) {
     
-        [self.hud visibleHudTitle:NSLocalizedString(@"_uploading_", nil) mode:MBProgressHUDModeDeterminate color:NCBrandColor.sharedInstance.brandElement];
+        [self.hud visibleHudTitle:NSLocalizedString(@"_uploading_", nil) mode:MBProgressHUDModeDeterminate color:NCBrandColor.shared.brandElement];
         
         NSString *fileName = [self.filesName objectAtIndex:0];
         NSString *fileNameLocal = [NSTemporaryDirectory() stringByAppendingString:fileName];
@@ -287,15 +287,15 @@
                
                 [CCUtility copyFileAtPath:fileNameLocal toPath:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameForUpload]];
                
-                tableMetadata *metadata = [[NCManageDatabase sharedInstance] createMetadataWithAccount:self.account fileName:fileNameForUpload ocId:ocId serverUrl:self.serverUrl urlBase:self.urlBase url:@"" contentType:@"" livePhoto:false];
+                tableMetadata *metadata = [[NCManageDatabase shared] createMetadataWithAccount:self.account fileName:fileNameForUpload ocId:ocId serverUrl:self.serverUrl urlBase:self.urlBase url:@"" contentType:@"" livePhoto:false];
                                
                 metadata.date = date;
                 metadata.etag = etag;
                 metadata.serverUrl = self.serverUrl;
                 metadata.size = size;
                 
-                [[NCManageDatabase sharedInstance] addMetadata:metadata];
-                [[NCManageDatabase sharedInstance] addLocalFileWithMetadata:metadata];
+                [[NCManageDatabase shared] addMetadata:metadata];
+                [[NCManageDatabase shared] addLocalFileWithMetadata:metadata];
                
                 [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
                 [self performSelector:@selector(selectPost) withObject:nil];
@@ -433,11 +433,11 @@
     cell.fileImageView.image = image;
 
     cell.fileName.text = fileName;
-    cell.fileName.textColor = NCBrandColor.sharedInstance.textView;
+    cell.fileName.textColor = NCBrandColor.shared.textView;
     cell.fileName.delegate = self;
     
     cell.info.text = [CCUtility transformedSize:fileSize];
-    cell.info.textColor = NCBrandColor.sharedInstance.textView;
+    cell.info.textColor = NCBrandColor.shared.textView;
     
     return cell;
 }

+ 27 - 17
iOSClient/Activity/NCActivity.swift

@@ -80,9 +80,13 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
     @objc func changeTheming() {
         
         if filterFileId == nil {
-            appDelegate.changeTheming(self, tableView: tableView, collectionView: nil, form: false)
+            view.backgroundColor = NCBrandColor.shared.backgroundView
+            tableView.backgroundColor = NCBrandColor.shared.backgroundView
+            tableView.reloadData()
         } else {
-            appDelegate.changeTheming(self, tableView: tableView, collectionView: nil, form: true)
+            view.backgroundColor = NCBrandColor.shared.backgroundForm
+            tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+            tableView.reloadData()
         }
     }
     
@@ -112,7 +116,8 @@ class activityTableViewCell: UITableViewCell {
     var account: String = ""
     var activityPreviews: [tableActivityPreview] = []
     var didSelectItemEnable: Bool = true
-
+    var viewController: UIViewController? = nil
+    
     override func awakeFromNib() {
         super.awakeFromNib()
         
@@ -144,7 +149,7 @@ extension NCActivity: UITableViewDelegate {
         
         let label = UILabel()
         label.font = UIFont.boldSystemFont(ofSize: 13)
-        label.textColor = NCBrandColor.sharedInstance.textView
+        label.textColor = NCBrandColor.shared.textView
         label.text = CCUtility.getTitleSectionDate(sectionDate[section])
         label.textAlignment = .center
         label.layer.cornerRadius = 11
@@ -185,7 +190,8 @@ extension NCActivity: UITableViewDataSource {
             cell.avatar.isHidden = true
             cell.subjectTrailingConstraint.constant = 10
             cell.didSelectItemEnable = self.didSelectItemEnable
-            cell.subject.textColor = NCBrandColor.sharedInstance.textView
+            cell.subject.textColor = NCBrandColor.shared.textView
+            cell.viewController = self
             
             // icon
             if activity.icon.count > 0 {
@@ -245,7 +251,7 @@ extension NCActivity: UITableViewDataSource {
                 }
                 
                 for key in keys {
-                    if let result = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: appDelegate.account, idActivity: activity.idActivity, key: key) {
+                    if let result = NCManageDatabase.shared.getActivitySubjectRich(account: appDelegate.account, idActivity: activity.idActivity, key: key) {
                         orderKeysId.append(result.id)
                         subject = subject.replacingOccurrences(of: "{\(key)}", with: "<bold>" + result.name + "</bold>")
                     }
@@ -265,7 +271,7 @@ extension NCActivity: UITableViewDataSource {
             }
             
             // CollectionView
-            cell.activityPreviews = NCManageDatabase.sharedInstance.getActivityPreview(account: activity.account, idActivity: activity.idActivity, orderKeysId: orderKeysId)
+            cell.activityPreviews = NCManageDatabase.shared.getActivityPreview(account: activity.account, idActivity: activity.idActivity, orderKeysId: orderKeysId)
             if cell.activityPreviews.count == 0 {
                 cell.collectionViewHeightConstraint.constant = 0
             } else {
@@ -337,7 +343,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
             }
             if (responder as? UIViewController)!.navigationController != nil {
                 if let viewController = UIStoryboard.init(name: "NCTrash", bundle: nil).instantiateInitialViewController() as? NCTrash {
-                    if let result = NCManageDatabase.sharedInstance.getTrashItem(fileId: String(activityPreview.fileId), account: activityPreview.account) {
+                    if let result = NCManageDatabase.shared.getTrashItem(fileId: String(activityPreview.fileId), account: activityPreview.account) {
                         viewController.blinkFileId = result.fileId
                         viewController.trashPath = result.filePath
                         (responder as? UIViewController)!.navigationController?.pushViewController(viewController, animated: true)
@@ -352,17 +358,19 @@ extension activityTableViewCell: UICollectionViewDelegate {
         
         if activityPreview.view == "files" && activityPreview.mimeType != "dir" {
             
-            guard let activitySubjectRich = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: activityPreview.account, idActivity: activityPreview.idActivity, id: String(activityPreview.fileId)) else {
+            guard let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: activityPreview.idActivity, id: String(activityPreview.fileId)) else {
                 return
             }
             
-            if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "fileId == %@", activitySubjectRich.id)) {
+            if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "fileId == %@", activitySubjectRich.id)) {
                 if let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) {
                     do {
                         let attr = try FileManager.default.attributesOfItem(atPath: filePath)
                         let fileSize = attr[FileAttributeKey.size] as! UInt64
                         if fileSize > 0 {
-                            self.appDelegate.activeFiles.segue(metadata: metadata)
+                            if let viewController = self.viewController {
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata])
+                            }
                             return
                         }
                     } catch {
@@ -406,8 +414,10 @@ extension activityTableViewCell: UICollectionViewDelegate {
                                                        
                             CCUtility.moveFile(atPath: atPath, toPath: toPath)
                                                        
-                            NCManageDatabase.sharedInstance.addMetadata(metadata!)
-                            self.appDelegate.activeFiles.segue(metadata: metadata!)
+                            NCManageDatabase.shared.addMetadata(metadata!)
+                            if let viewController = self.viewController {
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata!, metadatas: [metadata!])
+                            }
                         }
                     }
                     
@@ -472,7 +482,7 @@ extension activityTableViewCell: UICollectionViewDataSource {
                 
             } else {
                 
-                if let activitySubjectRich = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: account, idActivity: idActivity, id: fileId) {
+                if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: account, idActivity: idActivity, id: fileId) {
                     
                     let fileNamePath = CCUtility.getDirectoryUserData() + "/" + activitySubjectRich.name
                     
@@ -531,7 +541,7 @@ extension NCActivity {
         
         sectionDate.removeAll()
         
-        let activities = NCManageDatabase.sharedInstance.getActivity(predicate: NSPredicate(format: "account == %@", appDelegate.account), filterFileId: filterFileId)
+        let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@", appDelegate.account), filterFileId: filterFileId)
         allActivities = activities.all
         filterActivities = activities.filter
         for tableActivity in filterActivities {
@@ -553,7 +563,7 @@ extension NCActivity {
             return Calendar.current.date(byAdding: components, to: startDate)!
         }()
         
-        let activities = NCManageDatabase.sharedInstance.getActivity(predicate: NSPredicate(format: "account == %@ && date BETWEEN %@", appDelegate.account, [startDate, endDate]), filterFileId: filterFileId)
+        let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@ && date BETWEEN %@", appDelegate.account, [startDate, endDate]), filterFileId: filterFileId)
         return activities.filter
     }
     
@@ -569,7 +579,7 @@ extension NCActivity {
         NCCommunication.shared.getActivity(since: idActivity, limit: 200, objectId: filterFileId, objectType: objectType, previews: true) { (account, activities, errorCode, errorDescription) in
             
            if errorCode == 0 && account == self.appDelegate.account {
-                NCManageDatabase.sharedInstance.addActivity(activities , account: account)
+                NCManageDatabase.shared.addActivity(activities , account: account)
             }
             
             NCUtility.shared.stopActivityIndicator()

+ 5 - 30
iOSClient/AppDelegate.h

@@ -29,13 +29,12 @@
 #import <TOPasscodeViewController/TOPasscodeViewController.h>
 
 #import "CCUtility.h"
-#import "CCSettings.h"
 #import "CCLogin.h"
 
 @class NCFiles;
 @class NCFileViewInFolder;
 @class NCRecent;
-@class CCMore;
+@class NCMore;
 @class NCMedia;
 @class NCOffline;
 @class NCTransfers;
@@ -44,10 +43,10 @@
 @class NCTrash;
 @class NCAppConfigView;
 @class IMImagemeterViewer;
-@class NCDetailViewController;
 @class NCNetworkingAutoUpload;
 @class NCDocumentPickerViewController;
 @class FileProviderDomain;
+@class NCViewerVideo;
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
 
@@ -65,10 +64,6 @@
 @property (nonatomic, strong) NSString *userID;
 @property (nonatomic, strong) NSString *password;
 
-// next version ... ? ...
-@property double currentLatitude;
-@property double currentLongitude;
-
 // Networking 
 @property (nonatomic, copy) void (^backgroundSessionCompletionHandler)(void);
 
@@ -78,17 +73,9 @@
 // Passcode lockDirectory
 @property (nonatomic, strong) NSDate *sessionePasscodeLock;
 
-// Audio Video
-@property (nonatomic, strong) AVPlayer *player;
-@property (nonatomic, strong) AVPlayerViewController *playerController;
-@property BOOL isMediaObserver;
-
 // Push Norification Token
 @property (nonatomic, strong) NSString *pushKitToken;
 
-// ProgressView Detail
-@property (nonatomic, strong) UIProgressView *progressViewDetail;
-
 @property (nonatomic, retain) TOPasscodeViewController *passcodeViewController;
 
 @property (nonatomic, retain) NSString *activeServerUrl;
@@ -100,27 +87,26 @@
 @property (nonatomic, retain) NCRecent *activeRecent;
 @property (nonatomic, retain) NCShares *activeShares;
 @property (nonatomic, retain) NCMedia *activeMedia;
-@property (nonatomic, retain) NCDetailViewController *activeDetail;
 @property (nonatomic, retain) NCTransfers *activeTransfers;
 @property (nonatomic, retain) CCLogin *activeLogin;
 @property (nonatomic, retain) NCLoginWeb *activeLoginWeb;
-@property (nonatomic, retain) CCMore *activeMore;
+@property (nonatomic, retain) NCMore *activeMore;
 @property (nonatomic, retain) NCOffline *activeOffline;
 @property (nonatomic, retain) NCTrash *activeTrash;
 @property (nonatomic, retain) NCAppConfigView *appConfigView;
 @property (nonatomic, retain) IMImagemeterViewer *activeImagemeterView;
+@property (nonatomic, retain) NCViewerVideo *activeViewerVideo;
 
-@property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listFilesVC;
 @property (nonatomic, strong) NSMutableDictionary *listFavoriteVC;
 @property (nonatomic, strong) NSMutableDictionary *listOfflineVC;
-
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
 
 @property (nonatomic) UIUserInterfaceStyle preferredUserInterfaceStyle API_AVAILABLE(ios(12.0));
 
 // Shares
 @property (nonatomic, strong) NSArray *shares;
+@property BOOL disableSharesView;
 
 // UserDefaults
 @property (nonatomic, strong) NSUserDefaults *ncUserDefaults;
@@ -137,19 +123,8 @@
 - (void)deleteAccount:(NSString *)account wipe:(BOOL)wipe;
 - (void)settingSetupCommunication:(NSString *)account;
 
-// Quick Actions - ShotcutItem
-- (void)configDynamicShortcutItems;
-- (BOOL)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem;
-
-// TabBarController
-- (void)createTabBarController:(UITabBarController *)tabBarController;
-
 // Push Notification
 - (void)pushNotification;
 
-// Theming Color
-- (void)settingThemingColorBrand;
-- (void)changeTheming:(UIViewController *)viewController tableView:(UITableView *)tableView collectionView:(UICollectionView *)collectionView form:(BOOL)form;
-
 @end
 

+ 78 - 380
iOSClient/AppDelegate.m

@@ -29,6 +29,7 @@
 #import <QuartzCore/QuartzCore.h>
 
 @import Firebase;
+
 @class NCViewerRichdocument;
 
 @interface AppDelegate() <TOPasscodeViewControllerDelegate>
@@ -45,7 +46,7 @@
 {
     BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
     
-    if (![CCUtility getDisableCrashservice] && NCBrandOptions.sharedInstance.disable_crash_service == false) {
+    if (![CCUtility getDisableCrashservice] && NCBrandOptions.shared.disable_crash_service == false) {
         [FIRApp configure];
     }
     
@@ -59,7 +60,7 @@
     NSInteger logLevel = [CCUtility getLogLevel];
     [[NCCommunicationCommon shared] setFileLogWithLevel:logLevel];
     NSString *versionApp = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
-    NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions sharedInstance].textCopyrightNextcloudiOS, versionApp];
+    NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, versionApp];
     if (isSimulatorOrTestFlight) {
         [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Start session with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
     } else {
@@ -70,7 +71,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initializeMain:) name:k_notificationCenter_initializeMain object:nil];
     
     // Set account, if no exists clear all
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
     if (tableAccount == nil) {
         // remove all the keys Chain
         [CCUtility deleteAllChainStore];
@@ -82,22 +83,21 @@
             NSString *user = [tableAccount.user stringByAppendingString:@" "];
             NSString *urlBase = [tableAccount.account stringByReplacingOccurrencesOfString:user withString:@""];
             tableAccount.urlBase = urlBase;
-            [[NCManageDatabase sharedInstance] updateAccount:tableAccount];
+            [[NCManageDatabase shared] updateAccount:tableAccount];
             
-            tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+            tableAccount = [[NCManageDatabase shared] getAccountActive];
         }
         [self settingAccount:tableAccount.account urlBase:tableAccount.urlBase user:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account]];
     }
     
     // UserDefaults
-    self.ncUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:[NCBrandOptions sharedInstance].capabilitiesGroups];
+    self.ncUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:[NCBrandOptions shared].capabilitiesGroups];
         
     // Background Fetch
     [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
 
     self.listProgressMetadata = [NSMutableDictionary new];
     self.listFilesVC = [NSMutableDictionary new];
-    self.listMainVC = [NSMutableDictionary new];
     self.listFavoriteVC = [NSMutableDictionary new];
     self.listOfflineVC = [NSMutableDictionary new];
 
@@ -112,21 +112,7 @@
     //AV Session
     [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:nil];
     [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
-
-    // ProgressView Detail
-    self.progressViewDetail = [[UIProgressView alloc] initWithProgressViewStyle: UIProgressViewStyleBar];
     
-    // Quick Actions
-    if([[UIApplicationShortcutItem class] respondsToSelector:@selector(new)]) {
-    
-        [self configDynamicShortcutItems];
-        
-        UIApplicationShortcutItem *shortcutItem = [launchOptions objectForKeyedSubscript:UIApplicationLaunchOptionsShortcutItemKey];
-        
-        if (shortcutItem)
-            [self handleShortCutItem:shortcutItem];
-    }
-        
     // Start Timer
     self.timerUpdateApplicationIconBadgeNumber = [NSTimer scheduledTimerWithTimeInterval:k_timerUpdateApplicationIconBadgeNumber target:self selector:@selector(updateApplicationIconBadgeNumber) userInfo:nil repeats:YES];
     [self startTimerErrorNetworking];
@@ -148,8 +134,8 @@
             }
         }
     }
-    
-    if ([NCBrandOptions sharedInstance].disable_intro) {
+        
+    if ([NCBrandOptions shared].disable_intro) {
         [CCUtility setIntro:YES];
         
         if (self.account.length == 0) {
@@ -178,8 +164,6 @@
     // Auto upload
     self.networkingAutoUpload = [NCNetworkingAutoUpload new];
     
-    [[NCCommunicationCommon shared] writeLog:@"Application did finish launching"];
-
     return YES;
 }
 
@@ -213,10 +197,10 @@
     [self passcodeWithAutomaticallyPromptForBiometricValidation:true];
     
     // Initialize Auto upload
-    [[NCAutoUpload sharedInstance] initStateAutoUpload];
+    [[NCAutoUpload shared] initStateAutoUpload];
     
     // Read active directory
-    [self.activeFiles reloadDataSourceNetworkWithForced:true];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_reloadDataSourceNetworkForced object:nil];
     
     // Required unsubscribing / subscribing
     [self pushNotification];
@@ -226,8 +210,6 @@
     
     // Request Service Server Nextcloud
     [[NCService shared] startRequestServicesServer];
-    
-    [[NCCommunicationCommon shared] writeLog:@"The application Will enter in foreground"];
 }
 
 //
@@ -239,7 +221,7 @@
         
     // Brand
     #if defined(HC)
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
     if (account.hcIsTrial == true || account.hcTrialExpired == true || account.hcNextGroupExpirationGroupExpired == true) {
         
         HCTrial *vc = [[UIStoryboard storyboardWithName:@"HCTrial" bundle:nil] instantiateInitialViewController];
@@ -250,8 +232,6 @@
     #endif
     
     [[NCNetworking shared] verifyUploadZombie];
-    
-    [[NCCommunicationCommon shared] writeLog:@"The application did become active"];
 }
 
 //
@@ -277,39 +257,33 @@
 // NotificationCenter
 - (void)initializeMain:(NSNotification *)notification
 {
-    if (self.account.length == 0) return;
+    if (self.account.length == 0) { return; }
     
     // Clear error certificate
     [CCUtility setCertificateError:self.account error:NO];
     
     // Setting Theming
-    [self settingThemingColorBrand];
-    
-    // If AVPlayer in play -> Stop
-    if (self.player != nil && self.player.rate != 0) {
-        [self.player pause];
-    }
+    [[NCBrandColor shared] settingThemingColorWithAccount:self.account];
     
     // close detail
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_menuDetailClose object:nil];
     
     // Not Photos Video in library ? then align and Init Auto Upload
-    NSArray *recordsPhotoLibrary = [[NCManageDatabase sharedInstance] getPhotoLibraryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", self.account]];
+    NSArray *recordsPhotoLibrary = [[NCManageDatabase shared] getPhotoLibraryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", self.account]];
     if ([recordsPhotoLibrary count] == 0) {
-        [[NCAutoUpload sharedInstance] alignPhotoLibrary];
+        [[NCAutoUpload shared] alignPhotoLibrary];
     }
     
     // Start Auto Upload
-    [[NCAutoUpload sharedInstance] initStateAutoUpload];
+    [[NCAutoUpload shared] initStateAutoUpload];
     
     // Start services
-    [[NCCommunicationCommon shared] writeLog:@"Request Service Server Nextcloud"];
     [[NCService shared] startRequestServicesServer];
     
     // Registeration push notification
     [self pushNotification];
     
-    //Registeration domain File Provider
+    // Registeration domain File Provider
     //FileProviderDomain *fileProviderDomain = [FileProviderDomain new];
     //[fileProviderDomain removeAllDomains];
     //[fileProviderDomain registerDomains];
@@ -323,7 +297,6 @@
 
 - (void)checkErrorNetworking
 {
-    // test
     if (self.account.length == 0) { return; }
     
     // check unauthorized server (401)
@@ -354,7 +327,7 @@
 - (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector openLoginWeb:(BOOL)openLoginWeb
 {
     // use appConfig [MDM]
-    if ([NCBrandOptions sharedInstance].use_configuration) {
+    if ([NCBrandOptions shared].use_configuration) {
         
         if (!(_appConfigView.isViewLoaded && _appConfigView.view.window)) {
         
@@ -367,12 +340,12 @@
     }
     
     // only for personalized LoginWeb [customer]
-    if ([NCBrandOptions sharedInstance].use_login_web_personalized) {
+    if ([NCBrandOptions shared].use_login_web_personalized) {
         
         if (!(_activeLoginWeb.isViewLoaded && _activeLoginWeb.view.window)) {
             
             self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
-            self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
+            self.activeLoginWeb.urlBase = [[NCBrandOptions shared] loginBaseUrl];
 
             [self showLoginViewController:self.activeLoginWeb forContext:viewController];
         }
@@ -388,7 +361,7 @@
             self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
             
             if (selector == k_intro_signup) {
-                self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] linkloginPreferredProviders];
+                self.activeLoginWeb.urlBase = [[NCBrandOptions shared] linkloginPreferredProviders];
             } else {
                 self.activeLoginWeb.urlBase = self.urlBase;
             }
@@ -396,10 +369,10 @@
            [self showLoginViewController:self.activeLoginWeb forContext:viewController];
         }
         
-    } else if ([NCBrandOptions sharedInstance].disable_intro && [NCBrandOptions sharedInstance].disable_request_login_url) {
+    } else if ([NCBrandOptions shared].disable_intro && [NCBrandOptions shared].disable_request_login_url) {
         
         self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
-        self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
+        self.activeLoginWeb.urlBase = [[NCBrandOptions shared] loginBaseUrl];
         
         [self showLoginViewController:self.activeLoginWeb forContext:viewController];
         
@@ -426,26 +399,31 @@
 -(void)showLoginViewController:(UIViewController *)viewController forContext:(UIViewController *)contextViewController
 {
     if (contextViewController == NULL) {
-        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
-        navController.navigationBar.barStyle =  UIBarStyleBlack;
-        navController.navigationBar.tintColor = NCBrandColor.sharedInstance.customerText;
-        navController.navigationBar.barTintColor = NCBrandColor.sharedInstance.customer;
-        [navController.navigationBar setTranslucent:false];
-        self.window.rootViewController = navController;
+        
+        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
+        navigationController.navigationBar.barStyle =  UIBarStyleBlack;
+        navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText;
+        navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer;
+        [navigationController.navigationBar setTranslucent:false];
+        self.window.rootViewController = navigationController;
+        
         [self.window makeKeyAndVisible];
         
     } else if ([contextViewController isKindOfClass:[UINavigationController class]]) {
-        UINavigationController *navController = ((UINavigationController *)contextViewController);
-        [navController pushViewController:viewController animated:true];
+        
+        UINavigationController *navigationController = ((UINavigationController *)contextViewController);
+        [navigationController pushViewController:viewController animated:true];
         
     } else {
-        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
-        navController.modalPresentationStyle = UIModalPresentationFullScreen;
-        navController.navigationBar.barStyle =  UIBarStyleBlack;
-        navController.navigationBar.tintColor = NCBrandColor.sharedInstance.customerText;
-        navController.navigationBar.barTintColor = NCBrandColor.sharedInstance.customer;
-        [navController.navigationBar setTranslucent:false];
-        [contextViewController presentViewController:navController animated:true completion:nil];
+        
+        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
+        navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
+        navigationController.navigationBar.barStyle =  UIBarStyleBlack;
+        navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText;
+        navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer;
+        [navigationController.navigationBar setTranslucent:false];
+        
+        [contextViewController presentViewController:navigationController animated:true completion:nil];
     }
 }
 
@@ -475,18 +453,18 @@
 - (void)deleteAccount:(NSString *)account wipe:(BOOL)wipe
 {
     // Push Notification
-    tableAccount *accountPN = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
+    tableAccount *accountPN = [[NCManageDatabase shared] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
     [self unsubscribingNextcloudServerPushNotification:accountPN.account urlBase:accountPN.urlBase user:accountPN.user withSubscribing:false];
 
     [self settingAccount:nil urlBase:nil user:nil userID:nil password:nil];
     
     /* DELETE ALL FILES LOCAL FS */
-    NSArray *results = [[NCManageDatabase sharedInstance] getTableLocalFilesWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account] sorted:@"ocId" ascending:NO];
+    NSArray *results = [[NCManageDatabase shared] getTableLocalFilesWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account] sorted:@"ocId" ascending:NO];
     for (tableLocalFile *result in results) {
         [CCUtility removeFileAtPath:[CCUtility getDirectoryProviderStorageOcId:result.ocId]];
     }
     // Clear database
-    [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:account removeAccount:true];
+    [[NCManageDatabase shared] clearDatabaseWithAccount:account removeAccount:true];
 
     [CCUtility clearAllKeysEndToEnd:account];
     [CCUtility clearAllKeysPushNotification:account];
@@ -494,10 +472,10 @@
     [CCUtility setPassword:account password:nil];
        
     if (wipe) {
-        NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
+        NSArray *listAccount = [[NCManageDatabase shared] getAccounts];
         if ([listAccount count] > 0) {
             NSString *newAccount = listAccount[0];
-            tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:newAccount];
+            tableAccount *tableAccount = [[NCManageDatabase shared] setAccountActive:newAccount];
             [self settingAccount:newAccount urlBase:tableAccount.urlBase user:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account]];
             [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
         } else {
@@ -508,7 +486,7 @@
 
 - (void)settingSetupCommunication:(NSString *)account
 {
-    NSInteger serverVersionMajor = [[NCManageDatabase sharedInstance] getCapabilitiesServerIntWithAccount:account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
+    NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
     if (serverVersionMajor > 0) {
         [[NCCommunicationCommon shared] setupWithNextcloudVersion:serverVersionMajor];
     }
@@ -525,7 +503,7 @@
 {
     if (self.account.length == 0 || self.pushKitToken.length == 0) { return; }
     
-    for (tableAccount *result in [[NCManageDatabase sharedInstance] getAllAccount]) {
+    for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
         
         NSString *token = [CCUtility getPushNotificationToken:result.account];
         
@@ -544,12 +522,12 @@
 {
     if (self.account.length == 0 || self.pushKitToken.length == 0) { return; }
     
-    [[NCPushNotificationEncryption sharedInstance] generatePushNotificationsKeyPair:account];
+    [[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
 
     NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
     NSData *pushPublicKey = [CCUtility getPushNotificationPublicKey:account];
     NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
-    NSString *proxyServerPath = [NCBrandOptions sharedInstance].pushNotificationServerProxy;
+    NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
     
     [[NCCommunication shared] subscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] pushTokenHash:pushTokenHash devicePublicKey:pushDevicePublicKey proxyServerUrl:proxyServerPath customUserAgent:nil addCustomHeaders:nil completionHandler:^(NSString *account, NSString *deviceIdentifier, NSString *signature, NSString *publicKey, NSInteger errorCode, NSString *errorDescription) {
         if (errorCode == 0) {
@@ -580,7 +558,7 @@
     [[NCCommunication shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] customUserAgent:nil addCustomHeaders:nil completionHandler:^(NSString *account, NSInteger errorCode, NSString *errorDescription) {
         if (errorCode == 0) {
             NSString *userAgent = [NSString stringWithFormat:@"%@  (Strict VoIP)", [CCUtility getUserAgent]];
-            NSString *proxyServerPath = [NCBrandOptions sharedInstance].pushNotificationServerProxy;
+            NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
             [[NCCommunication shared] unsubscribingPushProxyWithProxyServerUrl:proxyServerPath deviceIdentifier:deviceIdentifier signature:signature publicKey:publicKey userAgent:userAgent completionHandler:^(NSInteger errorCode, NSString *errorDescription) {
                 if (errorCode == 0) {
                 
@@ -624,11 +602,11 @@
 {
     NSString *message = [userInfo objectForKey:@"subject"];
     if (message) {
-        NSArray *results = [[NCManageDatabase sharedInstance] getAllAccount];
+        NSArray *results = [[NCManageDatabase shared] getAllAccount];
         for (tableAccount *result in results) {
             if ([CCUtility getPushNotificationPrivateKey:result.account]) {
                 NSData *decryptionKey = [CCUtility getPushNotificationPrivateKey:result.account];
-                NSString *decryptedMessage = [[NCPushNotificationEncryption sharedInstance] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
+                NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
                 if (decryptedMessage) {
                     NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
                     NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
@@ -658,7 +636,7 @@
     [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
         for (UNNotificationRequest *notificationRequest in requests) {
             NSString *message = [notificationRequest.content.userInfo objectForKey:@"subject"];
-            NSString *decryptedMessage = [[NCPushNotificationEncryption sharedInstance] decryptPushNotification:message withDevicePrivateKey:key];
+            NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:key];
             if (decryptedMessage) {
                 NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
                 NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
@@ -673,7 +651,7 @@
     [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
         for (UNNotification *notification in notifications) {
             NSString *message = [notification.request.content.userInfo objectForKey:@"subject"];
-            NSString *decryptedMessage = [[NCPushNotificationEncryption sharedInstance] decryptPushNotification:message withDevicePrivateKey:key];
+            NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:key];
             if (decryptedMessage) {
                 NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
                 NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
@@ -698,75 +676,6 @@
     return [token copy];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Quick Actions - ShotcutItem =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)configDynamicShortcutItems
-{
-    NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
-    
-    UIApplicationShortcutIcon *shortcutMediaIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"media"];
-    UIApplicationShortcutItem *shortcutMedia = [[UIApplicationShortcutItem alloc] initWithType:[NSString stringWithFormat:@"%@.media", bundleId] localizedTitle:NSLocalizedString(@"_media_", nil) localizedSubtitle:nil icon:shortcutMediaIcon userInfo:nil];
-   
-    // add the array to our app
-    if (shortcutMedia)
-        [UIApplication sharedApplication].shortcutItems = @[shortcutMedia];
-}
-
-- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
-{
-    BOOL handledShortCutItem = [self handleShortCutItem:shortcutItem];
-    
-    completionHandler(handledShortCutItem);
-}
-
-- (BOOL)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem
-{
-    BOOL handled = NO;
-    
-    NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
-    NSString *shortcutMedia = [NSString stringWithFormat:@"%@.media", bundleId];
-    
-    if ([shortcutItem.type isEqualToString:shortcutMedia] && self.account) {
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-
-            UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-            if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
-                UINavigationController *navigationControllerMaster = (UINavigationController *)splitViewController.viewControllers.firstObject;
-                if ([navigationControllerMaster isKindOfClass:[UINavigationController class]]) {
-                    UITabBarController *tabBarController = (UITabBarController *)navigationControllerMaster.topViewController;
-                     if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                         
-                         if (splitViewController.isCollapsed) {
-                                         
-                             [navigationControllerMaster popToRootViewControllerAnimated:false];
-                             UINavigationController *navigationControllerMaster = (UINavigationController *)splitViewController.viewControllers.firstObject;
-                             if ([navigationControllerMaster isKindOfClass:[UINavigationController class]]) {
-                                 UITabBarController *tabBarController = (UITabBarController *)navigationControllerMaster.topViewController;
-                                 if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                                     [tabBarController setSelectedIndex: k_tabBarApplicationIndexMedia];
-                                 }
-                             }
-                        
-                         } else {
-                         
-                             if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                                 [tabBarController setSelectedIndex: k_tabBarApplicationIndexMedia];
-                             }
-                         }
-                     }
-                }
-            }
-        });
-        
-        handled = YES;
-    }
-    
-    return handled;
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== ApplicationIconBadgeNumber =====
 #pragma --------------------------------------------------------------------------------------------
@@ -776,223 +685,20 @@
     if (self.account.length == 0) { return; }
             
     NSInteger counterDownload = [[NCOperationQueue shared] downloadCount];
-    NSInteger counterUpload = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status == %d OR status == %d OR status == %d", k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading]].count;
+    NSInteger counterUpload = [[NCManageDatabase shared] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status == %d OR status == %d OR status == %d", k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading]].count;
     NSInteger total = counterDownload + counterUpload;
     
     [UIApplication sharedApplication].applicationIconBadgeNumber = total;
     
-    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-    if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
-        UINavigationController *navigationController = (UINavigationController *)[splitViewController.viewControllers firstObject];
-        if ([navigationController isKindOfClass:[UINavigationController class]]) {
-            UITabBarController *tabBarController = (UITabBarController *)navigationController.topViewController;
-            if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                UITabBarItem *tabBarItem = [tabBarController.tabBar.items objectAtIndex:0];
-                    
-                if (total > 0) {
-                    [tabBarItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)total]];
-                } else {
-                    [tabBarItem setBadgeValue:nil];
-                }
-            }
-        }
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== TabBarController =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)createTabBarController:(UITabBarController *)tabBarController
-{
-    UITabBarItem *item;
-    NSLayoutConstraint *constraint;
-    CGFloat safeAreaBottom = safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
-   
-    // File
-    item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexFile];
-    [item setTitle:NSLocalizedString(@"_home_", nil)];
-    item.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"tabBarFiles"] width:50 height:50 color:NCBrandColor.sharedInstance.brandElement];
-    item.selectedImage = item.image;
-    
-    // Favorites
-    item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexFavorite];
-    [item setTitle:NSLocalizedString(@"_favorites_", nil)];
-    item.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"favorite"] width:50 height:50 color:NCBrandColor.sharedInstance.brandElement];
-    item.selectedImage = item.image;
-    
-    // (PLUS INVISIBLE)
-    item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexPlusHide];
-    item.title = @"";
-    item.image = nil;
-    item.enabled = false;
-    
-    // Media
-    item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexMedia];
-    [item setTitle:NSLocalizedString(@"_media_", nil)];
-    item.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"media"] width:50 height:50 color:NCBrandColor.sharedInstance.brandElement];
-    item.selectedImage = item.image;
-    
-    // More
-    item = [tabBarController.tabBar.items objectAtIndex: k_tabBarApplicationIndexMore];
-    [item setTitle:NSLocalizedString(@"_more_", nil)];
-    item.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"tabBarMore"] width:50 height:50 color:NCBrandColor.sharedInstance.brandElement];
-    item.selectedImage = item.image;
-    
-    // Plus Button
-    int buttonSize = 57;
-    UIImage *buttonImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"tabBarPlus"] width:120 height:120 color:UIColor.whiteColor];
-    UIButton *buttonPlus = [UIButton buttonWithType:UIButtonTypeCustom];
-    buttonPlus.tag = 99;
-    buttonPlus.accessibilityLabel = NSLocalizedString(@"_accessibility_add_upload_", nil);
-    [buttonPlus setImage:buttonImage forState:UIControlStateNormal];
-    buttonPlus.backgroundColor = NCBrandColor.sharedInstance.brandElement;
-    buttonPlus.layer.cornerRadius = buttonSize / 2;
-    buttonPlus.layer.masksToBounds = NO;
-    buttonPlus.layer.shadowOffset = CGSizeMake(0, 0);
-    buttonPlus.layer.shadowRadius = 3.0f;
-    buttonPlus.layer.shadowOpacity = 0.5;
-    
-
-    [buttonPlus addTarget:self action:@selector(handleTouchTabbarCenter:) forControlEvents:UIControlEventTouchUpInside];
-    
-    [buttonPlus setTranslatesAutoresizingMaskIntoConstraints:NO];
-    [tabBarController.tabBar addSubview:buttonPlus];
-    
-
-    if (safeAreaBottom > 0) {
-        
-        // X
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:tabBarController.tabBar attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0];
-        [tabBarController.view addConstraint:constraint];
-        // Y
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:tabBarController.tabBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:-(buttonSize / 2)];
-        [tabBarController.view addConstraint:constraint];
-        // Width
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0 constant:buttonSize];
-        [tabBarController.view addConstraint:constraint];
-        // Height
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0 constant:buttonSize];
-        [tabBarController.view addConstraint:constraint];
-        
-    } else {
-        
-        // X
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:tabBarController.tabBar attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0];
-        [tabBarController.view addConstraint:constraint];
-        // Y
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:tabBarController.tabBar attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:-(buttonSize / 2)];
-        [tabBarController.view addConstraint:constraint];
-        // Width
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0 constant:buttonSize];
-        [tabBarController.view addConstraint:constraint];
-        // Height
-        constraint = [NSLayoutConstraint constraintWithItem:buttonPlus attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:1.0 constant:buttonSize];
-        [tabBarController.view addConstraint:constraint];
-    }
-}
-
-- (void)handleTouchTabbarCenter:(id)sender
-{
-    tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", self.account, self.activeServerUrl]];
-    
-    if ([tableDirectory.permissions containsString:@"CK"]) {
-        [self showMenuInViewController:self.window.rootViewController];
-    } else {
-        [[NCContentPresenter shared] messageNotification:@"_warning_" description:@"_no_permission_add_file_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:k_CCErrorInternalError forced:false];
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Theming Color =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)settingThemingColorBrand
-{
-    if (self.account.length == 0) { return; }
-    
-    if ([NCBrandOptions sharedInstance].use_themingColor) {
-        
-        NSString *themingColor = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColor];
-        NSString *themingColorElement = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
-        NSString *themingColorText = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorText];
-
-        [CCGraphics settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
-        
-        BOOL isTooLight = NCBrandColor.sharedInstance.brandElement.isTooLight;
-        BOOL isTooDark = NCBrandColor.sharedInstance.brandElement.isTooDark;
-        
-        if (isTooLight) {
-            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.brandElement darkerBy:30];
-        } else if (isTooDark) {
-            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.brandElement lighterBy:30];
-        }
-    
-    } else {
-    
-        BOOL isTooLight = NCBrandColor.sharedInstance.customer.isTooLight;
-        BOOL isTooDark = NCBrandColor.sharedInstance.customer.isTooDark;
-        
-        if (isTooLight) {
-            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.customer darkerBy:30];
-        } else if (isTooDark) {
-            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.customer lighterBy:30];
+    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
+    if ([tabBarController isKindOfClass:[UITabBarController class]]) {
+        UITabBarItem *tabBarItem = [tabBarController.tabBar.items objectAtIndex:0];
+        if (total > 0) {
+            [tabBarItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)total]];
         } else {
-            NCBrandColor.sharedInstance.brandElement = NCBrandColor.sharedInstance.customer;
-        }
-        
-        NCBrandColor.sharedInstance.brand = NCBrandColor.sharedInstance.customer;
-        NCBrandColor.sharedInstance.brandText = NCBrandColor.sharedInstance.customerText;
-    }
-        
-    [NCBrandColor.sharedInstance setDarkMode];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        [[NCCollectionCommon shared] createImagesThemingColor];
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
-    });
-}
-
-- (void)changeTheming:(UIViewController *)viewController tableView:(UITableView *)tableView collectionView:(UICollectionView *)collectionView form:(BOOL)form
-{
-    [NCBrandColor.sharedInstance setDarkMode];
-    [self.window setTintColor:NCBrandColor.sharedInstance.textView];
-
-    //Tab bar
-    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-    if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
-        UINavigationController *masterNavigationController = [splitViewController.viewControllers firstObject];
-        if ([masterNavigationController isKindOfClass:[UINavigationController class]]) {
-            UITabBarController *tabBarController = [masterNavigationController.viewControllers firstObject];
-            if ([tabBarController isKindOfClass:[UITabBarController class]]) {
-                tabBarController.tabBar.barTintColor = NCBrandColor.sharedInstance.backgroundView;
-                tabBarController.tabBar.backgroundColor = NCBrandColor.sharedInstance.tabBar;
-                tabBarController.tabBar.tintColor = NCBrandColor.sharedInstance.brandElement;
-                [tabBarController.tabBar viewWithTag:99].backgroundColor = NCBrandColor.sharedInstance.brandElement;
-            }
+            [tabBarItem setBadgeValue:nil];
         }
     }
-    
-    // Nav bar
-    [self configureNavBarForViewController:viewController];
-
-    // View
-    if (form) viewController.view.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
-    else viewController.view.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
-            
-    // TableView
-    if (tableView) {
-        if (form) tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
-        else tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
-        tableView.separatorColor = NCBrandColor.sharedInstance.separator;
-        [tableView reloadData];
-    }
-    
-    // CollectionView
-    if (collectionView) {
-        if (form) collectionView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
-        else collectionView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
-        [collectionView reloadData];
-    }
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -1009,7 +715,7 @@
     [[NCCommunicationCommon shared] writeLog:@"Start perform Fetch With Completion Handler"];
     
     // Verify new photo
-    [[NCAutoUpload sharedInstance] initStateAutoUpload];
+    [[NCAutoUpload shared] initStateAutoUpload];
     
     // after 20 sec
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
@@ -1074,19 +780,19 @@
                 
             } else {
             
-                tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+                tableAccount *account = [[NCManageDatabase shared] getAccountActive];
                 if (account) {
                     NSURL *accountURL = [NSURL URLWithString:account.urlBase];
                     NSString *accountUser = account.user;
                     if ([link containsString:accountURL.host] && [user isEqualToString:accountUser]) {
                         matchedAccount = account;
                     } else {
-                        NSArray *accounts = [[NCManageDatabase sharedInstance] getAllAccount];
+                        NSArray *accounts = [[NCManageDatabase shared] getAllAccount];
                         for (tableAccount *account in accounts) {
                             NSURL *accountURL = [NSURL URLWithString:account.urlBase];
                             NSString *accountUser = account.user;
                             if ([link containsString:accountURL.host] && [user isEqualToString:accountUser]) {
-                                matchedAccount = [[NCManageDatabase sharedInstance] setAccountActive:account.account];
+                                matchedAccount = [[NCManageDatabase shared] setAccountActive:account.account];
                                 [self settingAccount:matchedAccount.account urlBase:matchedAccount.urlBase user:matchedAccount.user userID:matchedAccount.userID password:[CCUtility getPassword:matchedAccount.account]];
                                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
                             }
@@ -1134,24 +840,16 @@
     NSArray *splitedUrl = [url.path componentsSeparatedByString:@"/"];
     self.fileNameUpload = [NSString stringWithFormat:@"%@",[splitedUrl objectAtIndex:([splitedUrl count]-1)]];
     
-    if (self.account) {
+    if (self.account && [[NSFileManager defaultManager] fileExistsAtPath:url.path]) {
         
-        [[NSFileManager defaultManager]removeItemAtPath:[NSTemporaryDirectory() stringByAppendingString:self.fileNameUpload] error:nil];
-        [[NSFileManager defaultManager]moveItemAtPath:url.path toPath:[NSTemporaryDirectory() stringByAppendingString:self.fileNameUpload] error:&error];
+        [[NSFileManager defaultManager] removeItemAtPath:[NSTemporaryDirectory() stringByAppendingString:self.fileNameUpload] error:nil];
+        [[NSFileManager defaultManager] moveItemAtPath:url.path toPath:[NSTemporaryDirectory() stringByAppendingString:self.fileNameUpload] error:&error];
         
         if (error == nil) {
-            
-            UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-            if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
-                UINavigationController *navigationControllerMaster = (UINavigationController *)splitViewController.viewControllers.firstObject;
-                if ([navigationControllerMaster isKindOfClass:[UINavigationController class]]) {
-                    UIViewController *uploadNavigationViewController = [[UIStoryboard storyboardWithName:@"CCUploadFromOtherUpp" bundle:nil] instantiateViewControllerWithIdentifier:@"CCUploadNavigationViewController"];
-                    
-                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-                        [navigationControllerMaster presentViewController:uploadNavigationViewController animated:YES completion:nil];
-                    });
-                }
-            }
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+                UIViewController *uploadNavigationViewController = [[UIStoryboard storyboardWithName:@"CCUploadFromOtherUpp" bundle:nil] instantiateViewControllerWithIdentifier:@"CCUploadNavigationViewController"];
+                [self.window.rootViewController presentViewController:uploadNavigationViewController animated:YES completion:nil];
+            });
         }
     }
     
@@ -1225,7 +923,7 @@
 
 - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
 {
-    [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions sharedInstance] brand] reply:^(BOOL success, NSError * _Nullable error) {
+    [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) {
         if (success) {
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 [passcodeViewController dismissViewControllerAnimated:YES completion:^{
@@ -1239,7 +937,7 @@
 - (void)enableTouchFaceID:(BOOL)automaticallyPromptForBiometricValidation
 {
     if (CCUtility.getEnableTouchFaceID && automaticallyPromptForBiometricValidation && self.passcodeViewController.view.window) {
-        [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions sharedInstance] brand] reply:^(BOOL success, NSError * _Nullable error) {
+        [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) {
             if (success) {
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                     [self.passcodeViewController dismissViewControllerAnimated:YES completion:^{

+ 1 - 1
iOSClient/AutoUpload/NCAutoUpload.h

@@ -29,7 +29,7 @@
 
 @interface NCAutoUpload : NSObject <CCManageLocationDelegate>
 
-+ (NCAutoUpload *)sharedInstance;
++ (NCAutoUpload *)shared;
 
 - (void)initStateAutoUpload;
 - (BOOL)checkIfLocationIsEnabled;

+ 95 - 98
iOSClient/AutoUpload/NCAutoUpload.m

@@ -24,6 +24,7 @@
 #import "NCAutoUpload.h"
 #import "AppDelegate.h"
 #import "NCBridgeSwift.h"
+#import "CCHud.h"
 
 #pragma GCC diagnostic ignored "-Wundeclared-selector"
 
@@ -31,23 +32,24 @@
 {
     AppDelegate *appDelegate;
     CCHud *_hud;
+    BOOL endForAssetToUpload;
 }
 @end
 
 @implementation NCAutoUpload
 
-+ (NCAutoUpload *)sharedInstance {
++ (NCAutoUpload *)shared {
     
-    static NCAutoUpload *sharedInstance;
+    static NCAutoUpload *shared;
     
     @synchronized(self)
     {
-        if (!sharedInstance) {
+        if (!shared) {
             
-            sharedInstance = [NCAutoUpload new];
-            sharedInstance->appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+            shared = [NCAutoUpload new];
+            shared->appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
         }
-        return sharedInstance;
+        return shared;
     }
 }
 
@@ -57,7 +59,7 @@
 
 - (void)initStateAutoUpload
 {
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
     
     if (account.autoUpload) {
         
@@ -70,7 +72,7 @@
         
     } else {
         
-        [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+        [[CCManageLocation shared] stopSignificantChangeUpdates];
     }
 }
 
@@ -86,12 +88,12 @@
         
     } else {
         
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+        tableAccount *account = [[NCManageDatabase shared] getAccountActive];
 
         if (account.autoUpload == YES)
-            [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUpload" state:NO];
+            [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUpload" state:NO];
         
-        [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+        [[CCManageLocation shared] stopSignificantChangeUpdates];
         
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_access_photo_not_enabled_", nil) message:NSLocalizedString(@"_access_photo_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
@@ -110,12 +112,12 @@
         
     } else {
         
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+        tableAccount *account = [[NCManageDatabase shared] getAccountActive];
 
         if (account.autoUpload == YES)
-            [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUpload" state:NO];
+            [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUpload" state:NO];
         
-        [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+        [[CCManageLocation shared] stopSignificantChangeUpdates];
         
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_access_photo_not_enabled_", nil) message:NSLocalizedString(@"_access_photo_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
@@ -131,9 +133,9 @@
 
 - (BOOL)checkIfLocationIsEnabled
 {
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
     
-    [CCManageLocation sharedInstance].delegate = self;
+    [CCManageLocation shared].delegate = self;
     
     if ([CLLocationManager locationServicesEnabled]) {
         
@@ -144,14 +146,14 @@
             if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined ) {
                 
                 [[NCCommunicationCommon shared] writeLog:@"Check if location is enabled: Location services not determined"];
-                [[CCManageLocation sharedInstance] startSignificantChangeUpdates];
+                [[CCManageLocation shared] startSignificantChangeUpdates];
                 
             } else {
                 
                 if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) {
                     
                     if (account.autoUploadBackground == YES)
-                        [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+                        [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
                     
                     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_location_not_enabled_", nil) message:NSLocalizedString(@"_location_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
                     UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
@@ -174,16 +176,16 @@
             if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) {
                 
                 if (account.autoUploadBackground == NO)
-                    [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:YES];
+                    [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:YES];
                 
-                [[CCManageLocation sharedInstance] startSignificantChangeUpdates];
+                [[CCManageLocation shared] startSignificantChangeUpdates];
                 
             } else {
                 
                 if (account.autoUploadBackground == YES)
-                    [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+                    [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
                 
-                [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+                [[CCManageLocation shared] stopSignificantChangeUpdates];
                 
                 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_access_photo_not_enabled_", nil) message:NSLocalizedString(@"_access_photo_not_enabled_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
                 UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
@@ -196,9 +198,9 @@
     } else {
         
         if (account.autoUploadBackground == YES)
-            [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+            [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
         
-        [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+        [[CCManageLocation shared] stopSignificantChangeUpdates];
         
         if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) {
             
@@ -218,13 +220,13 @@
         }
     }
     
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
     return tableAccount.autoUploadBackground;
 }
 
 - (void)statusAuthorizationLocationChanged
 {
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
     
     if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusNotDetermined){
         
@@ -232,12 +234,12 @@
             
             if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) {
                 
-                if ([CCManageLocation sharedInstance].firstChangeAuthorizationDone) {
+                if ([CCManageLocation shared].firstChangeAuthorizationDone) {
                     
                     if (account.autoUploadBackground == YES)
-                        [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+                        [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
                     
-                    [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+                    [[CCManageLocation shared] stopSignificantChangeUpdates];
                 }
                 
             } else {
@@ -253,9 +255,9 @@
             
             if (account.autoUploadBackground == YES) {
                 
-                [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+                [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
                 
-                [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+                [[CCManageLocation shared] stopSignificantChangeUpdates];
                 
                 if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) {
                     
@@ -276,9 +278,9 @@
             }
         }
         
-        if (![CCManageLocation sharedInstance].firstChangeAuthorizationDone) {
+        if (![CCManageLocation shared].firstChangeAuthorizationDone) {
             
-            [CCManageLocation sharedInstance].firstChangeAuthorizationDone = YES;
+            [CCManageLocation shared].firstChangeAuthorizationDone = YES;
         }
     }
 }
@@ -286,7 +288,7 @@
 - (void)changedLocation
 {
     // Only in background
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
     
     if (account.autoUpload && account.autoUploadBackground && [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
         
@@ -302,12 +304,12 @@
         } else {
             
             if (account.autoUpload == YES)
-                [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUpload" state:NO];
+                [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUpload" state:NO];
             
             if (account.autoUploadBackground == YES)
-                [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
+                [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
             
-            [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
+            [[CCManageLocation shared] stopSignificantChangeUpdates];
         }
     }
 }
@@ -332,17 +334,18 @@
 
 - (void)uploadAssetsNewAndFull:(NSString *)selector
 {
-    if (!appDelegate.account) { return; }
+    if (!appDelegate.account) return;
     
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
     if (tableAccount == nil) {
         return;
     }
     
     NSMutableArray *metadataFull = [NSMutableArray new];
-    NSString *autoUploadPath = [[NCManageDatabase sharedInstance] getAccountAutoUploadPathWithUrlBase:appDelegate.urlBase account:appDelegate.account];
+    NSString *autoUploadPath = [[NCManageDatabase shared] getAccountAutoUploadPathWithUrlBase:appDelegate.urlBase account:appDelegate.account];
     NSString *serverUrl;
-    
+    __block NSInteger counterLivePhoto = 0;
+
     // Check Asset : NEW or FULL
     NSArray *newAssetToUpload = [self getCameraRollAssets:tableAccount selector:selector alignPhotoLibrary:NO];
     
@@ -379,6 +382,7 @@
         return;
     }
     
+    endForAssetToUpload = false;
     for (PHAsset *asset in newAssetToUpload) {
         
         BOOL livePhoto = false;
@@ -393,7 +397,6 @@
         }
         
         // Select type of session
-        
         if ([selector isEqualToString:selectorUploadAutoUploadAll]) {
             session = NCCommunicationCommon.shared.sessionIdentifierUpload;
         } else {
@@ -417,12 +420,20 @@
         else
             serverUrl = autoUploadPath;
         
-        tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView == %@", appDelegate.account, serverUrl, fileName]];
-        if (!metadata) {
+        tableMetadata *metadata = [[NCManageDatabase shared] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView == %@", appDelegate.account, serverUrl, fileName]];
+        if (metadata) {
+            
+            if ([selector isEqualToString:selectorUploadAutoUpload]) {
+                [[NCManageDatabase shared] addPhotoLibrary:@[asset] account:appDelegate.account];
+            }
+            
+        } else {
         
-            tableMetadata *metadataForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:livePhoto];
+            /* INSERT METADATA FOR UPLOAD */
+            tableMetadata *metadataForUpload = [[NCManageDatabase shared] createMetadataWithAccount:appDelegate.account fileName:fileName ocId:[[NSUUID UUID] UUIDString] serverUrl:serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:livePhoto];
             
             metadataForUpload.assetLocalIdentifier = asset.localIdentifier;
+            metadataForUpload.livePhoto = livePhoto;
             metadataForUpload.session = session;
             metadataForUpload.sessionSelector = selector;
             metadataForUpload.size = [[NCUtilityFileSystem shared] getFileSizeWithAsset:asset];
@@ -432,84 +443,70 @@
             } else if (assetMediaType == PHAssetMediaTypeImage) {
                 metadataForUpload.typeFile = k_metadataTypeFile_image;
             }
+            
+            if ([selector isEqualToString:selectorUploadAutoUpload]) {
+               
+                [[NCManageDatabase shared] addMetadataForAutoUpload:metadataForUpload];
+                [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Automatic upload added %@ (%lu bytes) with Identifier %@", metadata.fileNameView, (unsigned long)metadata.size, metadata.assetLocalIdentifier]];
+                [[NCManageDatabase shared] addPhotoLibrary:@[asset] account:appDelegate.account];
+                
+            } else if ([selector isEqualToString:selectorUploadAutoUploadAll]) {
+                
+                [metadataFull addObject:metadataForUpload];
+            }
 
-            // Add Medtadata MOV LIVE PHOTO for upload
+            /* INSERT METADATA MOV LIVE PHOTO FOR UPLOAD */
             if (livePhoto) {
                 
+                counterLivePhoto++;
                 NSString *fileNameMove = [NSString stringWithFormat:@"%@.mov", fileName.stringByDeletingPathExtension];
                 NSString *ocId = [[NSUUID UUID] UUIDString];
                 NSString *filePath = [CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameMove];
-                
-                dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
-                
+                                
                 [CCUtility extractLivePhotoAsset:asset filePath:filePath withCompletion:^(NSURL *url) {
                     if (url != nil) {
-                        unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:url.path error:nil] fileSize];
                         
-                        tableMetadata *metadataMOVForUpload = [[NCManageDatabase sharedInstance] createMetadataWithAccount:appDelegate.account fileName:fileNameMove ocId:ocId serverUrl:serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:livePhoto];
-                        
-                        metadataForUpload.livePhoto = true;
+                        unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:url.path error:nil] fileSize];
+                        tableMetadata *metadataMOVForUpload = [[NCManageDatabase shared] createMetadataWithAccount:appDelegate.account fileName:fileNameMove ocId:ocId serverUrl:serverUrl urlBase:appDelegate.urlBase url:@"" contentType:@"" livePhoto:livePhoto];
+                       
                         metadataMOVForUpload.livePhoto = true;
-                        
                         metadataMOVForUpload.session = session;
                         metadataMOVForUpload.sessionSelector = selector;
                         metadataMOVForUpload.size = fileSize;
                         metadataMOVForUpload.status = k_metadataStatusWaitUpload;
                         metadataMOVForUpload.typeFile = k_metadataTypeFile_video;
 
-                        [metadataFull addObject:metadataMOVForUpload];
-                                                
-                        // Update database Auto Upload
                         if ([selector isEqualToString:selectorUploadAutoUpload]) {
-                            [[NCManageDatabase sharedInstance] addMetadataForAutoUpload:metadataMOVForUpload];
+                            
+                            [[NCManageDatabase shared] addMetadataForAutoUpload:metadataMOVForUpload];
                             [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Automatic upload added Live Photo %@ (%llu bytes)", fileNameMove, fileSize]];
+                            
+                        } else if ([selector isEqualToString:selectorUploadAutoUploadAll]) {
+                            
+                            [metadataFull addObject:metadataMOVForUpload];
                         }
                     }
-                    
-                    dispatch_semaphore_signal(semaphore);
+                    counterLivePhoto--;
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        if (endForAssetToUpload && counterLivePhoto == 0 && [selector isEqualToString:selectorUploadAutoUploadAll]) {
+                            [[NCManageDatabase shared] addMetadatas:metadataFull];
+                            [_hud hideHud];
+                        }
+                    });
                 }];
-                
-                while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
-                       [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:30]];
-            }
-            
-            [metadataFull addObject:metadataForUpload];
-                       
-            // Update database Auto Upload
-            if ([selector isEqualToString:selectorUploadAutoUpload]) {
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [self addQueueUploadAndPhotoLibrary:metadataForUpload asset:asset];
-                });
             }
         }
     }
+    endForAssetToUpload = true;
     
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-        // Insert all assets (Full) in tableQueueUpload
-        if ([selector isEqualToString:selectorUploadAutoUploadAll] && [metadataFull count] > 0) {
-            [[NCManageDatabase sharedInstance] addMetadatas:metadataFull];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (counterLivePhoto == 0 && [selector isEqualToString:selectorUploadAutoUploadAll]) {
+            [[NCManageDatabase shared] addMetadatas:metadataFull];
+            [_hud hideHud];
         }
-        // end loadingcand reload
-        [_hud hideHud];
-        // START
-        [[appDelegate networkingAutoUpload] startProcess];
     });
 }
 
-- (void)addQueueUploadAndPhotoLibrary:(tableMetadata *)metadata asset:(PHAsset *)asset
-{
-    @synchronized(self) {
-        
-        [[NCManageDatabase sharedInstance] addMetadataForAutoUpload:metadata];
-        [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Automatic upload added %@ (%lu bytes) with Identifier %@", metadata.fileNameView, (unsigned long)metadata.size, metadata.assetLocalIdentifier]];
-        
-        // Add asset in table Photo Library
-        if ([metadata.sessionSelector isEqualToString:selectorUploadAutoUpload]) {
-            (void)[[NCManageDatabase sharedInstance] addPhotoLibrary:@[asset] account:appDelegate.account];
-        }
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== get Camera Roll new Asset ====
 #pragma --------------------------------------------------------------------------------------------
@@ -560,7 +557,7 @@
                 NSString *creationDate;
                 NSString *idAsset;
 
-                NSArray *idsAsset = [[NCManageDatabase sharedInstance] getPhotoLibraryIdAssetWithImage:account.autoUploadImage video:account.autoUploadVideo account:account.account];
+                NSArray *idsAsset = [[NCManageDatabase shared] getPhotoLibraryIdAssetWithImage:account.autoUploadImage video:account.autoUploadVideo account:account.account];
                 
                 for (PHAsset *asset in assets) {
                     
@@ -590,13 +587,13 @@
 
 - (void)alignPhotoLibrary
 {
-    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    tableAccount *account = [[NCManageDatabase shared] getAccountActive];
 
     NSArray *assets = [self getCameraRollAssets:account selector:selectorUploadAutoUploadAll alignPhotoLibrary:YES];
    
-    [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:appDelegate.account];
+    [[NCManageDatabase shared] clearTable:[tablePhotoLibrary class] account:appDelegate.account];
     if (assets != nil) {
-        (void)[[NCManageDatabase sharedInstance] addPhotoLibrary:assets account:account.account];
+        (void)[[NCManageDatabase shared] addPhotoLibrary:assets account:account.account];
 
         [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Align Photo Library %lu", (unsigned long)[assets count]]];
     }

+ 8 - 8
iOSClient/Brand/Intro/NCIntroViewController.swift

@@ -43,8 +43,8 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        let isTooLight = NCBrandColor.sharedInstance.customer.isTooLight()
-        let isTooDark = NCBrandColor.sharedInstance.customer.isTooDark()
+        let isTooLight = NCBrandColor.shared.customer.isTooLight()
+        let isTooDark = NCBrandColor.shared.customer.isTooDark()
         
         if isTooLight {
             textColor = .black
@@ -68,13 +68,13 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
             self.navigationController?.navigationBar.shadowImage = UIImage()
             self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
             self.navigationController?.navigationBar.backgroundColor = .clear
-            self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.customer
+            self.navigationController?.navigationBar.barTintColor = NCBrandColor.shared.customer
         }
         self.navigationController?.navigationBar.tintColor = textColor
 
         
         self.pageControl.currentPageIndicatorTintColor = textColor
-        self.pageControl.pageIndicatorTintColor = NCBrandColor.sharedInstance.nextcloudSoft
+        self.pageControl.pageIndicatorTintColor = NCBrandColor.shared.nextcloudSoft
 
         self.buttonLogin.layer.cornerRadius = 20
         self.buttonLogin.setTitleColor(textColorOpponent, for: .normal)
@@ -93,9 +93,9 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
         self.introCollectionView.register(UINib(nibName: "NCIntroCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "introCell")
         self.introCollectionView.dataSource = self
         self.introCollectionView.delegate = self
-        self.introCollectionView.backgroundColor = NCBrandColor.sharedInstance.customer
+        self.introCollectionView.backgroundColor = NCBrandColor.shared.customer
         self.pageControl.numberOfPages = self.titles.count
-        self.view.backgroundColor = NCBrandColor.sharedInstance.customer
+        self.view.backgroundColor = NCBrandColor.shared.customer
         self.timerAutoScroll = Timer.scheduledTimer(timeInterval: 5, target: self, selector: (#selector(NCIntroViewController.autoScroll)), userInfo: nil, repeats: true)
     }
     
@@ -141,7 +141,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "introCell", for: indexPath) as! NCIntroCollectionViewCell
-        cell.backgroundColor = NCBrandColor.sharedInstance.customer
+        cell.backgroundColor = NCBrandColor.shared.customer
 
         cell.titleLabel.textColor = textColor
         cell.titleLabel.text = titles[indexPath.row]
@@ -175,7 +175,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
 
         let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb
 
-        browserWebVC?.urlBase = NCBrandOptions.sharedInstance.linkLoginHost
+        browserWebVC?.urlBase = NCBrandOptions.shared.linkLoginHost
 
         if let browserWebVC = browserWebVC {
             appDelegate?.window.rootViewController?.present(browserWebVC, animated: true)

+ 80 - 3
iOSClient/Brand/NCBrand.swift

@@ -26,7 +26,7 @@ import UIKit
 //MARK: - Configuration
 
 @objc class NCBrandConfiguration: NSObject {
-    @objc static let sharedInstance: NCBrandConfiguration = {
+    @objc static let shared: NCBrandConfiguration = {
         let instance = NCBrandConfiguration()
         return instance
     }()
@@ -40,7 +40,7 @@ import UIKit
 //MARK: - Options
 
 @objc class NCBrandOptions: NSObject {
-    @objc static let sharedInstance: NCBrandOptions = {
+    @objc static let shared: NCBrandOptions = {
         let instance = NCBrandOptions()
         return instance
     }()
@@ -96,7 +96,7 @@ import UIKit
 //MARK: - Color
 
 class NCBrandColor: NSObject {
-    @objc static let sharedInstance: NCBrandColor = {
+    @objc static let shared: NCBrandColor = {
         let instance = NCBrandColor()
         instance.setDarkMode()
         return instance
@@ -153,4 +153,81 @@ class NCBrandColor: NSObject {
             select = self.brandElement.withAlphaComponent(0.1)
         }
     }
+    
+#if !EXTENSION
+    @objc public 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)
+            
+            CCGraphics.settingThemingColor(themingColor, themingColorElement: themingColorElement, themingColorText: themingColorText)
+                        
+            if NCBrandColor.shared.brandElement.isTooLight() {
+                if let color = NCBrandColor.shared.brandElement.darker(by: darker) {
+                    NCBrandColor.shared.brandElement = color
+                }
+            } else if NCBrandColor.shared.brandElement.isTooDark() {
+                if let color = NCBrandColor.shared.brandElement.lighter(by: lighter) {
+                    NCBrandColor.shared.brandElement = color
+                }
+            }           
+            
+        } else {
+            
+            if NCBrandColor.shared.customer.isTooLight() {
+                if let color = NCBrandColor.shared.customer.darker(by: darker) {
+                    NCBrandColor.shared.brandElement = color
+                }
+            } else if NCBrandColor.shared.customer.isTooDark() {
+                if let color = NCBrandColor.shared.customer.lighter(by: lighter) {
+                    NCBrandColor.shared.brandElement = color
+                }
+            } else {
+                NCBrandColor.shared.brandElement = NCBrandColor.shared.customer
+            }
+            
+            NCBrandColor.shared.brand = NCBrandColor.shared.customer
+            NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
+        }
+        
+        setDarkMode()
+        
+        DispatchQueue.main.async {
+            NCCollectionCommon.shared.createImagesThemingColor()
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_changeTheming)
+        }
+    }
+#endif
+}
+
+//MARK: - Global
+
+@objc class NCBrandGlobal: NSObject {
+    @objc static let shared: NCBrandGlobal = {
+        let instance = NCBrandGlobal()
+        return instance
+    }()
+
+    // Directory on Group
+    @objc public let appDatabaseNextcloud: String   = "Library/Application Support/Nextcloud"
+
+    // Database Realm
+    public let databaseDefault: String              = "nextcloud.realm"
+    public let databaseSchemaVersion: UInt64        = 153
+    
+    // NCSharePaging
+    public let indexPageActivity: Int               = 0
+    public let indexPageComments: Int               = 1
+    public let indexPageSharing: Int                = 2
+    
+    // Nextcloud unsupported
+    public let nextcloud_unsupported_version: Int   = 13
 }

+ 4 - 4
iOSClient/BrowserWeb/NCBrowserWeb.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="OOi-qQ-BCK">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="OOi-qQ-BCK">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -11,7 +11,7 @@
         <!--Browser Web-->
         <scene sceneID="qXu-Mk-wdV">
             <objects>
-                <viewController id="OOi-qQ-BCK" customClass="NCBrowserWeb" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController hidesBottomBarWhenPushed="YES" id="OOi-qQ-BCK" customClass="NCBrowserWeb" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="Aai-ip-ntL">
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -28,12 +28,12 @@
                                 </connections>
                             </button>
                         </subviews>
+                        <viewLayoutGuide key="safeArea" id="fTU-bd-6qR"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
                             <constraint firstItem="Lht-2f-Ep4" firstAttribute="top" secondItem="fTU-bd-6qR" secondAttribute="top" constant="10" id="Qy7-ho-gnO"/>
                             <constraint firstItem="fTU-bd-6qR" firstAttribute="trailing" secondItem="Lht-2f-Ep4" secondAttribute="trailing" constant="10" id="brR-Ag-YH0"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="fTU-bd-6qR"/>
                     </view>
                     <connections>
                         <outlet property="buttonExit" destination="Lht-2f-Ep4" id="dsx-PX-MaQ"/>

+ 9 - 0
iOSClient/BrowserWeb/NCBrowserWeb.swift

@@ -35,6 +35,7 @@ class NCBrowserWeb: UIViewController {
     
     @objc var urlBase = ""
     @objc var isHiddenButtonExit = false
+    @objc var titleBrowser: String? = nil
     @objc weak var delegate: NCBrowserWebDelegate?
     
     @IBOutlet weak var buttonExit: UIButton!
@@ -61,6 +62,14 @@ class NCBrowserWeb: UIViewController {
         loadWebPage(webView: webView!, url: URL(string: urlBase)!)
     }
     
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        if let titleBrowser = titleBrowser {
+            navigationItem.title = titleBrowser
+        }
+    }
+    
     func loadWebPage(webView: WKWebView, url: URL)  {
         
         let language = NSLocale.preferredLanguages[0] as String

+ 34 - 43
iOSClient/CCGlobal.h

@@ -45,14 +45,13 @@
 //#if TARGET_OS_SIMULATOR
 //#endif
 
-//if indexPath.section <  collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) 
+//if indexPath.section <  collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section)
 
 #define CALL_ORIGIN NSLog(@"Origin: [%@]", [[[[NSThread callStackSymbols] objectAtIndex:1] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"[]"]] objectAtIndex:1])
 #endif
 
 // Directory on Group
 #define k_appApplicationSupport                         @"Library/Application Support"
-#define k_appDatabaseNextcloud                          @"Library/Application Support/Nextcloud"
 #define k_appUserData                                   @"Library/Application Support/UserData"
 #define k_appCertificates                               @"Library/Application Support/Certificates"
 #define k_appScan                                       @"Library/Application Support/Scan"
@@ -78,10 +77,6 @@
 #define k_sizePreview                                   1024
 #define k_sizeIcon                                      512
 
-// Database Realm
-#define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         149
-
 // Database JSON
 #define k_databaseDefaultJSON                           @"nextcloud.json"
 
@@ -168,7 +163,6 @@
 #define selectorLoadCopy                                @"loadCopy"
 #define selectorLoadOffline                             @"loadOffline"
 #define selectorOpenIn                                  @"openIn"
-#define selectorOpenInDetail                            @"openInDetail"
 #define selectorUploadAutoUpload                        @"uploadAutoUpload"
 #define selectorUploadAutoUploadAll                     @"uploadAutoUploadAll"
 #define selectorUploadFile                              @"uploadFile"
@@ -292,9 +286,6 @@
 #define k_template_spreadsheet                          @"spreadsheet"
 #define k_template_presentation                         @"presentation"
 
-// Nextcloud unsupported
-#define k_nextcloud_unsupported                         13
-
 // Nextcloud version
 #define k_nextcloud_version_12_0                        12
 #define k_nextcloud_version_13_0                        13
@@ -311,36 +302,36 @@
 #define k_notificationCenter_applicationDidEnterBackground  @"applicationDidEnterBackground"
 #define k_notificationCenter_applicationWillEnterForeground @"applicationWillEnterForeground"
 
-#define k_notificationCenter_initializeMain             @"initializeMain"
-#define k_notificationCenter_setTitleMain               @"setTitleMain"
-#define k_notificationCenter_changeTheming              @"changeTheming"
-#define k_notificationCenter_splitViewChangeDisplayMode @"splitViewChangeDisplayMode"
-#define k_notificationCenter_changeUserProfile          @"changeUserProfile"
-#define k_notificationCenter_richdocumentGrabFocus      @"richdocumentGrabFocus"
-#define k_notificationCenter_reloadDataNCShare          @"reloadDataNCShare"
-#define k_notificationCenter_closeRichWorkspaceWebView  @"closeRichWorkspaceWebView"
-
-#define k_notificationCenter_reloadDataSource           @"reloadDataSource"                 // userInfo: ocId?, serverUrl?
-#define k_notificationCenter_changeStatusFolderE2EE     @"changeStatusFolderE2EE"           // userInfo: serverUrl
-
-#define k_notificationCenter_downloadStartFile          @"downloadStartFile"                // userInfo: ocId
-#define k_notificationCenter_downloadedFile             @"downloadedFile"                   // userInfo: ocId, selector, errorCode, errorDescription
-#define k_notificationCenter_downloadCancelFile         @"downloadCancelFile"               // userInfo: ocId
-
-#define k_notificationCenter_uploadStartFile            @"uploadStartFile"                  // userInfo: ocId
-#define k_notificationCenter_uploadedFile               @"uploadedFile"                     // userInfo: ocId, ocIdTemp, errorCode, errorDescription
-#define k_notificationCenter_uploadCancelFile           @"uploadCancelFile"                 // userInfo: ocId
-
-#define k_notificationCenter_progressTask               @"progressTask"                     // userInfo: account, ocId, serverUrl, status, progress, totalBytes, totalBytesExpected
-
-#define k_notificationCenter_createFolder               @"createFolder"                     // userInfo: ocId
-#define k_notificationCenter_deleteFile                 @"deleteFile"                       // userInfo: ocId, fileNameView, typeFile, onlyLocal
-#define k_notificationCenter_renameFile                 @"renameFile"                       // userInfo: ocId, errorCode, errorDescription
-#define k_notificationCenter_moveFile                   @"moveFile"                         // userInfo: ocId, metadataNew
-#define k_notificationCenter_copyFile                   @"copyFile"                         // userInfo: ocId, serverUrlTo
-#define k_notificationCenter_favoriteFile               @"favoriteFile"                     // userInfo: ocId
-
-#define k_notificationCenter_menuSearchTextPDF          @"menuSearchTextPDF"
-#define k_notificationCenter_menuDownloadImage          @"menuDownloadImage"                // userInfo: ocId
-#define k_notificationCenter_menuSaveLivePhoto          @"menuSaveLivePhoto"                // userInfo: ocId, ocIdMov
-#define k_notificationCenter_menuDetailClose            @"menuDetailClose"
+#define k_notificationCenter_initializeMain                 @"initializeMain"
+#define k_notificationCenter_setTitleMain                   @"setTitleMain"
+#define k_notificationCenter_changeTheming                  @"changeTheming"
+#define k_notificationCenter_changeUserProfile              @"changeUserProfile"
+#define k_notificationCenter_richdocumentGrabFocus          @"richdocumentGrabFocus"
+#define k_notificationCenter_reloadDataNCShare              @"reloadDataNCShare"
+#define k_notificationCenter_closeRichWorkspaceWebView      @"closeRichWorkspaceWebView"
+
+#define k_notificationCenter_reloadDataSource               @"reloadDataSource"                 // userInfo: ocId?, serverUrl?
+#define k_notificationCenter_reloadDataSourceNetworkForced  @"reloadDataSourceNetworkForced"    // userInfo: serverUrl?
+
+#define k_notificationCenter_changeStatusFolderE2EE         @"changeStatusFolderE2EE"           // userInfo: serverUrl
+
+#define k_notificationCenter_downloadStartFile              @"downloadStartFile"                // userInfo: ocId
+#define k_notificationCenter_downloadedFile                 @"downloadedFile"                   // userInfo: ocId, selector, errorCode, errorDescription
+#define k_notificationCenter_downloadCancelFile             @"downloadCancelFile"               // userInfo: ocId
+
+#define k_notificationCenter_uploadStartFile                @"uploadStartFile"                  // userInfo: ocId
+#define k_notificationCenter_uploadedFile                   @"uploadedFile"                     // userInfo: ocId, ocIdTemp, errorCode, errorDescription
+#define k_notificationCenter_uploadCancelFile               @"uploadCancelFile"                 // userInfo: ocId
+
+#define k_notificationCenter_progressTask                   @"progressTask"                     // userInfo: account, ocId, serverUrl, status, progress, totalBytes, totalBytesExpected
+
+#define k_notificationCenter_createFolder                   @"createFolder"                     // userInfo: ocId
+#define k_notificationCenter_deleteFile                     @"deleteFile"                       // userInfo: ocId, fileNameView, typeFile, onlyLocal
+#define k_notificationCenter_renameFile                     @"renameFile"                       // userInfo: ocId, errorCode, errorDescription
+#define k_notificationCenter_moveFile                       @"moveFile"                         // userInfo: ocId, serverUrlTo
+#define k_notificationCenter_copyFile                       @"copyFile"                         // userInfo: ocId, serverUrlFrom
+#define k_notificationCenter_favoriteFile                   @"favoriteFile"                     // userInfo: ocId
+
+#define k_notificationCenter_menuSearchTextPDF              @"menuSearchTextPDF"
+#define k_notificationCenter_menuSaveLivePhoto              @"menuSaveLivePhoto"                // userInfo: ocId, ocIdMov
+#define k_notificationCenter_menuDetailClose                @"menuDetailClose"

+ 4 - 4
iOSClient/Data/NCDataSource.swift

@@ -108,7 +108,7 @@ class NCDataSource: NSObject {
             }
             
             // share
-            let shares = NCManageDatabase.sharedInstance.getTableShares(account: metadata.account, serverUrl: metadata.serverUrl, fileName: metadata.fileName)
+            let shares = NCManageDatabase.shared.getTableShares(account: metadata.account, serverUrl: metadata.serverUrl, fileName: metadata.fileName)
             if shares.count > 0 {
                 metadataShare[metadata.ocId] = shares.first
             }
@@ -117,9 +117,9 @@ class NCDataSource: NSObject {
             if !metadata.directory {
                 let size = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
                 if size > 0 {
-                    let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                    let tableLocalFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                     if tableLocalFile == nil && size == metadata.size {
-                        NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
+                        NCManageDatabase.shared.addLocalFile(metadata: metadata)
                     }
                     if tableLocalFile?.offline ?? false {
                         metadataOffLine.append(metadata.ocId)
@@ -190,7 +190,7 @@ class NCDataSource: NSObject {
         }
         
         if index != nil {
-            if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 metadatas[index!] = metadata
             } 
         }

+ 27 - 1
iOSClient/Data/NCDatabase.swift

@@ -69,6 +69,13 @@ class tableAccount: Object {
     @objc dynamic var urlBase = ""
     @objc dynamic var user = ""
     @objc dynamic var userID = ""
+    @objc dynamic var userStatusClearAt: NSDate? = nil
+    @objc dynamic var userStatusIcon: String?
+    @objc dynamic var userStatusMessage: String?
+    @objc dynamic var userStatusMessageId: String?
+    @objc dynamic var userStatusMessageIsPredefined: Bool = false
+    @objc dynamic var userStatusStatus: String?
+    @objc dynamic var userStatusStatusIsUserDefined: Bool = false
     @objc dynamic var webpage = ""
     @objc dynamic var zip = ""
     // HC
@@ -214,7 +221,8 @@ class tableDirectory: Object {
     @objc dynamic var permissions = ""
     @objc dynamic var richWorkspace: String?
     @objc dynamic var serverUrl = ""
-    
+    @objc dynamic var synchronized: Bool = false
+
     override static func primaryKey() -> String {
         return "ocId"
     }
@@ -396,6 +404,10 @@ class tableShare: Object {
     @objc dynamic var uidFileOwner = ""
     @objc dynamic var uidOwner = ""
     @objc dynamic var url = ""
+    @objc dynamic var userClearAt: NSDate? = nil
+    @objc dynamic var userIcon = ""
+    @objc dynamic var userMessage = ""
+    @objc dynamic var userStatus = ""
 
     override static func primaryKey() -> String {
         return "idShare"
@@ -435,6 +447,20 @@ class tableTrash: Object {
     }
 }
 
+class tableUserStatus: Object {
+    
+    @objc dynamic var account = ""
+    @objc dynamic var clearAt: NSDate?
+    @objc dynamic var clearAtTime: String?
+    @objc dynamic var clearAtType: String?
+    @objc dynamic var icon: String?
+    @objc dynamic var id: String?
+    @objc dynamic var message: String?
+    @objc dynamic var predefined: Bool = false
+    @objc dynamic var status: String?
+    @objc dynamic var userId: String?
+}
+
 class tableVideo: Object {
     
     @objc dynamic var account = ""

+ 3 - 0
iOSClient/Data/NCElementsJSON.swift

@@ -59,4 +59,7 @@ import Foundation
     @objc public let capabilitiesPaginationEndpoint:            Array = ["ocs","data","capabilities","files","pagination","endpoint"]
 
     @objc public let capabilitiesHWCEnabled:                    Array = ["ocs","data","capabilities","handwerkcloud","enabled"]
+    
+    @objc public let capabilitiesUserStatusEnabled:             Array = ["ocs","data","capabilities","user_status","enabled"]
+    @objc public let capabilitiesUserStatusSupportsEmoji:       Array = ["ocs","data","capabilities","user_status","supports_emoji"]
 }

+ 127 - 22
iOSClient/Data/NCManageDatabase.swift

@@ -26,15 +26,15 @@ import NCCommunication
 import SwiftyJSON
 
 class NCManageDatabase: NSObject {
-    @objc static let sharedInstance: NCManageDatabase = {
+    @objc static let shared: NCManageDatabase = {
         let instance = NCManageDatabase()
         return instance
     }()
     
     override init() {
         
-        let dirGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.sharedInstance.capabilitiesGroups)
-        let databaseFilePath = dirGroup?.appendingPathComponent("\(k_appDatabaseNextcloud)/\(k_databaseDefault)")
+        let dirGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)
+        let databaseFilePath = dirGroup?.appendingPathComponent(NCBrandGlobal.shared.appDatabaseNextcloud + "/" + NCBrandGlobal.shared.databaseDefault)
 
         let bundleUrl: URL = Bundle.main.bundleURL
         let bundlePathExtension: String = bundleUrl.pathExtension
@@ -45,8 +45,8 @@ class NCManageDatabase: NSObject {
             // App Extension config
             
             let config = Realm.Configuration(
-                fileURL: dirGroup?.appendingPathComponent("\(k_appDatabaseNextcloud)/\(k_databaseDefault)"),
-                schemaVersion: UInt64(k_databaseSchemaVersion),
+                fileURL: dirGroup?.appendingPathComponent(NCBrandGlobal.shared.appDatabaseNextcloud + "/" + NCBrandGlobal.shared.databaseDefault),
+                schemaVersion: NCBrandGlobal.shared.databaseSchemaVersion,
                 objectTypes: [tableMetadata.self, tableLocalFile.self, tableDirectory.self, tableTag.self, tableAccount.self, tableCapabilities.self, tableE2eEncryption.self]
             )
             
@@ -59,7 +59,7 @@ class NCManageDatabase: NSObject {
             let configCompact = Realm.Configuration(
                 
                 fileURL: databaseFilePath,
-                schemaVersion: UInt64(k_databaseSchemaVersion),
+                schemaVersion: NCBrandGlobal.shared.databaseSchemaVersion,
                 
                 migrationBlock: { migration, oldSchemaVersion in
                                         
@@ -144,8 +144,8 @@ class NCManageDatabase: NSObject {
             }
                         
             let config = Realm.Configuration(
-                fileURL: dirGroup?.appendingPathComponent("\(k_appDatabaseNextcloud)/\(k_databaseDefault)"),
-                schemaVersion: UInt64(k_databaseSchemaVersion)
+                fileURL: dirGroup?.appendingPathComponent(NCBrandGlobal.shared.appDatabaseNextcloud + "/" + NCBrandGlobal.shared.databaseDefault),
+                schemaVersion: NCBrandGlobal.shared.databaseSchemaVersion
             )
             
             Realm.Configuration.defaultConfiguration = config
@@ -213,6 +213,7 @@ class NCManageDatabase: NSObject {
         self.clearTable(tableShare.self, account: account)
         self.clearTable(tableTag.self, account: account)
         self.clearTable(tableTrash.self, account: account)
+        self.clearTable(tableUserStatus.self, account: account)
         self.clearTable(tableVideo.self, account: account)
 
         if removeAccount {
@@ -240,13 +241,13 @@ class NCManageDatabase: NSObject {
     
     @objc func getThreadConfined(_ object: Object) -> Any {
      
-        // id tradeReference = [[NCManageDatabase sharedInstance] getThreadConfined:metadata];
+        // id tradeReference = [[NCManageDatabase shared] getThreadConfined:metadata];
         return ThreadSafeReference(to: object)
     }
     
     @objc func putThreadConfined(_ tableRef: Any) -> Object? {
         
-        //tableMetadata *metadataThread = (tableMetadata *)[[NCManageDatabase sharedInstance] putThreadConfined:tradeReference];
+        //tableMetadata *metadataThread = (tableMetadata *)[[NCManageDatabase shared] putThreadConfined:tradeReference];
         let realm = try! Realm()
         
         return realm.resolve(tableRef as! ThreadSafeReference<Object>)
@@ -275,7 +276,7 @@ class NCManageDatabase: NSObject {
                 addObject.account = account
                 
                 // Brand
-                if NCBrandOptions.sharedInstance.use_default_auto_upload {
+                if NCBrandOptions.shared.use_default_auto_upload {
                         
                     addObject.autoUpload = true
                     addObject.autoUploadImage = true
@@ -379,7 +380,7 @@ class NCManageDatabase: NSObject {
         if result.autoUploadFileName.count > 0 {
             return result.autoUploadFileName
         } else {
-            return NCBrandOptions.sharedInstance.folderDefaultAutoUpload
+            return NCBrandOptions.shared.folderDefaultAutoUpload
         }
     }
     
@@ -658,6 +659,26 @@ class NCManageDatabase: NSObject {
         }
     }
     
+    @objc func setAccountUserStatus(userStatusClearAt: NSDate?, userStatusIcon: String?, userStatusMessage: String?, userStatusMessageId: String?, userStatusMessageIsPredefined: Bool, userStatusStatus: String?, userStatusStatusIsUserDefined: Bool, account: String) {
+        
+        let realm = try! Realm()
+        do {
+            try realm.safeWrite {
+                if let result = realm.objects(tableAccount.self).filter("account == %@", account).first {
+                    result.userStatusClearAt = userStatusClearAt
+                    result.userStatusIcon = userStatusIcon
+                    result.userStatusMessage = userStatusMessage
+                    result.userStatusMessageId = userStatusMessageId
+                    result.userStatusMessageIsPredefined = userStatusMessageIsPredefined
+                    result.userStatusStatus = userStatusStatus
+                    result.userStatusStatusIsUserDefined = userStatusStatusIsUserDefined
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
     //MARK: -
     //MARK: Table Activity
 
@@ -1233,6 +1254,46 @@ class NCManageDatabase: NSObject {
             NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
         }
     }
+    
+    @objc func setDirectory(synchronized: Bool, serverUrl: String, account: String) {
+        
+        let realm = try! Realm()
+                
+        do {
+            try realm.safeWrite {
+                let result = realm.objects(tableDirectory.self).filter("account == %@ AND serverUrl == %@", account, serverUrl).first
+                result?.synchronized = synchronized
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
+    func removeDirectoriesSynchronized(serverUrl: String, account: String) {
+        
+        setDirectory(synchronized: false, serverUrl: serverUrl, account: account)
+        let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", account, serverUrl))
+        for metadata in metadatas {
+            let serverUrl = metadata.serverUrl + "/" + metadata.fileName
+            setDirectory(synchronized: false, serverUrl: serverUrl, account: account)
+        }
+    }
+    
+    @objc func removeAllDirectoriesSynchronized(account: String) {
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.safeWrite {
+                let results = realm.objects(tableDirectory.self).filter("account == %@ AND synchronized == true", account)
+                for result in results {
+                    result.synchronized = false
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
 
     //MARK: -
     //MARK: Table e2e Encryption
@@ -1643,7 +1704,7 @@ class NCManageDatabase: NSObject {
         
         // E2EE find the fileName for fileNameView
         if isEncrypted || metadata.e2eEncrypted {
-            if let tableE2eEncryption = NCManageDatabase.sharedInstance.getE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameIdentifier == %@", account, file.serverUrl, file.fileName)) {
+            if let tableE2eEncryption = NCManageDatabase.shared.getE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameIdentifier == %@", account, file.serverUrl, file.fileName)) {
                 metadata.fileNameView = tableE2eEncryption.fileName
                 let results = NCCommunicationCommon.shared.getInternalContenType(fileName: metadata.fileNameView, contentType: file.contentType, directory: file.directory)
                 metadata.contentType = results.contentType
@@ -1828,7 +1889,7 @@ class NCManageDatabase: NSObject {
     }
 
     @discardableResult
-    func updateMetadatas(_ metadatas: [tableMetadata], metadatasResult: [tableMetadata], addCompareLivePhoto: Bool = true, addExistsInLocal: Bool = false, addCompareEtagLocal: Bool = false) -> (metadatasUpdate: [tableMetadata], metadatasLocalUpdate: [tableMetadata]) {
+    func updateMetadatas(_ metadatas: [tableMetadata], metadatasResult: [tableMetadata], addCompareLivePhoto: Bool = true, addExistsInLocal: Bool = false, addCompareEtagLocal: Bool = false, addDirectorySynchronized: Bool = false) -> (metadatasUpdate: [tableMetadata], metadatasLocalUpdate: [tableMetadata]) {
         
         let realm = try! Realm()
         var ocIdsUdate : [String] = []
@@ -1872,6 +1933,8 @@ class NCManageDatabase: NSObject {
                         let table = realm.objects(tableDirectory.self).filter(NSPredicate(format: "ocId == %@", metadata.ocId)).first
                         if table?.etag != metadata.etag {
                             ocIdsUdate.append(metadata.ocId)
+                        } else if addDirectorySynchronized && table?.synchronized == false {
+                            ocIdsUdate.append(metadata.ocId)
                         }
                     }
                     
@@ -2162,7 +2225,7 @@ class NCManageDatabase: NSObject {
             serverUrl = ".."
         } else {
             fileName = (serverUrl as NSString).lastPathComponent
-            serverUrl = CCUtility.deletingLastPathComponent(fromServerUrl: serverUrl)
+            serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl: serverUrl, urlBase: urlBase, account: account)
         }
         
         guard let result = realm.objects(tableMetadata.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", account, serverUrl, fileName).first else { return nil }
@@ -2287,7 +2350,7 @@ class NCManageDatabase: NSObject {
             isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder!.permissions.contains(k_permission_shared)
             isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder!.permissions.contains(k_permission_mounted)
             
-        } else if let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl))  {
+        } else if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl))  {
                 
             isShare = metadata.permissions.contains(k_permission_shared) && !directory.permissions.contains(k_permission_shared)
             isMounted = metadata.permissions.contains(k_permission_mounted) && !directory.permissions.contains(k_permission_mounted)
@@ -2303,6 +2366,7 @@ class NCManageDatabase: NSObject {
     //MARK: -
     //MARK: Table Photo Library
     
+    @discardableResult
     @objc func addPhotoLibrary(_ assets: [PHAsset], account: String) -> Bool {
         
         let realm = try! Realm()
@@ -2390,7 +2454,7 @@ class NCManageDatabase: NSObject {
             
             let addObject = tableShare()
             let fullPath = NCUtility.shared.getHomeServer(urlBase: urlBase, account: account) + share.path
-            let serverUrl = CCUtility.deletingLastPathComponent(fromServerUrl: fullPath)!
+            let serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl:fullPath, urlBase: urlBase, account: account)
             let fileName = NSString(string: fullPath).lastPathComponent
                         
             addObject.account = account
@@ -2428,6 +2492,10 @@ class NCManageDatabase: NSObject {
             addObject.uidOwner = share.uidOwner
             addObject.uidFileOwner = share.uidFileOwner
             addObject.url = share.url
+            addObject.userClearAt = share.userClearAt
+            addObject.userIcon = share.userIcon
+            addObject.userMessage = share.userMessage
+            addObject.userStatus = share.userStatus
 
             realm.add(addObject, update: .all)
         }
@@ -2687,11 +2755,47 @@ class NCManageDatabase: NSObject {
         return tableTrash.init(value: result)
     }
     
+    //MARK: -
+    //MARK: Table UserStatus
+    
+    @objc func addUserStatus(_ userStatuses: [NCCommunicationUserStatus], account: String, predefined: Bool) {
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.safeWrite {
+                
+                let results = realm.objects(tableUserStatus.self).filter("account == %@ AND predefined == %@", account, predefined)
+                realm.delete(results)
+                
+                for userStatus in userStatuses {
+                    
+                    let object = tableUserStatus()
+                    
+                    object.account = account
+                    object.clearAt = userStatus.clearAt
+                    object.clearAtTime = userStatus.clearAtTime
+                    object.clearAtType = userStatus.clearAtType
+                    object.icon = userStatus.icon
+                    object.id = userStatus.id
+                    object.message = userStatus.message
+                    object.predefined = userStatus.predefined
+                    object.status = userStatus.status
+                    object.userId = userStatus.userId
+                    
+                    realm.add(object)
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
     //MARK: -
     //MARK: Table Video
     
-    func addVideoTime(account: String, ocId: String, time: CMTime?) {
+    func addVideoTime(metadata: tableMetadata, time: CMTime?) {
         
+        if metadata.livePhoto { return }
         guard let time = time else { return }
         let realm = try! Realm()
         
@@ -2699,8 +2803,8 @@ class NCManageDatabase: NSObject {
             try realm.safeWrite {
                 let addObject = tableVideo()
                
-                addObject.account = account
-                addObject.ocId = ocId
+                addObject.account = metadata.account
+                addObject.ocId = metadata.ocId
                 addObject.time = Int64(CMTimeGetSeconds(time) * 1000)
               
                 realm.add(addObject, update: .all)
@@ -2710,11 +2814,12 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    func getVideoTime(account: String, ocId: String) -> CMTime? {
+    func getVideoTime(metadata: tableMetadata) -> CMTime? {
         
+        if metadata.livePhoto { return CMTime.zero }
         let realm = try! Realm()
         
-        guard let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", account, ocId).first else {
+        guard let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", metadata.account, metadata.ocId).first else {
             return nil
         }
         

+ 98 - 10
iOSClient/Diagnostics/NCCapabilitiesViewController.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -21,7 +21,7 @@
                                 <rect key="frame" x="0.0" y="88" width="414" height="774"/>
                                 <subviews>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Sms-Ez-fLO" userLabel="View Capabilities">
-                                        <rect key="frame" x="5" y="5" width="404" height="450"/>
+                                        <rect key="frame" x="5" y="5" width="404" height="550"/>
                                         <subviews>
                                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jdW-oZ-cH8" userLabel="FileSharing">
                                                 <rect key="frame" x="0.0" y="0.0" width="404" height="50"/>
@@ -368,15 +368,95 @@
                                                     <constraint firstItem="Tq3-cS-wup" firstAttribute="centerY" secondItem="LTt-2C-rPb" secondAttribute="centerY" id="xlI-tP-AMe"/>
                                                 </constraints>
                                             </view>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Pp-Kb-YMc" userLabel="User Status">
+                                                <rect key="frame" x="0.0" y="450" width="404" height="50"/>
+                                                <subviews>
+                                                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="userStatusAway" translatesAutoresizingMaskIntoConstraints="NO" id="Nxp-H1-Pob">
+                                                        <rect key="frame" x="0.0" y="10" width="30" height="30"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="height" constant="30" id="qzU-OP-bvd"/>
+                                                            <constraint firstAttribute="width" constant="30" id="t5O-mN-Xyd"/>
+                                                        </constraints>
+                                                    </imageView>
+                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="User Status" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LID-IE-L9Z">
+                                                        <rect key="frame" x="40" y="16" width="80.5" height="18"/>
+                                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                                        <nil key="textColor"/>
+                                                        <nil key="highlightedColor"/>
+                                                    </label>
+                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Sj-5h-jgb">
+                                                        <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="width" constant="120" id="IJ3-gv-UjC"/>
+                                                            <constraint firstAttribute="height" constant="25" id="wiA-JQ-GDr"/>
+                                                        </constraints>
+                                                        <fontDescription key="fontDescription" type="system" pointSize="12"/>
+                                                        <nil key="textColor"/>
+                                                        <nil key="highlightedColor"/>
+                                                    </label>
+                                                </subviews>
+                                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                                <constraints>
+                                                    <constraint firstItem="LID-IE-L9Z" firstAttribute="leading" secondItem="Nxp-H1-Pob" secondAttribute="trailing" constant="10" id="4Pl-0O-5J4"/>
+                                                    <constraint firstItem="Nxp-H1-Pob" firstAttribute="leading" secondItem="2Pp-Kb-YMc" secondAttribute="leading" id="9yK-6i-taC"/>
+                                                    <constraint firstAttribute="height" constant="50" id="UUO-ej-PcK"/>
+                                                    <constraint firstAttribute="trailing" secondItem="5Sj-5h-jgb" secondAttribute="trailing" constant="5" id="iu9-2g-hKA"/>
+                                                    <constraint firstItem="LID-IE-L9Z" firstAttribute="centerY" secondItem="2Pp-Kb-YMc" secondAttribute="centerY" id="lFh-r6-Yvh"/>
+                                                    <constraint firstItem="Nxp-H1-Pob" firstAttribute="centerY" secondItem="2Pp-Kb-YMc" secondAttribute="centerY" id="ocY-iN-t73"/>
+                                                    <constraint firstItem="5Sj-5h-jgb" firstAttribute="centerY" secondItem="2Pp-Kb-YMc" secondAttribute="centerY" id="peY-Iv-kLA"/>
+                                                </constraints>
+                                            </view>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S24-Wc-fps" userLabel="Comments">
+                                                <rect key="frame" x="0.0" y="498" width="404" height="50"/>
+                                                <subviews>
+                                                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="comments" translatesAutoresizingMaskIntoConstraints="NO" id="cYf-px-izj">
+                                                        <rect key="frame" x="0.0" y="10" width="30" height="30"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="width" constant="30" id="gdA-CQ-Wu0"/>
+                                                            <constraint firstAttribute="height" constant="30" id="xGI-Zv-SQC"/>
+                                                        </constraints>
+                                                    </imageView>
+                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Comments" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AEw-vE-bsf">
+                                                        <rect key="frame" x="40" y="16" width="74.5" height="18"/>
+                                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                                        <nil key="textColor"/>
+                                                        <nil key="highlightedColor"/>
+                                                    </label>
+                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lVT-MG-7kN">
+                                                        <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="width" constant="120" id="TPY-VV-LmQ"/>
+                                                            <constraint firstAttribute="height" constant="25" id="WwT-hU-yOT"/>
+                                                        </constraints>
+                                                        <fontDescription key="fontDescription" type="system" pointSize="12"/>
+                                                        <nil key="textColor"/>
+                                                        <nil key="highlightedColor"/>
+                                                    </label>
+                                                </subviews>
+                                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="50" id="3iW-tC-sQm"/>
+                                                    <constraint firstItem="AEw-vE-bsf" firstAttribute="leading" secondItem="cYf-px-izj" secondAttribute="trailing" constant="10" id="6bS-1j-tEi"/>
+                                                    <constraint firstItem="lVT-MG-7kN" firstAttribute="centerY" secondItem="S24-Wc-fps" secondAttribute="centerY" id="6zR-QZ-UEn"/>
+                                                    <constraint firstItem="cYf-px-izj" firstAttribute="leading" secondItem="S24-Wc-fps" secondAttribute="leading" id="Ahj-Nc-bRa"/>
+                                                    <constraint firstItem="cYf-px-izj" firstAttribute="centerY" secondItem="S24-Wc-fps" secondAttribute="centerY" id="BO8-tt-rX5"/>
+                                                    <constraint firstItem="AEw-vE-bsf" firstAttribute="centerY" secondItem="S24-Wc-fps" secondAttribute="centerY" id="ete-pJ-l2X"/>
+                                                    <constraint firstAttribute="trailing" secondItem="lVT-MG-7kN" secondAttribute="trailing" constant="5" id="zCZ-du-XT5"/>
+                                                </constraints>
+                                            </view>
                                         </subviews>
                                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                         <constraints>
                                             <constraint firstItem="lGp-bh-Ysz" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="0qE-PV-O2f"/>
                                             <constraint firstAttribute="trailing" secondItem="8nf-zJ-Qas" secondAttribute="trailing" id="0vv-HQ-Qqx"/>
-                                            <constraint firstAttribute="height" constant="450" id="6nU-Cb-MzH"/>
+                                            <constraint firstAttribute="height" constant="550" id="6nU-Cb-MzH"/>
                                             <constraint firstItem="mSC-JU-xuk" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="9Nq-du-3ah"/>
+                                            <constraint firstItem="S24-Wc-fps" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="Aad-cm-E1T"/>
+                                            <constraint firstAttribute="trailing" secondItem="S24-Wc-fps" secondAttribute="trailing" id="Ajf-er-GBr"/>
                                             <constraint firstItem="ZNB-jF-9zg" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="GdE-lt-vZC"/>
                                             <constraint firstAttribute="trailing" secondItem="nVq-4i-FNy" secondAttribute="trailing" id="HSG-Ia-fYc"/>
+                                            <constraint firstItem="S24-Wc-fps" firstAttribute="top" secondItem="2Pp-Kb-YMc" secondAttribute="bottom" constant="-2" id="ML8-GT-9hb"/>
+                                            <constraint firstAttribute="trailing" secondItem="2Pp-Kb-YMc" secondAttribute="trailing" id="NG8-Nu-ic6"/>
                                             <constraint firstItem="LTt-2C-rPb" firstAttribute="top" secondItem="dhs-06-3RT" secondAttribute="bottom" id="Nm6-NH-AC9"/>
                                             <constraint firstItem="UPC-L1-VKj" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="QcN-sd-pHM"/>
                                             <constraint firstItem="LTt-2C-rPb" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="SUy-Mo-oAO"/>
@@ -391,7 +471,9 @@
                                             <constraint firstItem="nVq-4i-FNy" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="efi-mm-hvP"/>
                                             <constraint firstAttribute="trailing" secondItem="LTt-2C-rPb" secondAttribute="trailing" id="erZ-V1-p76"/>
                                             <constraint firstAttribute="trailing" secondItem="UPC-L1-VKj" secondAttribute="trailing" id="f2Y-D9-fMV"/>
+                                            <constraint firstItem="2Pp-Kb-YMc" firstAttribute="leading" secondItem="Sms-Ez-fLO" secondAttribute="leading" id="fQm-C9-02f"/>
                                             <constraint firstAttribute="trailing" secondItem="dhs-06-3RT" secondAttribute="trailing" id="ijj-gU-Gdk"/>
+                                            <constraint firstItem="2Pp-Kb-YMc" firstAttribute="top" secondItem="LTt-2C-rPb" secondAttribute="bottom" id="jbS-we-vDH"/>
                                             <constraint firstAttribute="trailing" secondItem="jdW-oZ-cH8" secondAttribute="trailing" id="k81-ap-Nwy"/>
                                             <constraint firstItem="lGp-bh-Ysz" firstAttribute="top" secondItem="nVq-4i-FNy" secondAttribute="bottom" id="l7m-bA-t7c"/>
                                             <constraint firstItem="dhs-06-3RT" firstAttribute="top" secondItem="ZNB-jF-9zg" secondAttribute="bottom" id="mJv-Ta-ZbY"/>
@@ -402,7 +484,7 @@
                                         </constraints>
                                     </view>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ogC-ph-Xdr" userLabel="View Link">
-                                        <rect key="frame" x="5" y="470" width="404" height="90"/>
+                                        <rect key="frame" x="5" y="550" width="404" height="90"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Home server" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PD5-8h-ZLm">
                                                 <rect key="frame" x="40" y="0.0" width="359" height="40"/>
@@ -453,12 +535,12 @@
                                         </constraints>
                                     </view>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OO4-N7-9vp" userLabel="View JSON">
-                                        <rect key="frame" x="0.0" y="600" width="414" height="43"/>
+                                        <rect key="frame" x="0.0" y="650" width="414" height="40.5"/>
                                         <subviews>
                                             <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="RIO-6X-GG1">
-                                                <rect key="frame" x="5" y="5" width="404" height="33"/>
+                                                <rect key="frame" x="5" y="5" width="404" height="30.5"/>
                                                 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
-                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="12"/>
                                                 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
                                             </textView>
                                         </subviews>
@@ -472,8 +554,8 @@
                                     </view>
                                 </subviews>
                                 <constraints>
-                                    <constraint firstItem="ogC-ph-Xdr" firstAttribute="top" secondItem="hTE-ys-qsF" secondAttribute="top" constant="470" id="9yP-Qs-EjJ"/>
-                                    <constraint firstItem="OO4-N7-9vp" firstAttribute="top" secondItem="hTE-ys-qsF" secondAttribute="top" constant="600" id="A9O-TK-Vz6" userLabel="View JSON.top = top + 550"/>
+                                    <constraint firstItem="ogC-ph-Xdr" firstAttribute="top" secondItem="hTE-ys-qsF" secondAttribute="top" constant="550" id="9yP-Qs-EjJ"/>
+                                    <constraint firstItem="OO4-N7-9vp" firstAttribute="top" secondItem="hTE-ys-qsF" secondAttribute="top" constant="650" id="A9O-TK-Vz6" userLabel="View JSON.top = top + 550"/>
                                     <constraint firstAttribute="trailing" secondItem="ogC-ph-Xdr" secondAttribute="trailing" constant="5" id="JLe-vC-Oyq"/>
                                     <constraint firstAttribute="bottom" secondItem="OO4-N7-9vp" secondAttribute="bottom" id="MpX-OZ-MDh"/>
                                     <constraint firstItem="OO4-N7-9vp" firstAttribute="width" secondItem="hTE-ys-qsF" secondAttribute="width" id="PWW-C3-Qcw"/>
@@ -503,6 +585,7 @@
                         <outlet property="homeServer" destination="PD5-8h-ZLm" id="Hge-8o-YY1"/>
                         <outlet property="imageActivity" destination="tl5-S1-p9X" id="pT5-X7-R2q"/>
                         <outlet property="imageCollabora" destination="GXZ-Rj-WCE" id="cOv-xH-ZKC"/>
+                        <outlet property="imageComments" destination="cYf-px-izj" id="lU6-Vu-AKk"/>
                         <outlet property="imageDeletedFiles" destination="8Zc-9W-n27" id="XYP-JN-JFc"/>
                         <outlet property="imageEndToEndEncryption" destination="S7m-5Z-ktw" id="0Pv-Yt-YJB"/>
                         <outlet property="imageExternalSite" destination="JWO-C0-32L" id="JKi-n1-5IQ"/>
@@ -510,8 +593,10 @@
                         <outlet property="imageNotification" destination="cgb-3g-trc" id="fa5-99-76C"/>
                         <outlet property="imageOnlyOffice" destination="xvv-h0-9bM" id="tw2-is-KHy"/>
                         <outlet property="imageText" destination="iCB-2A-phO" id="uit-Ku-oOF"/>
+                        <outlet property="imageUserStatus" destination="Nxp-H1-Pob" id="LQg-7M-CNd"/>
                         <outlet property="statusActivity" destination="dyb-1O-dIA" id="BfC-ZI-Wcr"/>
                         <outlet property="statusCollabora" destination="30w-oC-gZl" id="wnj-OE-UQZ"/>
+                        <outlet property="statusComments" destination="lVT-MG-7kN" id="7tn-cz-EhW"/>
                         <outlet property="statusDeletedFiles" destination="8hg-qK-qvz" id="xtt-gI-H0a"/>
                         <outlet property="statusEndToEndEncryption" destination="M82-8U-M4Q" id="S9e-h3-GpF"/>
                         <outlet property="statusExternalSite" destination="ivv-te-kaP" id="qzS-eo-Dq3"/>
@@ -519,6 +604,7 @@
                         <outlet property="statusNotification" destination="WAg-Hw-sQS" id="T5C-Ch-11o"/>
                         <outlet property="statusOnlyOffice" destination="ucV-YG-5ht" id="11e-La-p9K"/>
                         <outlet property="statusText" destination="uiz-H8-p3D" id="wLb-D2-MNS"/>
+                        <outlet property="statusUserStatus" destination="5Sj-5h-jgb" id="EXQ-7b-UCf"/>
                         <outlet property="textView" destination="RIO-6X-GG1" id="lPs-Ev-hQf"/>
                     </connections>
                 </viewController>
@@ -548,6 +634,7 @@
     <resources>
         <image name="activity" width="512" height="512"/>
         <image name="collabora" width="425" height="425"/>
+        <image name="comments" width="425" height="425"/>
         <image name="dav" width="425" height="425"/>
         <image name="delete" width="425" height="425"/>
         <image name="externalsites" width="425" height="425"/>
@@ -557,6 +644,7 @@
         <image name="onlyoffice" width="425" height="425"/>
         <image name="share" width="512" height="512"/>
         <image name="text" width="425" height="425"/>
+        <image name="userStatusAway" width="425" height="425"/>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>

+ 72 - 35
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -46,6 +46,12 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
     @IBOutlet weak var imageDeletedFiles: UIImageView!
     @IBOutlet weak var statusDeletedFiles: UILabel!
     
+    @IBOutlet weak var imageUserStatus: UIImageView!
+    @IBOutlet weak var statusUserStatus: UILabel!
+    
+    @IBOutlet weak var imageComments: UIImageView!
+    @IBOutlet weak var statusComments: UILabel!
+    
     @IBOutlet weak var imageText: UIImageView!
     @IBOutlet weak var statusText: UILabel!
     
@@ -77,52 +83,62 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_done_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(close))
 
         textView.layer.cornerRadius = 15
-        textView.backgroundColor = NCBrandColor.sharedInstance.graySoft
+        textView.backgroundColor = NCBrandColor.shared.graySoft
         
         statusFileSharing.layer.cornerRadius = 12.5
         statusFileSharing.layer.borderWidth = 0.5
-        statusFileSharing.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusFileSharing.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusFileSharing.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusFileSharing.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusExternalSite.layer.cornerRadius = 12.5
         statusExternalSite.layer.borderWidth = 0.5
-        statusExternalSite.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusExternalSite.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusExternalSite.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusExternalSite.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusEndToEndEncryption.layer.cornerRadius = 12.5
         statusEndToEndEncryption.layer.borderWidth = 0.5
-        statusEndToEndEncryption.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusEndToEndEncryption.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusEndToEndEncryption.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusEndToEndEncryption.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusActivity.layer.cornerRadius = 12.5
         statusActivity.layer.borderWidth = 0.5
-        statusActivity.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusActivity.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusActivity.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusActivity.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusNotification.layer.cornerRadius = 12.5
         statusNotification.layer.borderWidth = 0.5
-        statusNotification.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusNotification.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusNotification.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusNotification.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusDeletedFiles.layer.cornerRadius = 12.5
         statusDeletedFiles.layer.borderWidth = 0.5
-        statusDeletedFiles.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusDeletedFiles.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusDeletedFiles.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusDeletedFiles.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         statusText.layer.cornerRadius = 12.5
         statusText.layer.borderWidth = 0.5
-        statusText.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusText.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusText.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusText.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
 
         statusCollabora.layer.cornerRadius = 12.5
         statusCollabora.layer.borderWidth = 0.5
-        statusCollabora.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusCollabora.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusCollabora.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusCollabora.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
  
         statusOnlyOffice.layer.cornerRadius = 12.5
         statusOnlyOffice.layer.borderWidth = 0.5
-        statusOnlyOffice.layer.borderColor = NCBrandColor.sharedInstance.textView.cgColor
-        statusOnlyOffice.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.3).cgColor
+        statusOnlyOffice.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusOnlyOffice.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
+        
+        statusUserStatus.layer.cornerRadius = 12.5
+        statusUserStatus.layer.borderWidth = 0.5
+        statusUserStatus.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusUserStatus.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
+        
+        statusComments.layer.cornerRadius = 12.5
+        statusComments.layer.borderWidth = 0.5
+        statusComments.layer.borderColor = NCBrandColor.shared.textView.cgColor
+        statusComments.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
         
         imageFileSharing.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 100, height: 100, color: .gray)
         imageExternalSite.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "externalsites"), width: 100, height: 100, color: .gray)
@@ -133,11 +149,13 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         imageText.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "text"), width: 100, height: 100, color: .gray)
         imageCollabora.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "collabora"), width: 100, height: 100, color: .gray)
         imageOnlyOffice.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "onlyoffice"), width: 100, height: 100, color: .gray)
+        imageUserStatus.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "userStatusAway"), width: 100, height: 100, color: .gray)
+        imageComments.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "comments"), width: 100, height: 100, color: .gray)
 
-        guard let account = NCManageDatabase.sharedInstance.getAccountActive() else { return }
+        guard let account = NCManageDatabase.shared.getAccountActive() else { return }
         self.account = account.account
         
-        if let text = NCManageDatabase.sharedInstance.getCapabilities(account: account.account) {
+        if let text = NCManageDatabase.shared.getCapabilities(account: account.account) {
             capabilitiesText = text
             updateCapabilities()
         } else {
@@ -159,14 +177,14 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         
         NCCommunication.shared.getCapabilities() { (account, data, errorCode, errorDescription) in
             if errorCode == 0 && data != nil {
-                NCManageDatabase.sharedInstance.addCapabilitiesJSon(data!, account: account)
+                NCManageDatabase.shared.addCapabilitiesJSon(data!, account: account)
                 
                 // EDITORS
-                let serverVersionMajor = NCManageDatabase.sharedInstance.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+                let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
                 if serverVersionMajor >= k_nextcloud_version_18_0 {
                     NCCommunication.shared.NCTextObtainEditorDetails() { (account, editors, creators, errorCode, errorMessage) in
                         if errorCode == 0 && account == self.appDelegate.account {
-                            NCManageDatabase.sharedInstance.addDirectEditing(account: account, editors: editors, creators: creators)
+                            NCManageDatabase.shared.addDirectEditing(account: account, editors: editors, creators: creators)
                             self.readCapabilities()
                         }
                         if self.view.window != nil {
@@ -179,7 +197,7 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
                     }
                 }
                 
-                if let text = NCManageDatabase.sharedInstance.getCapabilities(account: account) {
+                if let text = NCManageDatabase.shared.getCapabilities(account: account) {
                     self.capabilitiesText = text
                 }
                 self.readCapabilities()
@@ -195,7 +213,12 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             let fileURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("capabilities.txt")
             do {
                 try self.capabilitiesText.write(to: fileURL, atomically: true, encoding: .utf8)
-                NCNetworkingNotificationCenter.shared.openIn(fileURL: fileURL, selector: nil)
+                
+                if let view = self.appDelegate.window?.rootViewController?.view {
+                    self.documentController = UIDocumentInteractionController(url: fileURL)
+                    self.documentController?.delegate = self
+                    self.documentController?.presentOptionsMenu(from: CGRect.zero, in: view, animated: true)
+                }
             } catch { }
         }
     }
@@ -209,20 +232,20 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         
         textView.text = capabilitiesText
         
-        if NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false) {
+        if NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false) {
             statusFileSharing.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
             statusFileSharing.text = NSLocalizedString("_not_available_", comment: "")
         }
         
-        if NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true) {
+        if NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesExternalSitesExists, exists: true) {
             statusExternalSite.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
             statusExternalSite.text = NSLocalizedString("_not_available_", comment: "")
         }
         
-        let isE2EEEnabled = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEEnabled, exists: false)
-        //let versionE2EE = NCManageDatabase.sharedInstance.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion)
+        let isE2EEEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEEnabled, exists: false)
+        //let versionE2EE = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion)
         
         if isE2EEEnabled {
             statusEndToEndEncryption.text = "✓ " + NSLocalizedString("_available_", comment: "")
@@ -230,21 +253,21 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             statusEndToEndEncryption.text = NSLocalizedString("_not_available_", comment: "")
         }
       
-        let activity = NCManageDatabase.sharedInstance.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
+        let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
         if activity != nil {
             statusActivity.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
             statusActivity.text = NSLocalizedString("_not_available_", comment: "")
         }
         
-        let notification = NCManageDatabase.sharedInstance.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesNotification)
+        let notification = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesNotification)
         if notification != nil {
             statusNotification.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
             statusNotification.text = NSLocalizedString("_not_available_", comment: "")
         }
         
-        let deleteFiles = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesUndelete, exists: false)
+        let deleteFiles = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesUndelete, exists: false)
         if deleteFiles {
             statusDeletedFiles.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
@@ -253,7 +276,7 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         
         var textEditor = false
         var onlyofficeEditors = false
-        if let editors = NCManageDatabase.sharedInstance.getDirectEditingEditors(account: account) {
+        if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: account) {
             for editor in editors {
                 if editor.editor == k_editor_text {
                     textEditor = true
@@ -269,7 +292,7 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             statusText.text = NSLocalizedString("_not_available_", comment: "")
         }
         
-        let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes)
+        let richdocumentsMimetypes = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesRichdocumentsMimetypes)
         if richdocumentsMimetypes != nil {
             statusCollabora.text = "✓ " + NSLocalizedString("_available_", comment: "")
         } else {
@@ -282,6 +305,20 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
             statusOnlyOffice.text = NSLocalizedString("_not_available_", comment: "")
         }
         
+        let userStatus = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesUserStatusEnabled, exists: false)
+        if userStatus {
+            statusUserStatus.text = "✓ " + NSLocalizedString("_available_", comment: "")
+        } else {
+            statusUserStatus.text = NSLocalizedString("_not_available_", comment: "")
+        }
+        
+        let comments = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesComments, exists: false)
+        if comments {
+            statusComments.text = "✓ " + NSLocalizedString("_available_", comment: "")
+        } else {
+            statusComments.text = NSLocalizedString("_not_available_", comment: "")
+        }
+        
         print("end.")
     }
 }

+ 1 - 1
iOSClient/EmptyView/NCEmptyDataSet.swift

@@ -93,7 +93,7 @@ public class NCEmptyView: UIView {
     }
     
     @objc func changeTheming() {
-        emptyTitle.textColor = NCBrandColor.sharedInstance.textView
+        emptyTitle.textColor = NCBrandColor.shared.textView
     }
 }
 

+ 0 - 9
iOSClient/Favorites/NCFavorite.storyboard

@@ -43,20 +43,11 @@
                     </view>
                     <connections>
                         <outlet property="collectionView" destination="Zaz-Cl-qpZ" id="8oA-Gx-z7T"/>
-                        <segue destination="rIl-hI-jAh" kind="showDetail" identifier="segueDetail" id="MHI-ti-PGq"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="JJ0-Le-6eT" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="256.80000000000001" y="228.32512315270938"/>
         </scene>
-        <!--CCDetailNC-->
-        <scene sceneID="D5y-IR-BuC">
-            <objects>
-                <viewControllerPlaceholder storyboardName="Main" referencedIdentifier="CCDetailNC" id="rIl-hI-jAh" sceneMemberID="viewController"/>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="eCA-Ct-z68" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="1080" y="228"/>
-        </scene>
     </scenes>
 </document>

+ 7 - 7
iOSClient/Favorites/NCFavorite.swift

@@ -33,7 +33,7 @@ class NCFavorite: NCCollectionViewCommon  {
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
         layoutKey = k_layout_view_favorite
         enableSearchBar = true
-        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 300, height: 300, color: NCBrandColor.sharedInstance.yellowFavorite)
+        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 300, height: 300, color: NCBrandColor.shared.yellowFavorite)
         emptyTitle = "_favorite_no_files_"
         emptyDescription = "_tutorial_favorite_view_"
     }
@@ -48,9 +48,9 @@ class NCFavorite: NCCollectionViewCommon  {
             if !self.isSearching {
            
                 if self.serverUrl == "" {
-                    self.metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND favorite == true", self.appDelegate.account))
+                    self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND favorite == true", self.appDelegate.account))
                 } else {
-                    self.metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
+                    self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
                 }
             }
             
@@ -80,9 +80,9 @@ class NCFavorite: NCCollectionViewCommon  {
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory && CCUtility.getFavoriteOffline() {
-                            let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                            let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                             if localFile == nil || localFile?.etag != metadata.etag {
-                                NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false, forceDownload: true)
+                                NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false)
                             }
                         }
                     }
@@ -101,9 +101,9 @@ class NCFavorite: NCCollectionViewCommon  {
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {
-                            let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                            let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                             if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
-                                NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false, forceDownload: true)
+                                NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false)
                             }
                         }
                     }

+ 0 - 9
iOSClient/FileViewInFolder/NCFileViewInFolder.storyboard

@@ -43,20 +43,11 @@
                     </view>
                     <connections>
                         <outlet property="collectionView" destination="Zaz-Cl-qpZ" id="8oA-Gx-z7T"/>
-                        <segue destination="rIl-hI-jAh" kind="showDetail" identifier="segueDetail" id="MHI-ti-PGq"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="JJ0-Le-6eT" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="256.80000000000001" y="228.32512315270938"/>
         </scene>
-        <!--CCDetailNC-->
-        <scene sceneID="D5y-IR-BuC">
-            <objects>
-                <viewControllerPlaceholder storyboardName="Main" referencedIdentifier="CCDetailNC" id="rIl-hI-jAh" sceneMemberID="viewController"/>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="eCA-Ct-z68" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="1080" y="228"/>
-        </scene>
     </scenes>
 </document>

+ 8 - 7
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -32,9 +32,10 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         super.init(coder: aDecoder)
         
         appDelegate.activeFileViewInFolder = self
+        titleCurrentFolder = NCBrandOptions.shared.brand
         layoutKey = k_layout_view_viewInFolder
         enableSearchBar = false
-        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.sharedInstance.brandElement)
+        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"
         emptyDescription = "_no_file_pull_down_"
     }
@@ -42,7 +43,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
     override func viewWillAppear(_ animated: Bool) {
                 
         if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
-            self.navigationItem.title = NCBrandOptions.sharedInstance.brand
+            self.navigationItem.title = NCBrandOptions.shared.brand
         } else {
             self.navigationItem.title = (serverUrl as NSString).lastPathComponent
         }
@@ -79,9 +80,9 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         DispatchQueue.global().async {
             
             if !self.isSearching {
-                self.metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
+                self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
                 if self.metadataFolder == nil {
-                    self.metadataFolder = NCManageDatabase.sharedInstance.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl:  self.serverUrl)
+                    self.metadataFolder = NCManageDatabase.shared.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl:  self.serverUrl)
                 }
             }
             
@@ -94,7 +95,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
                 
                 // Blink file
                 if self.fileName != nil {
-                    if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", self.appDelegate.account, self.serverUrl, self.fileName!)) {
+                    if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", self.appDelegate.account, self.serverUrl, self.fileName!)) {
                         if let row = self.dataSource.getIndexMetadata(ocId: metadata.ocId) {
                             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                                 UIView.animate(withDuration: 0.3) {
@@ -131,9 +132,9 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
             if errorCode == 0 {
                 for metadata in metadatas ?? [] {
                     if !metadata.directory {
-                        let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                        let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
-                            NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false, forceDownload: true)
+                            NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false)
                         }
                     }
                 }

+ 0 - 9
iOSClient/Files/NCFiles.storyboard

@@ -43,20 +43,11 @@
                     </view>
                     <connections>
                         <outlet property="collectionView" destination="Zaz-Cl-qpZ" id="8oA-Gx-z7T"/>
-                        <segue destination="rIl-hI-jAh" kind="showDetail" identifier="segueDetail" id="MHI-ti-PGq"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="JJ0-Le-6eT" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="256.80000000000001" y="228.32512315270938"/>
         </scene>
-        <!--CCDetailNC-->
-        <scene sceneID="D5y-IR-BuC">
-            <objects>
-                <viewControllerPlaceholder storyboardName="Main" referencedIdentifier="CCDetailNC" id="rIl-hI-jAh" sceneMemberID="viewController"/>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="eCA-Ct-z68" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="1080" y="228"/>
-        </scene>
     </scenes>
 </document>

+ 8 - 8
iOSClient/Files/NCFiles.swift

@@ -32,10 +32,10 @@ class NCFiles: NCCollectionViewCommon  {
         super.init(coder: aDecoder)
         
         appDelegate.activeFiles = self
-        titleCurrentFolder = NCBrandOptions.sharedInstance.brand
+        titleCurrentFolder = NCBrandOptions.shared.brand
         layoutKey = k_layout_view_files
         enableSearchBar = true
-        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.sharedInstance.brandElement)
+        emptyImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
         emptyTitle = "_files_no_files_"
         emptyDescription = "_no_file_pull_down_"
     }
@@ -66,12 +66,12 @@ class NCFiles: NCCollectionViewCommon  {
     override func reloadDataSource() {
         super.reloadDataSource()
         
-        DispatchQueue.global().async {
+        DispatchQueue.global(qos: .background).async {
                         
             if !self.isSearching {
-                self.metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
+                self.metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
                 if self.metadataFolder == nil {
-                    self.metadataFolder = NCManageDatabase.sharedInstance.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl:  self.serverUrl)
+                    self.metadataFolder = NCManageDatabase.shared.getMetadataFolder(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, serverUrl:  self.serverUrl)
                 }
             }
             
@@ -79,7 +79,7 @@ class NCFiles: NCCollectionViewCommon  {
             
             DispatchQueue.main.async {
                 self.refreshControl.endRefreshing()
-                self.collectionView.reloadData()
+                self.collectionView.reloadData()                
             }
         }
     }
@@ -99,9 +99,9 @@ class NCFiles: NCCollectionViewCommon  {
             if errorCode == 0 {
                 for metadata in metadatas ?? [] {
                     if !metadata.directory {
-                        let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                        let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         if (CCUtility.getFavoriteOffline() && localFile == nil) || (localFile != nil && localFile?.etag != metadata.etag) {
-                            NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false, forceDownload: true)
+                            NCOperationQueue.shared.download(metadata: metadata, selector: selectorDownloadFile, setFavorite: false)
                         }
                     }
                 }

+ 15 - 0
iOSClient/Images.xcassets/audioOff.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "audioOff.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 53 - 0
iOSClient/Images.xcassets/audioOff.imageset/audioOff.pdf

@@ -0,0 +1,53 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201031065104+00'00')
+/ModDate (D:20201031065104+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 174>> stream
+xœmNK1Ýs
+Ö&"Ж¶'píÊ?‹õþ‰´u̘I߃Â{�†ÚÙsK«RqÁÓh"Fæ‘lMŸg8nðî3‘ЉkWú­\d·x}A"È"{ΠBÁ:—º°	œ×Ô¹2å²tÝߨ„A•ú^rÌTIú­Š¤Òl&â&ê—M¯é²Ñ�jFòñ¶Rä¡‘)å±÷™žà8x¾‡BL
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 28.08 28.08]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000582 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000774 00000 n 
+0000000829 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+876
+%%EOF

+ 15 - 0
iOSClient/Images.xcassets/audioOn.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "audioOn.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 52 - 0
iOSClient/Images.xcassets/audioOn.imageset/audioOn.pdf

@@ -0,0 +1,52 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201031060355+00'00')
+/ModDate (D:20201031060355+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 232>> stream
+xœU�MnÄ0…÷>ëJC
Ž
9Á¬»šXýY4•ÚÞ_ꃸÕÔ–‚	�Çg³¶=Uìߥê\�æQ>KÔD¬>î�_Ïåö@ÐlìCDª¦Óÿ&�×F¯ßE6jBGœ:ëNïnî9t°ôŠ%$;9»ž,HDi–ˆ�Å–ä¯MŒ}#Šó*Îð×Êf1Àa ¬hvª‡Î2kDc“°ƒØÁ/m
_Ä38{¨�uª¬	؃ªƒ×$ÔÆ{B´BF„@ò¾goc¼Ï¯ë,�vx7èÐag@Aë·üÖòûV^ÊöÄßVì
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 28.08 28.08]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000640 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000832 00000 n 
+0000000887 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+934
+%%EOF

+ 0 - 23
iOSClient/Images.xcassets/bkempty.imageset/Contents.json

@@ -1,23 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "filename" : "bkempty.png",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "bkempty@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "bkempty@3x.png",
-      "scale" : "3x"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty.png


BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty@2x.png


BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty@3x.png


+ 0 - 23
iOSClient/Images.xcassets/bkfull.imageset/Contents.json

@@ -1,23 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "filename" : "bkfull.png",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "bkfull@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "bkfull@3x.png",
-      "scale" : "3x"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull.png


BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull@2x.png


BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull@3x.png


+ 15 - 0
iOSClient/Images.xcassets/closeVideo.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "closeVideo.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/closeVideo.imageset/closeVideo.pdf


+ 15 - 0
iOSClient/Images.xcassets/comments.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "comments.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/comments.imageset/comments.pdf


+ 15 - 0
iOSClient/Images.xcassets/favoriteSmall.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "videoFavoriteOn.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/favoriteSmall.imageset/videoFavoriteOn.pdf


+ 15 - 0
iOSClient/Images.xcassets/noPreview.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "noPreview.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 54 - 0
iOSClient/Images.xcassets/noPreview.imageset/noPreview.pdf

@@ -0,0 +1,54 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201025123511+00'00')
+/ModDate (D:20201025123511+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 323>> stream
+xœmRKNÅ0ÜçY#ab;q’°fÅ">‹>$àþ¶£×ä¡×.Ú™‰Çc·@ÜýŠIïGØ 5.€¨ï㾃éˆ
	Êùüy¯ñKU–˜“°ûÜ"-zæøñrÇ”Å
+™š7º(K©+‹Æ¶ìz�Þ³ëª�«¤â㉡çjÊa(Õ8±�RÉ‹@¨lx*Àu§£¤»Óbé´¤½•Ö[NÉsz­šéMÖühY
�d½Yö;{8ÂgX¨A+Ú/eÝ�gJ'ëÇÆ¢dÝ8G4V¿Y/Ê¡Ÿ�”€Z™=¦îëô²Õ‡*ZÕ
+q‡Zç-/ª‹™‹2¬I;4œêF¯D œÿùè�t5[dœƒl®k:k½Ðjƒíö„mÄV.»ÙÎî�w~żº®inGº„÷ð¢÷ˆ_¤¹
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 2835.1199 2835.1199]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000731 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000931 00000 n 
+0000000986 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+1033
+%%EOF

+ 15 - 0
iOSClient/Images.xcassets/noPreviewAudio.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "noPreviewAudio.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 55 - 0
iOSClient/Images.xcassets/noPreviewAudio.imageset/noPreviewAudio.pdf

@@ -0,0 +1,55 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201111104753+00'00')
+/ModDate (D:20201111104753+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 303>> stream
+xœ]’MN1…÷9EÖH˜ø'±sÖ¬8Àˆ–E‹Ü_ÂNh'ÓÉ&ùâ<ÛÏÄ}|¹øz†å(T¡øÑòvMß)îQµ€1ó²ûùHïOùË#”AM”phO.ñòÊùü›°CÍÖ¥”‚ù:
+h£A.ÿ¤™:ÑŒÔ"'TªQœß)·½Ã-aBt,k,CWò];H.tOígw#¢½–EÁ-™©—*vê
+ØŽ‘^MsE‚Ò‡ÁA: )h>s¤Ð˜Âƒ…tÄv`”›5;öô,è»G®`!ŠÙ|6{逥Ó°rÆÝÙ–ªw¢Tbw-™#¹eÜ’Ì©êðeQ`¨:û^’ípKÞ£ÙèzÁÞL‹šÆ3s(bLb˜ê�'
+åÃï²ÿQ—ô™NéÍ×qâ�W
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 425.03998 425.03998]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000711 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000911 00000 n 
+0000000966 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+1013
+%%EOF

+ 15 - 0
iOSClient/Images.xcassets/noPreviewVideo.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "noPreviewVideo.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

+ 52 - 0
iOSClient/Images.xcassets/noPreviewVideo.imageset/noPreviewVideo.pdf

@@ -0,0 +1,52 @@
+%PDF-1.4
+%Óëéá
+1 0 obj
+<</Creator (Mozilla/5.0 \(Macintosh; Intel Mac OS X 10_15_7\) AppleWebKit/537.36 \(KHTML, like Gecko\) BoxySVG/3.42.2 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36)
+/Producer (Skia/PDF m83)
+/CreationDate (D:20201111105208+00'00')
+/ModDate (D:20201111105208+00'00')>>
+endobj
+3 0 obj
+<</ca 1
+/BM /Normal>>
+endobj
+4 0 obj
+<</Filter /FlateDecode
+/Length 236>> stream
+xœu‘ÍNÅ@…÷<ŬMÄaî¸vå4þ,Zõý)W;4jg_áØø_©þn1¥½	VO­,¼ÃþŸT+3§èã	oÊ›W(£Z×F¡uÎ\âîžËË'PGo«µ¶bhfá¶eL‚Tw¬e…�"rÙ§øO‘õomÇÞI䘊ªj"«î–ˆx<¬†�¸ä�ÿ²�3<ÈdÞå•¡â`Œá —«QK)ñU:E’xòJ>™Î0´ÎHS;º›_îȵµ˜b=µÅm¿—’¸¥$<—”Æ×Ó=­�Wx†_ÂQ
+endstream
+endobj
+2 0 obj
+<</Type /Page
+/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
+/ExtGState <</G3 3 0 R>>>>
+/MediaBox [0 0 425.03998 425.03998]
+/Contents 4 0 R
+/StructParents 0
+/Parent 5 0 R>>
+endobj
+5 0 obj
+<</Type /Pages
+/Count 1
+/Kids [2 0 R]>>
+endobj
+6 0 obj
+<</Type /Catalog
+/Pages 5 0 R>>
+endobj
+xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000644 00000 n 
+0000000301 00000 n 
+0000000338 00000 n 
+0000000844 00000 n 
+0000000899 00000 n 
+trailer
+<</Size 7
+/Root 6 0 R
+/Info 1 0 R>>
+startxref
+946
+%%EOF

+ 15 - 0
iOSClient/Images.xcassets/userStatusAway.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "userStatusAway.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/userStatusAway.imageset/userStatusAway.pdf


+ 15 - 0
iOSClient/Images.xcassets/userStatusDnd.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "userStatusDnd.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/userStatusDnd.imageset/userStatusDnd.pdf


+ 15 - 0
iOSClient/Images.xcassets/userStatusOffline.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "offline.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/userStatusOffline.imageset/offline.pdf


+ 15 - 0
iOSClient/Images.xcassets/userStatusOnline.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "online.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/userStatusOnline.imageset/online.pdf


+ 15 - 15
iOSClient/Login/CCLogin.m

@@ -58,11 +58,11 @@
     Ivar ivar =  class_getInstanceVariable([UITextField class], "_placeholderLabel");
 
     // Background color
-    self.view.backgroundColor = NCBrandColor.sharedInstance.customer;
+    self.view.backgroundColor = NCBrandColor.shared.customer;
     
     // Text Color
-    BOOL isTooLight = NCBrandColor.sharedInstance.customer.isTooLight;
-    BOOL isTooDark = NCBrandColor.sharedInstance.customer.isTooDark;
+    BOOL isTooLight = NCBrandColor.shared.customer.isTooLight;
+    BOOL isTooDark = NCBrandColor.shared.customer.isTooDark;
     if (isTooLight) {
         textColor = [UIColor blackColor];
         textColorOpponent = [UIColor whiteColor];
@@ -126,8 +126,8 @@
     [self.loginTypeView setTitleColor:[textColor colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
 
     // Brand
-    if ([NCBrandOptions sharedInstance].disable_request_login_url) {
-        _baseUrl.text = [NCBrandOptions sharedInstance].loginBaseUrl;
+    if ([NCBrandOptions shared].disable_request_login_url) {
+        _baseUrl.text = [NCBrandOptions shared].loginBaseUrl;
         _imageBaseUrl.hidden = YES;
         _baseUrl.hidden = YES;
     }
@@ -135,7 +135,7 @@
     // QrCode image
     [self.qrCode setImage:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"qrcode"] width:100 height:100 color:textColor] forState:UIControlStateNormal];
     
-    NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
+    NSArray *listAccount = [[NCManageDatabase shared] getAccounts];
     if ([listAccount count] == 0) {
         _imageUser.hidden = YES;
         _user.hidden = YES;
@@ -201,7 +201,7 @@
             [[NCCommunication shared] getLoginFlowV2WithServerUrl:self.baseUrl.text completionHandler:^(NSString *token, NSString *endpoint, NSString *login, NSInteger errorCode, NSString *errorDescription) {
                 
                 // Login Flow V2
-                if (errorCode == 0 && [[NCBrandOptions sharedInstance] use_loginflowv2] && token != nil && endpoint != nil && login != nil) {
+                if (errorCode == 0 && [[NCBrandOptions shared] use_loginflowv2] && token != nil && endpoint != nil && login != nil) {
                     
                     NCLoginWeb *activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
                     
@@ -297,7 +297,7 @@
 
 - (void)dismissQRCode:(NSString *)value metadataType:(NSString *)metadataType
 {
-    NSString *protocolLogin = [[NCBrandOptions sharedInstance].webLoginAutenticationProtocol stringByAppendingString:@"login/"];
+    NSString *protocolLogin = [[NCBrandOptions shared].webLoginAutenticationProtocol stringByAppendingString:@"login/"];
     
     if (value != nil && [value hasPrefix:protocolLogin] && [value containsString:@"user:"] && [value containsString:@"password:"] && [value containsString:@"server:"]) {
         
@@ -391,12 +391,12 @@
         NSString *account = [NSString stringWithFormat:@"%@ %@", user, url];
         
         // NO account found, clear
-        if ([NCManageDatabase.sharedInstance getAccounts] == nil) { [NCUtility.shared removeAllSettings]; }
+        if ([NCManageDatabase.shared getAccounts] == nil) { [NCUtility.shared removeAllSettings]; }
         
-        [[NCManageDatabase sharedInstance] deleteAccount:account];
-        [[NCManageDatabase sharedInstance] addAccount:account urlBase:url user:user password:token];
+        [[NCManageDatabase shared] deleteAccount:account];
+        [[NCManageDatabase shared] addAccount:account urlBase:url user:user password:token];
         
-        tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
+        tableAccount *tableAccount = [[NCManageDatabase shared] setAccountActive:account];
         
         // Setting appDelegate active account
         [appDelegate settingAccount:tableAccount.account urlBase:tableAccount.urlBase user:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account]];
@@ -407,10 +407,10 @@
         } else {
             [CCUtility setIntro:YES];
             if (self.presentingViewController == nil) {
-                UISplitViewController *splitController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
-                splitController.modalPresentationStyle = UIModalPresentationFullScreen;
+                UIViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
+                viewController.modalPresentationStyle = UIModalPresentationFullScreen;
                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
-                appDelegate.window.rootViewController = splitController;
+                appDelegate.window.rootViewController = viewController;
                 [appDelegate.window makeKeyWindow];
             } else {
                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];

+ 13 - 13
iOSClient/Login/NCAppConfigView.swift

@@ -38,19 +38,19 @@ class NCAppConfigView: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        self.view.backgroundColor = NCBrandColor.sharedInstance.brandElement
-        titleLabel.textColor = NCBrandColor.sharedInstance.brandText
+        self.view.backgroundColor = NCBrandColor.shared.brandElement
+        titleLabel.textColor = NCBrandColor.shared.brandText
         
         titleLabel.text = NSLocalizedString("_appconfig_view_title_", comment: "")
         
-        if let serverConfig = UserDefaults.standard.dictionary(forKey: NCBrandConfiguration.sharedInstance.configuration_bundleId) {
-            serverUrl = serverConfig[NCBrandConfiguration.sharedInstance.configuration_serverUrl] as? String
-            username = serverConfig[NCBrandConfiguration.sharedInstance.configuration_username] as? String
-            password = serverConfig[NCBrandConfiguration.sharedInstance.configuration_password] as? String
+        if let serverConfig = UserDefaults.standard.dictionary(forKey: NCBrandConfiguration.shared.configuration_bundleId) {
+            serverUrl = serverConfig[NCBrandConfiguration.shared.configuration_serverUrl] as? String
+            username = serverConfig[NCBrandConfiguration.shared.configuration_username] as? String
+            password = serverConfig[NCBrandConfiguration.shared.configuration_password] as? String
         } else {
-            serverUrl = UserDefaults.standard.string(forKey: NCBrandConfiguration.sharedInstance.configuration_serverUrl)
-            username = UserDefaults.standard.string(forKey: NCBrandConfiguration.sharedInstance.configuration_username)
-            password = UserDefaults.standard.string(forKey: NCBrandConfiguration.sharedInstance.configuration_password)
+            serverUrl = UserDefaults.standard.string(forKey: NCBrandConfiguration.shared.configuration_serverUrl)
+            username = UserDefaults.standard.string(forKey: NCBrandConfiguration.shared.configuration_username)
+            password = UserDefaults.standard.string(forKey: NCBrandConfiguration.shared.configuration_password)
         }
     }
     
@@ -79,13 +79,13 @@ class NCAppConfigView: UIViewController {
                     let account: String = "\(username) \(serverUrl)"
                     
                     // NO account found, clear
-                    if NCManageDatabase.sharedInstance.getAccounts() == nil { NCUtility.shared.removeAllSettings() }
+                    if NCManageDatabase.shared.getAccounts() == nil { NCUtility.shared.removeAllSettings() }
                     
                     // Add new account
-                    NCManageDatabase.sharedInstance.deleteAccount(account)
-                    NCManageDatabase.sharedInstance.addAccount(account, urlBase: serverUrl, user: username, password: token!)
+                    NCManageDatabase.shared.deleteAccount(account)
+                    NCManageDatabase.shared.addAccount(account, urlBase: serverUrl, user: username, password: token!)
                     
-                    guard let tableAccount = NCManageDatabase.sharedInstance.setAccountActive(account) else {
+                    guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else {
                         NCContentPresenter.shared.messageNotification("_error_", description: "setAccountActive error", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError), forced: true)
                         self.dismiss(animated: true, completion: nil)
                         return

+ 19 - 17
iOSClient/Login/NCLoginWeb.swift

@@ -41,8 +41,8 @@ class NCLoginWeb: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        if (NCBrandOptions.sharedInstance.use_login_web_personalized) {
-            if let accountCount = NCManageDatabase.sharedInstance.getAccounts()?.count {
+        if (NCBrandOptions.shared.use_login_web_personalized) {
+            if let accountCount = NCManageDatabase.shared.getAccounts()?.count {
                 if(accountCount > 0) {
                     self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .stop, target: self, action: #selector(self.closeView(sender:)))
                 }
@@ -55,6 +55,7 @@ class NCLoginWeb: UIViewController {
         webView = WKWebView(frame: CGRect.zero, configuration: config)
         webView!.navigationDelegate = self
         view.addSubview(webView!)
+        
         webView!.translatesAutoresizingMaskIntoConstraints = false
         webView!.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
         webView!.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0).isActive = true
@@ -62,7 +63,7 @@ class NCLoginWeb: UIViewController {
         webView!.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
         
         // ADD k_flowEndpoint for Web Flow
-        if urlBase != NCBrandOptions.sharedInstance.linkloginPreferredProviders {
+        if urlBase != NCBrandOptions.shared.linkloginPreferredProviders {
             if loginFlowV2Available {
                 urlBase = loginFlowV2Login
             } else {
@@ -122,7 +123,7 @@ extension NCLoginWeb: WKNavigationDelegate {
         
         let urlString: String = url.absoluteString.lowercased()
         
-        if (urlString.hasPrefix(NCBrandOptions.sharedInstance.webLoginAutenticationProtocol) == true && urlString.contains("login") == true) {
+        if (urlString.hasPrefix(NCBrandOptions.shared.webLoginAutenticationProtocol) == true && urlString.contains("login") == true) {
             
             var server: String = ""
             var user: String = ""
@@ -164,7 +165,7 @@ extension NCLoginWeb: WKNavigationDelegate {
             return
         }
         
-        if String(describing: url).hasPrefix(NCBrandOptions.sharedInstance.webLoginAutenticationProtocol) {
+        if String(describing: url).hasPrefix(NCBrandOptions.shared.webLoginAutenticationProtocol) {
             decisionHandler(.allow)
             return
         } else if navigationAction.request.httpMethod != "GET" || navigationAction.request.value(forHTTPHeaderField: "OCS-APIRequest") != nil {
@@ -211,7 +212,7 @@ extension NCLoginWeb: WKNavigationDelegate {
         var urlBase = server
         
         // NO account found, clear all
-        if NCManageDatabase.sharedInstance.getAccounts() == nil { NCUtility.shared.removeAllSettings() }
+        if NCManageDatabase.shared.getAccounts() == nil { NCUtility.shared.removeAllSettings() }
             
         // Normalized
         if (urlBase.last == "/") {
@@ -222,10 +223,10 @@ extension NCLoginWeb: WKNavigationDelegate {
         let account: String = "\(username) \(urlBase)"
 
         // Add new account
-        NCManageDatabase.sharedInstance.deleteAccount(account)
-        NCManageDatabase.sharedInstance.addAccount(account, urlBase: urlBase, user: username, password: password)
+        NCManageDatabase.shared.deleteAccount(account)
+        NCManageDatabase.shared.addAccount(account, urlBase: urlBase, user: username, password: password)
             
-        guard let tableAccount = NCManageDatabase.sharedInstance.setAccountActive(account) else {
+        guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else {
             self.dismiss(animated: true, completion: nil)
             return
         }
@@ -241,14 +242,15 @@ extension NCLoginWeb: WKNavigationDelegate {
             
             CCUtility.setIntro(true)
             if (self.presentingViewController == nil) {
-                let splitController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
-                splitController?.modalPresentationStyle = .fullScreen
-                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
-                splitController!.view.alpha = 0
-                appDelegate.window.rootViewController = splitController!
-                appDelegate.window.makeKeyAndVisible()
-                UIView.animate(withDuration: 0.5) {
-                    splitController!.view.alpha = 1
+                if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
+                    viewController.modalPresentationStyle = .fullScreen
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
+                    viewController.view.alpha = 0
+                    appDelegate.window.rootViewController = viewController
+                    appDelegate.window.makeKeyAndVisible()
+                    UIView.animate(withDuration: 0.5) {
+                        viewController.view.alpha = 1
+                    }
                 }
             } else {
                 NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)

+ 4 - 4
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift

@@ -25,7 +25,7 @@ import Foundation
 
 class NCActionSheetHeader: NSObject {
     
-    @objc static let sharedInstance: NCActionSheetHeader = {
+    @objc static let shared: NCActionSheetHeader = {
         let instance = NCActionSheetHeader()
         return instance
     }()
@@ -38,7 +38,7 @@ class NCActionSheetHeader: NSObject {
         
         // Header
         if isDirectory {
-            image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+            image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.shared.brandElement)
         } else if iconName.count > 0 {
             image = UIImage.init(named: iconName)
         } else {
@@ -50,10 +50,10 @@ class NCActionSheetHeader: NSObject {
         
         let headerView = UINib(nibName: "NCActionSheetHeaderView", bundle: nil).instantiate(withOwner: self, options: nil).first as! NCActionSheetHeaderView
         
-        headerView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
+        headerView.backgroundColor = NCBrandColor.shared.backgroundForm
         headerView.imageItem.image = image
         headerView.label.text = text
-        headerView.label.textColor = NCBrandColor.sharedInstance.icon
+        headerView.label.textColor = NCBrandColor.shared.icon
         
         return headerView
     }

+ 0 - 43
iOSClient/Main/AppDelegate+Swift.swift

@@ -1,43 +0,0 @@
-//
-//  AppDelegate+Swift.swift
-//  Nextcloud
-//
-//  Created by Philippe Weidmann on 24.04.20.
-//  Copyright © 2020 Marino Faggiana. All rights reserved.
-//
-
-import Foundation
-
-extension AppDelegate {
-
-    @objc func configureNavBarForViewController(_ viewController: UIViewController) {
-        if #available(iOS 13.0, *) {
-            var navBarAppearance = UINavigationBarAppearance()
-            navBarAppearance.configureWithOpaqueBackground()
-            
-            navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
-            navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.backgroundView
-            
-            navBarAppearance.shadowColor = .clear
-            navBarAppearance.shadowImage = UIImage()
-            
-            viewController.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
-
-            navBarAppearance = UINavigationBarAppearance()
-            navBarAppearance.configureWithOpaqueBackground()
-            
-            navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
-            navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.tabBar
-
-            viewController.navigationController?.navigationBar.standardAppearance = navBarAppearance
-        } else {
-            viewController.navigationController?.navigationBar.barStyle = .default
-            viewController.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
-            viewController.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.sharedInstance.textView]
-            viewController.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.sharedInstance.textView]
-        }
-        viewController.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandElement
-        viewController.navigationController?.navigationBar.setNeedsLayout()
-    }
-    
-}

+ 102 - 38
iOSClient/Main/Colleaction Common/NCCollectionCommon.swift

@@ -31,6 +31,8 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
         return instance
     }()
     
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
     struct images {
         static var cellFileImage = UIImage()
 
@@ -64,29 +66,29 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
     @objc func createImagesThemingColor() {
         images.cellFileImage = UIImage.init(named: "file")!
         
-        images.cellSharedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
-        images.cellCanShareImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
-        images.cellShareByLinkImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
+        images.cellSharedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
+        images.cellCanShareImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
+        images.cellShareByLinkImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
         
-        images.cellFavouriteImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 50, height: 50, color: NCBrandColor.sharedInstance.yellowFavorite)
-        images.cellCommentImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "comment"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
-        images.cellLivePhotoImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "livePhoto"), width: 50, height: 50, color: NCBrandColor.sharedInstance.textView)
+        images.cellFavouriteImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 50, height: 50, color: NCBrandColor.shared.yellowFavorite)
+        images.cellCommentImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "comment"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
+        images.cellLivePhotoImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "livePhoto"), width: 50, height: 50, color: NCBrandColor.shared.textView)
         images.cellOfflineFlag = UIImage.init(named: "offlineFlag")!
         images.cellLocal = UIImage.init(named: "local")!
             
-        images.cellFolderEncryptedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderEncrypted"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderSharedWithMeImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_shared_with_me"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderPublicImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_public"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderGroupImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_group"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderExternalImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_external"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderAutomaticUploadImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderAutomaticUpload"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
-        images.cellFolderImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
+        images.cellFolderEncryptedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderEncrypted"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderSharedWithMeImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_shared_with_me"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderPublicImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_public"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderGroupImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_group"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderExternalImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_external"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderAutomaticUploadImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderAutomaticUpload"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
+        images.cellFolderImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 600, height: 600, color: NCBrandColor.shared.brandElement)
         
         images.cellCheckedYes = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedYes"), width: 50, height: 50, color: .darkGray)
-        images.cellCheckedNo = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedNo"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
+        images.cellCheckedNo = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedNo"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
         
-        images.cellButtonMore = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
-        images.cellButtonStop = CCGraphics.changeThemingColorImage(UIImage.init(named: "stop"), width: 50, height: 50, color: NCBrandColor.sharedInstance.graySoft)
+        images.cellButtonMore = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
+        images.cellButtonStop = CCGraphics.changeThemingColorImage(UIImage.init(named: "stop"), width: 50, height: 50, color: NCBrandColor.shared.graySoft)
     }
     
     // MARK: - NCSelect + Delegate
@@ -102,42 +104,104 @@ class NCCollectionCommon: NSObject, NCSelectDelegate {
         }
     }
 
-    func openSelectView(viewController: UIViewController, items: [Any]) {
+    func openSelectView(items: [Any]) {
         
         let navigationController = UIStoryboard.init(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
-        let vc = navigationController.topViewController as! NCSelect
+        let topViewController = navigationController.topViewController as! NCSelect
+        var listViewController = [NCSelect]()
+        
         var copyItems: [Any] = []
         for item in items {
             copyItems.append(item)
         }
         
-        vc.delegate = self
-        vc.hideButtonCreateFolder = false
-        vc.selectFile = false
-        vc.includeDirectoryE2EEncryption = false
-        vc.includeImages = false
-        vc.type = ""
-        vc.titleButtonDone = NSLocalizedString("_move_", comment: "")
-        vc.titleButtonDone1 = NSLocalizedString("_copy_",comment: "")
-        vc.isButtonDone1Hide = false
-        vc.isOverwriteHide = false
-        vc.items = copyItems
-        
-        navigationController.modalPresentationStyle = .fullScreen
-        viewController.present(navigationController, animated: true, completion: nil)
+        let homeUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+        var serverUrl = (copyItems[0] as! Nextcloud.tableMetadata).serverUrl
+        
+        // Setup view controllers such that the current view is of the same directory the items to be copied are in
+        while true {
+            // If not in the topmost directory, create a new view controller and set correct title.
+            // If in the topmost directory, use the default view controller as the base.
+            var viewController: NCSelect?
+            if serverUrl != homeUrl {
+                viewController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateViewController(withIdentifier: "NCSelect.storyboard") as? NCSelect
+                if viewController == nil {
+                    return
+                }
+                viewController!.titleCurrentFolder = (serverUrl as NSString).lastPathComponent
+            } else {
+                viewController = topViewController
+            }
+            guard let vc = viewController else { return }
+
+            vc.delegate = self
+            vc.hideButtonCreateFolder = false
+            vc.selectFile = false
+            vc.includeDirectoryE2EEncryption = false
+            vc.includeImages = false
+            vc.type = ""
+            vc.titleButtonDone = NSLocalizedString("_move_", comment: "")
+            vc.titleButtonDone1 = NSLocalizedString("_copy_",comment: "")
+            vc.isButtonDone1Hide = false
+            vc.isOverwriteHide = false
+            vc.items = copyItems
+            vc.serverUrl = serverUrl
+            
+            vc.navigationItem.backButtonTitle = vc.titleCurrentFolder
+            listViewController.insert(vc, at: 0)
+            
+            if serverUrl != homeUrl {
+                serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl: serverUrl, urlBase: appDelegate.urlBase, account: appDelegate.account)
+            } else {
+                break
+            }
+        }
+        
+        navigationController.setViewControllers(listViewController, animated: false)
+        navigationController.modalPresentationStyle = .formSheet
+        
+        appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
     }
     
     @objc func openFileViewInFolder(serverUrl: String, fileName: String) {
         
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
         let viewController = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder
         let navigationController = UINavigationController.init(rootViewController: viewController)
 
-        viewController.serverUrl = serverUrl
-        viewController.fileName = fileName
-                
-        navigationController.presentationController?.delegate = viewController
+        let topViewController = viewController
+        var listViewController = [NCFileViewInFolder]()
+        var serverUrl = serverUrl
+        let homeUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+        
+        while true {
+            
+            var viewController: NCFileViewInFolder?
+            if serverUrl != homeUrl {
+                viewController = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as? NCFileViewInFolder
+                if viewController == nil {
+                    return
+                }
+                viewController!.titleCurrentFolder = (serverUrl as NSString).lastPathComponent
+            } else {
+                viewController = topViewController
+            }
+            guard let vc = viewController else { return }
+            
+            vc.serverUrl = serverUrl
+            vc.fileName = fileName
+            
+            vc.navigationItem.backButtonTitle = vc.titleCurrentFolder
+            listViewController.insert(vc, at: 0)
+            
+            if serverUrl != homeUrl {
+                serverUrl = NCUtility.shared.deletingLastPathComponent(serverUrl: serverUrl, urlBase: appDelegate.urlBase, account: appDelegate.account)
+            } else {
+                break
+            }
+        }
+        
+        navigationController.setViewControllers(listViewController, animated: false)
+        navigationController.modalPresentationStyle = .formSheet
         
         appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
     }

+ 135 - 87
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -24,7 +24,7 @@
 import Foundation
 import NCCommunication
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate, UIAdaptivePresentationControllerDelegate  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate  {
 
     @IBOutlet weak var collectionView: UICollectionView!
 
@@ -33,7 +33,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
     internal var emptyDataSet: NCEmptyDataSet?
-
+    
     internal var serverUrl: String = ""
     internal var isEncryptedFolder = false
     internal var isEditMode = false
@@ -68,6 +68,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     internal var isReloadDataSourceNetworkInProgress: Bool = false
     
+    var selectedIndexPath: IndexPath!
+   
+    
     // DECLARE
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
@@ -83,7 +86,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        self.navigationController?.navigationBar.prefersLargeTitles = true
+        self.navigationController?.presentationController?.delegate = self
         
         if enableSearchBar {
             searchController = UISearchController(searchResultsController: nil)
@@ -136,6 +139,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         NotificationCenter.default.addObserver(self, selector: #selector(initializeMain), name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSourceNetworkForced(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSourceNetworkForced), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeStatusFolderE2EE(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_changeStatusFolderE2EE), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView), name: NSNotification.Name(rawValue: k_notificationCenter_closeRichWorkspaceWebView), object: nil)
 
@@ -162,16 +166,14 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
 
+        appDelegate.activeViewController = self
+
         if serverUrl == "" {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
             appDelegate.activeServerUrl = serverUrl
         }
         
-        appDelegate.activeViewController = self
-        
-        self.navigationItem.title = titleCurrentFolder
-                
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
         gridLayout.itemForLine = CGFloat(itemForLine)
         
@@ -181,7 +183,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             collectionView?.collectionViewLayout = gridLayout
         }
         
+        navigationController?.navigationBar.prefersLargeTitles = true
+        navigationController?.setNavigationBarHidden(false, animated: true)
         setNavigationItem()
+        
         reloadDataSource()
     }
         
@@ -215,14 +220,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     
     func setNavigationItem() {
+        
         if isEditMode {
-            self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
-            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
-            self.navigationItem.title = NSLocalizedString("_selected_", comment: "") + " : \(selectOcId.count)" + " / \(dataSource.metadatas.count)"
+            navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
+            navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
+            navigationItem.title = NSLocalizedString("_selected_", comment: "") + " : \(selectOcId.count)" + " / \(dataSource.metadatas.count)"
         } else {
-            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
-            self.navigationItem.leftBarButtonItem = nil
-            self.navigationItem.title = titleCurrentFolder
+            navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
+            navigationItem.leftBarButtonItem = nil
+            navigationItem.title = titleCurrentFolder
         }
     }
     
@@ -255,7 +261,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     }
     
     @objc func changeTheming() {
-        appDelegate.changeTheming(self, tableView: nil, collectionView: collectionView, form: false)
+        view.backgroundColor = NCBrandColor.shared.backgroundView
+        collectionView.backgroundColor = NCBrandColor.shared.backgroundView
+        collectionView.reloadData()
     }
     
     @objc func reloadDataSource(_ notification: NSNotification) {
@@ -264,6 +272,19 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         reloadDataSource()
     }
     
+    @objc func reloadDataSourceNetworkForced(_ notification: NSNotification) {
+        if self.view?.window == nil { return }
+        if let userInfo = notification.userInfo as NSDictionary? {
+            if let serverUrl = userInfo["serverUrl"] as? String {
+                if serverUrl == self.serverUrl {
+                    reloadDataSourceNetwork(forced: true)
+                }
+            }
+        } else {
+            reloadDataSourceNetwork(forced: true)
+        }
+    }
+    
     @objc func changeStatusFolderE2EE(_ notification: NSNotification) {
         if self.view?.window == nil { return }
         
@@ -303,9 +324,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let ocIdNew = userInfo["ocIdNew"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId), let metadataNew = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocIdNew) {
-                if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
-                    if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
+            if let ocId = userInfo["ocId"] as? String, let serverUrlFrom = userInfo["serverUrlFrom"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                
+                // DEL
+                if serverUrlFrom == serverUrl && metadata.account == appDelegate.account {
+                    if let row = dataSource.deleteMetadata(ocId: ocId) {
                         let indexPath = IndexPath(row: row, section: 0)
                         collectionView?.performBatchUpdates({
                             collectionView?.deleteItems(at: [indexPath])
@@ -313,8 +336,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                             self.collectionView?.reloadData()
                         })
                     }
-                } else if metadataNew.serverUrl == serverUrl && metadata.account == appDelegate.account {
-                    if let row = dataSource.addMetadata(metadataNew) {
+                    // ADD
+                } else if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
+                    if let row = dataSource.addMetadata(metadata) {
                         let indexPath = IndexPath(row: row, section: 0)
                         collectionView?.performBatchUpdates({
                             collectionView?.insertItems(at: [indexPath])
@@ -332,6 +356,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
         if let userInfo = notification.userInfo as NSDictionary? {
             if let serverUrlTo = userInfo["serverUrlTo"] as? String {
+                
                 if serverUrlTo == self.serverUrl {
                     reloadDataSource()
                 }
@@ -349,7 +374,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                
                 if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
                     if let row = dataSource.addMetadata(metadata) {
                         let indexPath = IndexPath(row: row, section: 0)
@@ -370,7 +396,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                
                 if dataSource.getIndexMetadata(ocId: metadata.ocId) != nil {
                     reloadDataSource()
                 }
@@ -382,7 +409,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
                     let indexPath = IndexPath(row: row, section: 0)
                     if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
@@ -397,7 +424,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
                     let indexPath = IndexPath(row: row, section: 0)
                     if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
@@ -412,7 +439,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
                     let indexPath = IndexPath(row: row, section: 0)
                     if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
@@ -427,7 +454,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
                     dataSource.addMetadata(metadata)
                     self.collectionView?.reloadData()
@@ -440,7 +467,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let ocIdTemp = userInfo["ocIdTemp"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId)  {
+        if let ocId = userInfo["ocId"] as? String, let ocIdTemp = userInfo["ocIdTemp"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
                     dataSource.reloadMetadata(ocId: metadata.ocId, ocIdTemp: ocIdTemp)
                     collectionView?.reloadData()
@@ -453,9 +480,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if self.view?.window == nil { return }
         
         if let userInfo = notification.userInfo as NSDictionary? {
-            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+            if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                
                 if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
-                    
                     if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
                         let indexPath = IndexPath(row: row, section: 0)
                         collectionView?.performBatchUpdates({
@@ -544,9 +571,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
             view.emptyDescription.text = ""
         } else {
-            view.emptyImage.image = emptyImage
-            view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
-            view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
+            if serverUrl == "" {
+                view.emptyImage.image = emptyImage
+                view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
+                view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
+            } else {
+                view.emptyImage.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
+                view.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "")
+                view.emptyDescription.text = NSLocalizedString("_no_file_pull_down_", comment: "")
+            }
         }
     }
     
@@ -633,7 +666,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     func tapShareListItem(with objectId: String, sender: Any) {
         
         if isEditMode { return }
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
+        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
         
         NCNetworkingNotificationCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 2)
     }
@@ -642,7 +675,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
         if isEditMode { return }
 
-        guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
+        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
 
         if namedButtonMore == k_buttonMoreMore {
             toggleMoreMenu(viewController: self, metadata: metadata)
@@ -687,7 +720,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if gestureRecognizer.state != .began { return }
         if serverUrl == "" { return }
         
-        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
+        if let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) {
             metadataTouch = metadata
         } else {
             metadataTouch = nil
@@ -706,7 +739,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
         if metadataTouch != nil {
             listMenuItems.append(UIMenuItem.init(title: NSLocalizedString("_open_quicklook_", comment: ""), action: #selector(openQuickLookMenu(_:))))
-            if !NCBrandOptions.sharedInstance.disable_openin_file {
+            if !NCBrandOptions.shared.disable_openin_file {
                 listMenuItems.append(UIMenuItem.init(title: NSLocalizedString("_open_in_", comment: ""), action: #selector(openInMenu(_:))))
             }
         }
@@ -744,7 +777,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         if isEditMode {
             for ocId in selectOcId {
-                if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+                if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                     metadatas.append(metadata)
                 }
             }
@@ -823,33 +856,33 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 return
             }
             
-            let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: contentType, livePhoto: false)
+            let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: contentType, livePhoto: false)
             
             metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
             metadataForUpload.sessionSelector = selectorUploadFile
             metadataForUpload.size = Double(NCUtilityFileSystem.shared.getFileSize(filePath: filePath))
             metadataForUpload.status = Int(k_metadataStatusWaitUpload)
             
-            NCManageDatabase.sharedInstance.addMetadata(metadataForUpload)
+            NCManageDatabase.shared.addMetadata(metadataForUpload)
             
         } catch { }
     }
     
     private func uploadPasteOcId(_ ocId: String) {
-        if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
+        if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
             if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
                 let fileNameView = NCUtility.shared.createFileName(metadata.fileNameView, serverUrl: serverUrl, account: appDelegate.account)
                 let ocId = NSUUID().uuidString
                 
                 CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView))
-                let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
+                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
                 
                 metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
                 metadataForUpload.sessionSelector = selectorUploadFile
                 metadataForUpload.size = metadata.size
                 metadataForUpload.status = Int(k_metadataStatusWaitUpload)
                 
-                NCManageDatabase.sharedInstance.addMetadata(metadataForUpload)
+                NCManageDatabase.shared.addMetadata(metadataForUpload)
             }
         }
     }
@@ -874,31 +907,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
     
-    // MARK: - SEGUE
-    
-    @objc func segue(metadata: tableMetadata) {
-        self.metadataTouch = metadata
-        performSegue(withIdentifier: "segueDetail", sender: self)
-    }
-        
-    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-        
-        let photoDataSource: NSMutableArray = []
-        
-        for metadata in (dataSource.metadatas) {
-            if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video {
-                photoDataSource.add(metadata)
-            }
-        }
-        
-        if let segueNavigationController = segue.destination as? UINavigationController {
-            if let segueViewController = segueNavigationController.topViewController as? NCDetailViewController {
-                segueViewController.metadata = metadataTouch
-                segueViewController.layoutKey = layoutKey
-            }
-        }
-    }
-    
     // MARK: - DataSource + NC Endpoint
     
     @objc func reloadDataSource() {
@@ -906,15 +914,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         if appDelegate.account == nil || appDelegate.account.count == 0 { return }
         
         // Get richWorkspace Text
-        let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
+        let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
         richWorkspaceText = directory?.richWorkspace
         
         // E2EE
         isEncryptedFolder = CCUtility.isFolderEncrypted(serverUrl, e2eEncrypted: metadataFolder?.e2eEncrypted ?? false, account: appDelegate.account, urlBase: appDelegate.urlBase)
 
         // get auto upload folder
-        autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
-        autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
+        autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
+        autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
         
         // get layout for view
         (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
@@ -952,7 +960,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             
             if errorCode == 0 {
                 
-                let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
+                let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
                 
                 if forced || directory?.etag != metadata?.etag || directory?.e2eEncrypted ?? false {
                     
@@ -968,7 +976,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                                     NCCommunication.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: nil) { (account, e2eMetadata, errorCode, errorDescription) in
                                         if errorCode == 0 && e2eMetadata != nil {
                                             
-                                            if !NCEndToEndMetadata.sharedInstance.decoderMetadata(e2eMetadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: self.serverUrl, account: account, urlBase: self.appDelegate.urlBase) {
+                                            if !NCEndToEndMetadata.shared.decoderMetadata(e2eMetadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: self.serverUrl, account: account, urlBase: self.appDelegate.urlBase) {
                                                 
                                                 NCContentPresenter.shared.messageNotification("_error_e2ee_", description: "_e2e_error_decode_metadata_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorDecodeMetadata), forced: true)
                                             } else {
@@ -1048,6 +1056,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
         
         guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
         metadataTouch = metadata
+        selectedIndexPath = indexPath
         
         if isEditMode {
             if let index = selectOcId.firstIndex(of: metadata.ocId) {
@@ -1163,6 +1172,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
                 }
             }
             
+            //VIEW IN FOLDER
             if layoutKey == k_layout_view_viewInFolder {
                 
                 let vcFileViewInFolder:NCFileViewInFolder = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder
@@ -1173,16 +1183,37 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
                 self.navigationController?.pushViewController(vcFileViewInFolder, animated: true)
             }
             
+            // SHARES ( for push use Files ... he he he )
+            if layoutKey == k_layout_view_shares {
+                
+                if let viewController = appDelegate.listFilesVC.value(forKey: serverUrlPush) {
+                    guard let vcFiles = (viewController as? NCFiles) else { return }
+                    
+                    if vcFiles.isViewLoaded {
+                        self.navigationController?.pushViewController(vcFiles, animated: true)
+                    }
+                    
+                } else {
+                    
+                    let vcFiles:NCFiles = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as! NCFiles
+                    
+                    vcFiles.isRoot = false
+                    vcFiles.serverUrl = serverUrlPush
+                    vcFiles.titleCurrentFolder = metadataTouch!.fileNameView
+                    
+                    appDelegate.listFilesVC.setValue(vcFiles, forKey: serverUrlPush)
+                    
+                    self.navigationController?.pushViewController(vcFiles, animated: true)
+                }
+            }
+            
         } else {
             
-            if metadata.typeFile == k_metadataTypeFile_video {
-                performSegue(withIdentifier: "segueDetail", sender: self)
-                return
-            }
+            guard let metadataTouch = metadataTouch else { return }
             
             if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil {
                 if NCCommunication.shared.isNetworkReachable() {
-                    performSegue(withIdentifier: "segueDetail", sender: self)
+                    NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
                 } else {
                     NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
                 }
@@ -1191,17 +1222,28 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             
             if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isRichDocument(metadata) {
                 if NCCommunication.shared.isNetworkReachable() {
-                    performSegue(withIdentifier: "segueDetail", sender: self)
+                    NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
                 } else {
                     NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
                 }
                 return
             }
             
-            if CCUtility.fileProviderStorageExists(metadataTouch?.ocId, fileNameView: metadataTouch?.fileNameView) {
-                performSegue(withIdentifier: "segueDetail", sender: self)
+            if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio {
+                var metadatas: [tableMetadata] = []
+                for metadata in dataSource.metadatas {
+                    if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio {
+                        metadatas.append(metadata)
+                    }
+                }
+                NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: metadatas)
+                return
+            }
+            
+            if CCUtility.fileProviderStorageExists(metadataTouch.ocId, fileNameView: metadataTouch.fileNameView) {
+                NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
             } else {
-                NCNetworking.shared.download(metadata: metadataTouch!, selector: selectorLoadFileView) { (_) in }
+                NCNetworking.shared.download(metadata: metadataTouch, selector: selectorLoadFileView) { (_) in }
             }
         }
     }
@@ -1234,9 +1276,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
             
             if collectionView.collectionViewLayout == gridLayout {
-                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), width: 100, height: 100, color: NCBrandColor.sharedInstance.icon), for: .normal)
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), width: 100, height: 100, color: NCBrandColor.shared.icon), for: .normal)
             } else {
-                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), width: 100, height: 100, color: NCBrandColor.sharedInstance.icon), for: .normal)
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), width: 100, height: 100, color: NCBrandColor.shared.icon), for: .normal)
             }
             
             header.delegate = self
@@ -1302,8 +1344,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.objectId = metadata.ocId
             cell.indexPath = indexPath
             cell.labelTitle.text = metadata.fileNameView
-            cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
-            cell.separator.backgroundColor = NCBrandColor.sharedInstance.separator
+            cell.labelTitle.textColor = NCBrandColor.shared.textView
+            cell.separator.backgroundColor = NCBrandColor.shared.separator
             
             cell.imageSelect.image = nil
             cell.imageStatus.image = nil
@@ -1340,7 +1382,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
                 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
-                let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
+                let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
                 
                 // Local image: offline
                 if tableDirectory != nil && tableDirectory!.offline {
@@ -1476,6 +1518,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.selectMode(false)
             }
             
+            // Disable Share Button
+            if appDelegate.disableSharesView {
+                cell.hideButtonShare(true)
+            }
+            
             return cell
         }
         
@@ -1490,7 +1537,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.objectId = metadata.ocId
             cell.indexPath = indexPath
             cell.labelTitle.text = metadata.fileNameView
-            cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
+            cell.labelTitle.textColor = NCBrandColor.shared.textView
             
             cell.imageSelect.image = nil
             cell.imageStatus.image = nil
@@ -1523,7 +1570,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 }
     
                 let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
-                let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
+                let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
                                 
                 // Local image: offline
                 if tableDirectory != nil && tableDirectory!.offline {
@@ -1613,3 +1660,4 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
         return CGSize(width: collectionView.frame.width, height: footerHeight)
     }
 }
+

+ 1 - 1
iOSClient/Main/Colleaction Common/NCGridCell.swift

@@ -59,7 +59,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         imageVisualEffect.layer.cornerRadius = 6
         imageVisualEffect.clipsToBounds = true
         
-        progressView.tintColor = NCBrandColor.sharedInstance.brandElement
+        progressView.tintColor = NCBrandColor.shared.brandElement
         progressView.transform = CGAffineTransform(scaleX: 1.0, y: 0.5)
         progressView.trackTintColor = .clear
         

+ 1 - 1
iOSClient/Main/Colleaction Common/NCListCell.swift

@@ -65,7 +65,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         imageItem.layer.cornerRadius = 6
         imageItem.layer.masksToBounds = true
         
-        progressView.tintColor = NCBrandColor.sharedInstance.brandElement
+        progressView.tintColor = NCBrandColor.shared.brandElement
         progressView.transform = CGAffineTransform(scaleX: 1.0, y: 0.5)
         progressView.trackTintColor = .clear
 

+ 33 - 31
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -49,8 +49,8 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             titleServerUrl = "/"
         } else {
-            if let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
-                if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(tableDirectory.ocId) {
+            if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
+                if let metadata = NCManageDatabase.shared.getMetadataFromOcId(tableDirectory.ocId) {
                     titleServerUrl = metadata.fileNameView
                 } else { titleServerUrl = (serverUrl as NSString).lastPathComponent }
             } else { titleServerUrl = (serverUrl as NSString).lastPathComponent }
@@ -99,7 +99,9 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
     }
     
     @objc func changeTheming() {
-        appDelegate.changeTheming(self, tableView: tableView, collectionView: nil, form: true)
+        view.backgroundColor = NCBrandColor.shared.backgroundForm
+        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+        tableView.reloadData()
         initializeForm()
         self.reloadForm()
     }
@@ -121,28 +123,28 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
-        row.cellConfig["imageView.image"] = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        row.cellConfig["imageView.image"] = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, width: 50, height: 50, color: NCBrandColor.shared.brandElement) as UIImage
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
         
         // User folder Autoupload
         row = XLFormRowDescriptor(tag: "useFolderAutoUpload", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_use_folder_auto_upload_", comment: ""))
         row.value = 0
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
         
         // Use Sub folder
         row = XLFormRowDescriptor(tag: "useSubFolder", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_autoupload_create_subfolder_", comment: ""))
-        let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
+        let tableAccount = NCManageDatabase.shared.getAccountActive()
         if tableAccount?.autoUploadCreateSubfolder == true {
             row.value = 1
         } else {
@@ -151,7 +153,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row.hidden = "$\("useFolderAutoUpload") == 0"
         
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
 
@@ -164,10 +166,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         
         row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
         row.value = CCUtility.getOriginalFileName(k_keyFileNameOriginal)
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
         
@@ -176,10 +178,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row = XLFormRowDescriptor(tag: "addFileNameType", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_add_filenametype_", comment: ""))
         row.value = CCUtility.getFileNameType(k_keyFileNameType)
         row.hidden = "$\("maintainOriginalFileName") == 1"
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
         
@@ -194,14 +196,14 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             row.value = fileNameMask
         }
         row.hidden = "$\("maintainOriginalFileName") == 1"
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textField.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textField.textColor"] = NCBrandColor.shared.textView
 
         section.addFormRow(row)
         
@@ -210,11 +212,11 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row = XLFormRowDescriptor(tag: "previewFileName", rowType: XLFormRowDescriptorTypeTextView, title: "")
         row.height = 180
         row.disabled = true
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
-        row.cellConfig["textView.backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["textView.backgroundColor"] = NCBrandColor.shared.backgroundForm
         row.cellConfig["textView.font"] = UIFont.systemFont(ofSize: 14.0)
-        row.cellConfig["textView.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textView.textColor"] = NCBrandColor.shared.textView
 
         section.addFormRow(row)
         
@@ -310,9 +312,9 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             if serverUrl == NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
                 self.titleServerUrl = "/"
             } else {
-                if let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account
+                if let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account
                     , self.serverUrl)) {
-                    if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(tableDirectory.ocId) {
+                    if let metadata = NCManageDatabase.shared.getMetadataFromOcId(tableDirectory.ocId) {
                         titleServerUrl = metadata.fileNameView
                     } else { titleServerUrl = (self.serverUrl as NSString).lastPathComponent }
                 } else { titleServerUrl = (self.serverUrl as NSString).lastPathComponent }                
@@ -336,7 +338,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             
             if (useFolderPhotoRow.value! as AnyObject).boolValue == true {
                 
-                self.serverUrl = NCManageDatabase.sharedInstance.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
+                self.serverUrl = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
                 useSubFolder = (useSubFolderRow.value! as AnyObject).boolValue
             }
             
@@ -357,11 +359,11 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             var metadatasUploadInConflict: [tableMetadata] = []
 
             if (useFolderPhotoRow.value! as AnyObject).boolValue == true {
-                self.serverUrl = NCManageDatabase.sharedInstance.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
+                self.serverUrl = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
                 useSubFolder = (useSubFolderRow.value! as AnyObject).boolValue
             }
             
-            let autoUploadPath = NCManageDatabase.sharedInstance.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
+            let autoUploadPath = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
             if autoUploadPath == self.serverUrl {
                 if NCNetworking.shared.createFolder(assets: self.assets, selector: selectorUploadFile, useSubFolder: useSubFolder, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase) {
                     NCContentPresenter.shared.messageNotification("_error_", description: "_error_createsubfolders_upload_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError), forced: true)
@@ -395,12 +397,12 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                 }
                 
                 // Check if is in upload
-                let isRecordInSessions = NCManageDatabase.sharedInstance.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@ AND session != ''", self.appDelegate.account, serverUrl, fileName), sorted: "fileName", ascending: false)
+                let isRecordInSessions = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@ AND session != ''", self.appDelegate.account, serverUrl, fileName), sorted: "fileName", ascending: false)
                 if isRecordInSessions.count > 0 {
                     continue
                 }
                 
-                let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: NSUUID().uuidString, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
+                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: NSUUID().uuidString, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
                 
                 metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                 metadataForUpload.session = self.session
@@ -418,7 +420,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                     CCUtility.extractLivePhotoAsset(asset, filePath: filePath) { (url) in
                         if let url = url {
                             let fileSize = NCUtilityFileSystem.shared.getFileSize(filePath: url.path)
-                            let metadataMOVForUpload = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileNameMove, ocId:ocId, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
+                            let metadataMOVForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileNameMove, ocId:ocId, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
 
                             metadataForUpload.livePhoto = true
                             metadataMOVForUpload.livePhoto = true
@@ -460,8 +462,8 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                 
             } else {
                 
-                NCManageDatabase.sharedInstance.addMetadatas(metadatasNOConflict)
-                NCManageDatabase.sharedInstance.addMetadatas(metadatasMOV)
+                NCManageDatabase.shared.addMetadatas(metadatasNOConflict)
+                NCManageDatabase.shared.addMetadatas(metadatasMOV)
                 
                 self.appDelegate.networkingAutoUpload.startProcess()
             }
@@ -510,7 +512,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: nil, keyFileNameType: k_keyFileNameType, keyFileNameOriginal: k_keyFileNameOriginal)
         }
         
-        return String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM,MMM,DD,YY,YYYY and HH,hh,mm,ss,ampm") + ":" + "\n\n" + returnString
+        return String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm") + ":" + "\n\n" + returnString
     }
     
     @objc func changeDestinationFolder(_ sender: XLFormRowDescriptor) {

+ 3 - 3
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -98,14 +98,14 @@ extension NCCreateFormUploadConflictDelegate {
         buttonCancel.layer.cornerRadius = 20
         buttonCancel.layer.masksToBounds = true
         buttonCancel.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
-        buttonCancel.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.5).cgColor
+        buttonCancel.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.5).cgColor
         
         buttonContinue.layer.cornerRadius = 20
         buttonContinue.layer.masksToBounds = true
         buttonContinue.setTitle(NSLocalizedString("_continue_", comment: ""), for: .normal)
         buttonContinue.isEnabled = false
         buttonContinue.setTitleColor(.lightGray, for: .normal)
-        buttonContinue.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.5).cgColor
+        buttonContinue.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.5).cgColor
     }
     
     // MARK: - Action
@@ -227,7 +227,7 @@ extension NCCreateFormUploadConflictDelegate {
             
         } else {
             
-            NCManageDatabase.sharedInstance.addMetadatas(metadatasNOConflict)
+            NCManageDatabase.shared.addMetadatas(metadatasNOConflict)
             
             appDelegate.networkingAutoUpload.startProcess()
         }

+ 23 - 22
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -83,7 +83,11 @@ import NCCommunication
     }
     
     @objc func changeTheming() {
-        appDelegate.changeTheming(self, tableView: tableView, collectionView: collectionView, form: false)
+        view.backgroundColor = NCBrandColor.shared.backgroundForm
+        collectionView.backgroundColor = NCBrandColor.shared.backgroundForm
+        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+        collectionView.reloadData()
+        tableView.reloadData()
         initializeForm()
     }
     
@@ -105,13 +109,13 @@ import NCCommunication
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
         row.value = fileNameFolder
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
 
-        row.cellConfig["imageView.image"] = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement) as UIImage
+        row.cellConfig["imageView.image"] = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, width: 50, height: 50, color: NCBrandColor.shared.brandElement) as UIImage
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
 
         section.addFormRow(row)
         
@@ -122,15 +126,15 @@ import NCCommunication
         
         row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
         row.value = fileName
-        row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
+        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
         
         row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textField.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textField.textColor"] = NCBrandColor.shared.textView
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
         
         section.addFormRow(row)
         
@@ -141,7 +145,7 @@ import NCCommunication
         let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
         header.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
         header.textLabel?.textColor = .gray
-        header.tintColor = NCBrandColor.sharedInstance.backgroundForm
+        header.tintColor = NCBrandColor.shared.backgroundForm
     }
 
     // MARK: - CollectionView
@@ -183,16 +187,16 @@ import NCCommunication
         // name
         let name = cell.viewWithTag(200) as! UILabel
         name.text = template.name
-        name.textColor = NCBrandColor.sharedInstance.backgroundView
+        name.textColor = NCBrandColor.shared.backgroundView
         
         // select
         let imageSelect = cell.viewWithTag(300) as! UIImageView
         if selectTemplate != nil && selectTemplate?.name == template.name {
-            cell.backgroundColor = NCBrandColor.sharedInstance.textView
+            cell.backgroundColor = NCBrandColor.shared.textView
             imageSelect.image = UIImage(named: "plus100")
             imageSelect.isHidden = false
         } else {
-            cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
+            cell.backgroundColor = NCBrandColor.shared.backgroundView
             imageSelect.isHidden = true
         }
         
@@ -273,7 +277,7 @@ import NCCommunication
             
             if NCUtility.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileName: String(describing: fileNameForm)) != nil {
                 
-                let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
+                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
                 
                 guard let conflictViewController = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict else { return }
                 conflictViewController.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
@@ -327,9 +331,9 @@ import NCCommunication
                         let result = NCCommunicationCommon.shared.getInternalContenType(fileName: fileName, contentType: "", directory: false)
                         
                         self.dismiss(animated: true, completion: {
-                            let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: result.contentType, livePhoto: false)
+                            let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: result.contentType, livePhoto: false)
                             
-                            NCNetworkingNotificationCenter.shared.segueMetadata(metadata)
+                            NCViewer.shared.view(viewController: self.appDelegate.activeViewController, metadata: metadata, metadatas: [metadata])
                         })
                     }
                     
@@ -349,9 +353,9 @@ import NCCommunication
                    
                     self.dismiss(animated: true, completion: {
                     
-                        let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
+                        let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
                     
-                        NCNetworkingNotificationCenter.shared.segueMetadata(metadata)
+                        NCViewer.shared.view(viewController: self.appDelegate.activeViewController, metadata: metadata, metadatas: [metadata])
                    })
                    
                     
@@ -373,18 +377,15 @@ import NCCommunication
     
     func getTemplate() {
      
-        indicator.color = NCBrandColor.sharedInstance.brandElement
+        indicator.color = NCBrandColor.shared.brandElement
         indicator.startAnimating()
         
         if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {
-            
-            fileNameExtension = "md"
+                        
             var customUserAgent: String?
-                       
             if self.editorId == k_editor_onlyoffice {
                 customUserAgent = NCUtility.shared.getCustomUserAgentOnlyOffice()
             }
-            
             NCCommunication.shared.NCTextGetListOfTemplates(customUserAgent: customUserAgent) { (account, templates, errorCode, errorMessage) in
                 
                 self.indicator.stopAnimating()
@@ -503,7 +504,7 @@ import NCCommunication
 
         NCCommunication.shared.download(serverUrlFileName: preview, fileNameLocalPath: fileNameLocalPath, requestHandler: { (_) in
             
-        }, taskHandler: { (task) in
+        }, taskHandler: { (_) in
             
         }, progressHandler: { (_) in
             

Some files were not shown because too many files changed in this diff