Эх сурвалжийг харах

Merge branch 'develop' into share

marinofaggiana 4 жил өмнө
parent
commit
efbb84793e
64 өөрчлөгдсөн 587 нэмэгдсэн , 1610 устгасан
  1. 3 1
      .github/ISSUE_TEMPLATE.md
  2. BIN
      Animation.gif
  3. 15 0
      CHANGELOG.md
  4. 1 1
      Cartfile
  5. 1 1
      Cartfile.resolved
  6. 24 30
      Nextcloud.xcodeproj/project.pbxproj
  7. 1 1
      Share/NCSelectDestination.m
  8. 0 6
      iOSClient/AppDelegate.h
  9. 34 103
      iOSClient/AppDelegate.m
  10. 1 3
      iOSClient/Brand/NCBrand.swift
  11. 2 1
      iOSClient/CCGlobal.h
  12. 0 2
      iOSClient/Database/NCDatabase.swift
  13. 0 80
      iOSClient/Database/NCManageDatabase.swift
  14. 0 1
      iOSClient/Favorites/CCFavorites.h
  15. 52 52
      iOSClient/Favorites/CCFavorites.m
  16. 2 2
      iOSClient/Login/NCAppConfigView.swift
  17. 3 3
      iOSClient/Login/NCLoginWeb.swift
  18. 1 1
      iOSClient/Main/AppDelegate+Swift.swift
  19. 2 2
      iOSClient/Main/CCMain+Swift.swift
  20. 0 1
      iOSClient/Main/CCMain.h
  21. 73 159
      iOSClient/Main/CCMain.m
  22. 1 1
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  23. 2 6
      iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift
  24. 1 3
      iOSClient/Main/Menu/AppDelegate+Menu.swift
  25. 8 8
      iOSClient/Main/Menu/CCMain+Menu.swift
  26. 4 4
      iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift
  27. 7 9
      iOSClient/Main/NCDetailViewController.swift
  28. 2 2
      iOSClient/Main/NCMainCommon.swift
  29. 1 1
      iOSClient/Main/NCMasterNavigationController.swift
  30. 3 9
      iOSClient/Main/NCPhotosPickerViewController.swift
  31. 2 2
      iOSClient/Main/NCSplitViewController.swift
  32. 156 109
      iOSClient/Media/NCMedia.swift
  33. 5 5
      iOSClient/Media/NCMediaCommandView.xib
  34. 0 83
      iOSClient/MenuAccount/CCMenuAccount.h
  35. 0 794
      iOSClient/MenuAccount/CCMenuAccount.m
  36. 57 40
      iOSClient/Networking/NCNetworking.swift
  37. 19 12
      iOSClient/Networking/NCNetworkingE2EE.swift
  38. 12 2
      iOSClient/Networking/NCOperationQueue.swift
  39. 2 9
      iOSClient/Networking/NCService.swift
  40. 1 1
      iOSClient/Notification/NCNotification.swift
  41. 2 2
      iOSClient/Offline/NCOffline.swift
  42. 1 1
      iOSClient/PeekPop/CCPeekPop.m
  43. 9 7
      iOSClient/ScanDocument/ScanCollectionView.swift
  44. 2 2
      iOSClient/Select/NCSelect.swift
  45. 0 2
      iOSClient/Settings/CCAdvanced.m
  46. 3 3
      iOSClient/Share/NCShare.swift
  47. 2 2
      iOSClient/Share/NCShareCommon.swift
  48. 9 9
      iOSClient/Share/NCShareLinkMenuView.swift
  49. 2 2
      iOSClient/Share/NCSharePaging.swift
  50. 7 7
      iOSClient/Share/NCShareUserMenuView.swift
  51. BIN
      iOSClient/Supporting Files/ca.lproj/Localizable.strings
  52. BIN
      iOSClient/Supporting Files/fr.lproj/Localizable.strings
  53. BIN
      iOSClient/Supporting Files/gl.lproj/Localizable.strings
  54. BIN
      iOSClient/Supporting Files/it.lproj/Localizable.strings
  55. BIN
      iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings
  56. BIN
      iOSClient/Supporting Files/sl.lproj/Localizable.strings
  57. 2 1
      iOSClient/Transfers/CCTransfers.m
  58. 1 1
      iOSClient/Trash/NCTrash.swift
  59. 5 9
      iOSClient/Utility/NCContentPresenter.swift
  60. 4 4
      iOSClient/Utility/NCUtility.swift
  61. 34 0
      iOSClient/Utility/NotificationCenter+MainThread.swift
  62. 4 6
      iOSClient/Viewer/NCViewerImage/NCViewerImageCommon.swift
  63. 1 1
      iOSClient/Viewer/NCViewerImage/NCViewerImageContentView.swift
  64. 1 1
      iOSClient/Viewer/NCViewerVideo.swift

+ 3 - 1
.github/ISSUE_TEMPLATE.md

@@ -2,7 +2,9 @@
 
 ### Actual behaviour                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
 
-### Steps to reproduce                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
+### Steps to reproduce     
+
+### Reasoning or why should it be changed/implemented?
 
 ### iOS version
 

BIN
Animation.gif


+ 15 - 0
CHANGELOG.md

@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 ## [Unreleased]
 
+## [3.0.0] - 2020-06-19
+- See https://github.com/nextcloud/ios/releases/tag/v3.0.0
+
+## [2.25.9] - 2020-02-19
+- See https://github.com/nextcloud/ios/milestone/67
+
+## [2.25.8] - 2020-02-14
+- See https://github.com/nextcloud/ios/milestone/66
+
+## [2.25.7] - 2020-02-12
+- See https://github.com/nextcloud/ios/milestone/65
+
+## [2.25.6] - 2020-02-07
+- See https://github.com/nextcloud/ios/milestone/64
+
 ## [2.25.5] - 2020-01-26
 - See https://github.com/nextcloud/ios/milestone/63
 

+ 1 - 1
Cartfile

@@ -1,4 +1,4 @@
-github "nextcloud/ios-communication-library" "develop"
+github "nextcloud/ios-communication-library" "v0.70"
 github "tilltue/TLPhotoPicker" "2.0.11"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "MortimerGoro/MGSwipeTableCell" "1.6.8"

+ 1 - 1
Cartfile.resolved

@@ -20,7 +20,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "80a64ad950bc5021b5e93918948b21f392f7c872"
+github "nextcloud/ios-communication-library" "v0.70"
 github "realm/realm-cocoa" "v5.0.3"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 24 - 30
Nextcloud.xcodeproj/project.pbxproj

@@ -34,6 +34,9 @@
 		F700510322DF6897003A3356 /* Parchment.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F700510222DF6897003A3356 /* Parchment.framework */; };
 		F700510522DF6A89003A3356 /* NCShare.swift in Sources */ = {isa = PBXBuildFile; fileRef = F700510422DF6A89003A3356 /* NCShare.swift */; };
 		F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7020FCD2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift */; };
+		F70460522499061800BB98A7 /* NotificationCenter+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */; };
+		F70460532499095400BB98A7 /* NotificationCenter+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */; };
+		F70460542499095400BB98A7 /* NotificationCenter+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */; };
 		F704B5E32430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F704B5E22430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard */; };
 		F704B5E52430AA8000632F5F /* NCCreateFormUploadConflict.swift in Sources */ = {isa = PBXBuildFile; fileRef = F704B5E42430AA8000632F5F /* NCCreateFormUploadConflict.swift */; };
 		F704B5E72430C06700632F5F /* NCCreateFormUploadConflictCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F704B5E62430C06700632F5F /* NCCreateFormUploadConflictCell.xib */; };
@@ -292,7 +295,6 @@
 		F79A65C32191D90F00FF6DCC /* NCSelect.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F79A65C22191D90F00FF6DCC /* NCSelect.storyboard */; };
 		F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79A65C52191D95E00FF6DCC /* NCSelect.swift */; };
 		F7A321551E9E2A070069AD1B /* CCFavorites.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A3214F1E9E2A070069AD1B /* CCFavorites.m */; };
-		F7A3218C1E9E42B30069AD1B /* CCMenuAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */; };
 		F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */; };
 		F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */; };
 		F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F7230E81CB007ACF8A /* NCBrowserWeb.swift */; };
@@ -428,6 +430,7 @@
 		F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CCCellMainTransfer.xib; sourceTree = "<group>"; };
 		F70211FA1BAC56E9003FC03E /* CCMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMain.h; sourceTree = "<group>"; };
 		F70211FB1BAC56E9003FC03E /* CCMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCMain.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+		F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NotificationCenter+MainThread.swift"; sourceTree = "<group>"; };
 		F704B5E22430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCCreateFormUploadConflict.storyboard; sourceTree = "<group>"; };
 		F704B5E42430AA8000632F5F /* NCCreateFormUploadConflict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCreateFormUploadConflict.swift; sourceTree = "<group>"; };
 		F704B5E62430C06700632F5F /* NCCreateFormUploadConflictCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCCreateFormUploadConflictCell.xib; sourceTree = "<group>"; };
@@ -713,8 +716,6 @@
 		F79A65C52191D95E00FF6DCC /* NCSelect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSelect.swift; sourceTree = "<group>"; };
 		F7A3214E1E9E2A070069AD1B /* CCFavorites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFavorites.h; sourceTree = "<group>"; };
 		F7A3214F1E9E2A070069AD1B /* CCFavorites.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCFavorites.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
-		F7A3218A1E9E42B30069AD1B /* CCMenuAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuAccount.h; sourceTree = "<group>"; };
-		F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCMenuAccount.m; sourceTree = "<group>"; };
 		F7A321AB1E9E6AD50069AD1B /* CCAdvanced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAdvanced.h; sourceTree = "<group>"; };
 		F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCAdvanced.m; sourceTree = "<group>"; };
 		F7A54C341C6267B500E2C8BF /* CCExifGeo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCExifGeo.h; sourceTree = "<group>"; };
@@ -1328,15 +1329,6 @@
 			path = Activity;
 			sourceTree = "<group>";
 		};
-		F7A321891E9E42B20069AD1B /* MenuAccount */ = {
-			isa = PBXGroup;
-			children = (
-				F7A3218A1E9E42B30069AD1B /* CCMenuAccount.h */,
-				F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */,
-			);
-			path = MenuAccount;
-			sourceTree = "<group>";
-		};
 		F7ACE4281BAC0268006C0017 /* Settings */ = {
 			isa = PBXGroup;
 			children = (
@@ -1453,6 +1445,7 @@
 				F7053E3D1C639DF500741EA5 /* CCUtility.m */,
 				F78E7064219F096B006F23E4 /* NCAvatar.swift */,
 				F765608E23BF813500765969 /* NCContentPresenter.swift */,
+				F70460512499061800BB98A7 /* NotificationCenter+MainThread.swift */,
 				F70968A324212C4E00ED60E5 /* NCLivePhoto.swift */,
 				F707C26421A2DC5200F6181E /* NCStoreReview.swift */,
 				F70BFC7320E0FA7C00C67599 /* NCUtility.swift */,
@@ -1642,7 +1635,6 @@
 				F7BFFA621A24D7300044ED85 /* Login */,
 				F7BFCCBD1B68C21900548E76 /* ManageLocation+ManageAsset */,
 				F7EC9CB921185F2000F1C5CE /* Media */,
-				F7A321891E9E42B20069AD1B /* MenuAccount */,
 				F74D3DB81BAC1941000BAE4B /* Networking */,
 				F7C5259A1E3B441D00FFE02C /* Notification */,
 				F7381ED9218218A4000B1560 /* Offline */,
@@ -2142,6 +2134,7 @@
 				F711CCBD246AC99E0009B204 /* UtilsFramework.m in Sources */,
 				F711CCE3246AC99E0009B204 /* OCNotifications.m in Sources */,
 				F785EEA32461A23C00B3F945 /* CCExifGeo.m in Sources */,
+				F70460532499095400BB98A7 /* NotificationCenter+MainThread.swift in Sources */,
 				F711CCDB246AC99E0009B204 /* OCActivity.m in Sources */,
 				F711CCB7246AC99E0009B204 /* OCNotificationsAction.m in Sources */,
 				F71459C21D12E3B700CAFEEC /* ShareViewController.m in Sources */,
@@ -2201,6 +2194,7 @@
 				F73D5E49246DE09200DF6467 /* NCElementsJSON.swift in Sources */,
 				F771E3D520E2392D00AFB62D /* FileProviderItem.swift in Sources */,
 				F7434B3620E23FE000417916 /* NCManageDatabase.swift in Sources */,
+				F70460542499095400BB98A7 /* NotificationCenter+MainThread.swift in Sources */,
 				F716FE7A23795EC500FABE50 /* FileProviderExtension+NetworkingDelegate.swift in Sources */,
 				F785EEA42461A4A600B3F945 /* NCUtility.swift in Sources */,
 				F771E3F320E239A600AFB62D /* FileProviderData.swift in Sources */,
@@ -2287,7 +2281,6 @@
 				F76673ED22C901F6007ED366 /* FileProviderDomain.swift in Sources */,
 				F77B0E311D118A16002130FE /* CCExifGeo.m in Sources */,
 				F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */,
-				F7A3218C1E9E42B30069AD1B /* CCMenuAccount.m in Sources */,
 				F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */,
 				F7FCFFE01D707B83000E6E29 /* CCPeekPop.m in Sources */,
 				F7BAADC81ED5A87C00B7EAD4 /* NCDatabase.swift in Sources */,
@@ -2297,6 +2290,7 @@
 				F711CCB2246AC99E0009B204 /* OCFileDto.m in Sources */,
 				F7682FE023C36B0500983A04 /* NCMainTabBar.swift in Sources */,
 				F77B0E5F1D118A16002130FE /* CCSettings.m in Sources */,
+				F70460522499061800BB98A7 /* NotificationCenter+MainThread.swift in Sources */,
 				F78F74362163781100C2ADAD /* NCTrash.swift in Sources */,
 				F711CCD4246AC99E0009B204 /* OCWebDAVClient.m in Sources */,
 				3781B9B223DB2B9F006B4B1D /* CCMain+Menu.swift in Sources */,
@@ -2480,7 +2474,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2499,7 +2493,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				OTHER_LDFLAGS = "-ObjC";
@@ -2531,7 +2525,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2550,7 +2544,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				MTL_FAST_MATH = YES;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.Nextcloud.Notification-Service-Extension";
@@ -2574,7 +2568,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2593,7 +2587,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = it.twsweb.Nextcloud.Share;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2618,7 +2612,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2637,7 +2631,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = it.twsweb.Nextcloud.Share;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2668,7 +2662,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2687,7 +2681,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.Nextcloud.File-Provider-Extension";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2718,7 +2712,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2737,7 +2731,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.Nextcloud.File-Provider-Extension";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2760,7 +2754,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2776,7 +2770,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				OTHER_SWIFT_FLAGS = "";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.$(PRODUCT_NAME:rfc1034identifier)";
@@ -2805,7 +2799,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 72;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2820,7 +2814,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "";
-				MARKETING_VERSION = 3.0.0;
+				MARKETING_VERSION = 3.0.1;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 1 - 1
Share/NCSelectDestination.m

@@ -102,7 +102,7 @@
 {
     [super viewWillAppear:animated];
     
-    self.navigationController.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand;
+    self.navigationController.navigationBar.barTintColor = NCBrandColor.sharedInstance.brandElement;
     self.navigationController.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText;
     
     self.navigationController.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;

+ 0 - 6
iOSClient/AppDelegate.h

@@ -101,12 +101,6 @@
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
 
-@property (nonatomic, strong) NSMutableArray *arrayDeleteMetadata;
-@property (nonatomic, strong) NSMutableArray *arrayMoveMetadata;
-@property (nonatomic, strong) NSMutableArray *arrayMoveServerUrlTo;
-@property (nonatomic, strong) NSMutableArray *arrayCopyMetadata;
-@property (nonatomic, strong) NSMutableArray *arrayCopyServerUrlTo;
-
 @property (nonatomic) UIUserInterfaceStyle preferredUserInterfaceStyle API_AVAILABLE(ios(12.0));
 
 // Shares

+ 34 - 103
iOSClient/AppDelegate.m

@@ -85,12 +85,7 @@
 
     self.listProgressMetadata = [NSMutableDictionary new];
     self.listMainVC = [NSMutableDictionary new];
-    self.arrayDeleteMetadata = [NSMutableArray new];
-    self.arrayMoveMetadata = [NSMutableArray new];
-    self.arrayMoveServerUrlTo = [NSMutableArray new];
-    self.arrayCopyMetadata = [NSMutableArray new];
-    self.arrayCopyServerUrlTo = [NSMutableArray new];
-    
+   
     // Push Notification
     [application registerForRemoteNotifications];
     
@@ -158,13 +153,7 @@
 
     // init home
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
-    
-    // Observer
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moveFile:) name:k_notificationCenter_moveFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(copyFile:) name:k_notificationCenter_copyFile object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadedFile:) name:k_notificationCenter_uploadedFile object:nil];
-    
+
     // Passcode
     dispatch_async(dispatch_get_main_queue(), ^{
         [self passcodeWithAutomaticallyPromptForBiometricValidation:true];
@@ -190,9 +179,10 @@
 //
 - (void)applicationWillEnterForeground:(UIApplication *)application
 {
-    // Test Maintenance
-    if (self.activeAccount.length == 0 || self.maintenanceMode)
-        return;
+    if (self.activeAccount.length == 0 || self.maintenanceMode) { return; }
+    
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_applicationWillEnterForeground object:nil];
+
     
     NSLog(@"[LOG] Request Passcode");
     [self passcodeWithAutomaticallyPromptForBiometricValidation:true];
@@ -218,16 +208,8 @@
 //
 - (void)applicationDidBecomeActive:(UIApplication *)application
 {
-    // Test Maintenance
-    if (self.activeAccount.length == 0 || self.maintenanceMode)
-        return;
+    if (self.activeAccount.length == 0 || self.maintenanceMode) { return; }
         
-    // middelware ping
-    if ([[NCBrandOptions sharedInstance] use_middlewarePing]) {
-        NSLog(@"[LOG] Middleware Ping");
-        [[NCService shared] middlewarePing];
-    }
-
     // Brand
     #if defined(HC)
     tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
@@ -246,9 +228,10 @@
 //
 - (void)applicationDidEnterBackground:(UIApplication *)application
 {
-    NSLog(@"[LOG] Enter in Background");
-            
+    if (self.activeAccount.length == 0 || self.maintenanceMode) { return; }
+
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_applicationDidEnterBackground object:nil];
+    
     [self passcodeWithAutomaticallyPromptForBiometricValidation:false];
 }
 
@@ -651,63 +634,6 @@
     return [token copy];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ==== NotificationCenter ====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)deleteFile:(NSNotification *)notification
-{
-    if (self.arrayDeleteMetadata.count > 0) {
-        tableMetadata *metadata = self.arrayDeleteMetadata.firstObject;
-        [self.arrayDeleteMetadata removeObjectAtIndex:0];
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
-        if (account) {
-            [[NCNetworking shared] deleteMetadata:metadata account:metadata.account url:account.url completion:^(NSInteger errorCode, NSString *errorDescription) { }];
-        } else {
-            [self deleteFile:[NSNotification new]];
-        }
-    }
-}
-
-- (void)moveFile:(NSNotification *)notification
-{
-    if (self.arrayMoveMetadata.count > 0) {
-        tableMetadata *metadata = self.arrayMoveMetadata.firstObject;
-        NSString *serverUrlTo = self.arrayMoveServerUrlTo.firstObject;
-        [self.arrayMoveMetadata removeObjectAtIndex:0];
-        [self.arrayMoveServerUrlTo removeObjectAtIndex:0];
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
-        if (account) {
-            [[NCNetworking shared] moveMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
-        } else {
-            [self moveFile:[NSNotification new]];
-        }
-    }
-}
-
-- (void)copyFile:(NSNotification *)notification
-{
-    if (self.arrayCopyMetadata.count > 0) {
-        tableMetadata *metadata = self.arrayCopyMetadata.firstObject;
-        NSString *serverUrlTo = self.arrayCopyServerUrlTo.firstObject;
-        [self.arrayCopyMetadata removeObjectAtIndex:0];
-        [self.arrayCopyServerUrlTo removeObjectAtIndex:0];
-        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
-        if (account) {
-            [[NCNetworking shared] copyMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
-        } else {
-            [self copyFile:[NSNotification new]];
-        }
-    }
-}
-
-- (void)uploadedFile:(NSNotification *)notification
-{
-//    NSDictionary *userInfo = notification.userInfo;
-//    tableMetadata *metadata = userInfo[@"metadata"];
-//    NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Quick Actions - ShotcutItem =====
 #pragma --------------------------------------------------------------------------------------------
@@ -863,7 +789,7 @@
     UIButton *buttonPlus = [UIButton buttonWithType:UIButtonTypeCustom];
     buttonPlus.tag = 99;
     [buttonPlus setImage:buttonImage forState:UIControlStateNormal];
-    buttonPlus.backgroundColor = NCBrandColor.sharedInstance.brand;
+    buttonPlus.backgroundColor = NCBrandColor.sharedInstance.brandElement;
     buttonPlus.layer.cornerRadius = buttonSize / 2;
     buttonPlus.layer.masksToBounds = NO;
     buttonPlus.layer.shadowOffset = CGSizeMake(0, 0);
@@ -970,32 +896,37 @@
 
         [CCGraphics settingThemingColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
         
-        UIColor *color = NCBrandColor.sharedInstance.brand;
-        BOOL isTooLight = NCBrandColor.sharedInstance.brand.isTooLight;
-        BOOL isTooDark = NCBrandColor.sharedInstance.brand.isTooDark;
+        BOOL isTooLight = NCBrandColor.sharedInstance.brandElement.isTooLight;
+        BOOL isTooDark = NCBrandColor.sharedInstance.brandElement.isTooDark;
         
         if (isTooLight) {
-            color = [NCBrandColor.sharedInstance.brand darkerBy:10];
+            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.brandElement darkerBy:10];
         } else if (isTooDark) {
-            color = [NCBrandColor.sharedInstance.brand lighterBy:10];
+            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.brandElement lighterBy:15];
         }
-        
-        NCBrandColor.sharedInstance.brand = color;
-            
+    
     } else {
     
+        BOOL isTooLight = NCBrandColor.sharedInstance.customer.isTooLight;
+        BOOL isTooDark = NCBrandColor.sharedInstance.customer.isTooDark;
+        
+        if (isTooLight) {
+            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.customer darkerBy:10];
+        } else if (isTooDark) {
+            NCBrandColor.sharedInstance.brandElement = [NCBrandColor.sharedInstance.customer lighterBy:15];
+        } else {
+            NCBrandColor.sharedInstance.brandElement = NCBrandColor.sharedInstance.customer;
+        }
+        
         NCBrandColor.sharedInstance.brand = NCBrandColor.sharedInstance.customer;
-        NCBrandColor.sharedInstance.brandElement = NCBrandColor.sharedInstance.customer;
         NCBrandColor.sharedInstance.brandText = NCBrandColor.sharedInstance.customerText;
     }
         
     [NCBrandColor.sharedInstance setDarkMode];
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         [[NCMainCommon sharedInstance] createImagesThemingColor];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
     });
-    
-    
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
 }
 
 - (void)changeTheming:(UIViewController *)viewController tableView:(UITableView *)tableView collectionView:(UICollectionView *)collectionView form:(BOOL)form
@@ -1153,7 +1084,7 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                [[NCNetworking shared] uploadWithMetadata:metadata];
+                [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                     
                 break;
                                         
@@ -1162,7 +1093,7 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                [[NCNetworking shared] uploadWithMetadata:metadata];
+                [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                     
                 counterUpload++;
                 sizeUpload = sizeUpload + metadata.size;
@@ -1198,7 +1129,7 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                                           
-                [[NCNetworking shared] uploadWithMetadata:metadata];
+                [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                                 
                 break;
                 
@@ -1207,7 +1138,7 @@
                 metadataForUpload.status = k_metadataStatusInUpload;
                 tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                            
-                [[NCNetworking shared] uploadWithMetadata:metadata];
+                [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                            
                 counterUpload++;
                 sizeUpload = sizeUpload + metadata.size;
@@ -1253,7 +1184,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[NCNetworking shared] uploadWithMetadata:metadata];
+                    [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                     
                     break;
                     
@@ -1262,7 +1193,7 @@
                     metadataForUpload.status = k_metadataStatusInUpload;
                     tableMetadata *metadata = [[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
                     
-                    [[NCNetworking shared] uploadWithMetadata:metadata];
+                    [[NCNetworking shared] uploadWithMetadata:metadata background:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
                     
                     counterUpload++;
                     sizeUpload = sizeUpload + metadata.size;

+ 1 - 3
iOSClient/Brand/NCBrand.swift

@@ -53,7 +53,6 @@ import UIKit
     @objc public var pushNotificationServerProxy:       String = "https://push-notifications.nextcloud.com"
     @objc public var linkLoginHost:                     String = "https://nextcloud.com/install"
     @objc public var linkloginPreferredProviders:       String = "https://nextcloud.com/signup";
-    @objc public var middlewarePingUrl:                 String = ""
     @objc public var webLoginAutenticationProtocol:     String = "nc://"                                            // example "abc://"
     // Personalized
     @objc public var webCloseViewProtocolPersonalized:  String = ""                                                 // example "abc://change/plan"      Don't touch me !!
@@ -74,7 +73,6 @@ import UIKit
     @objc public var use_themingColor:                  Bool = true
     //@objc public var use_themingBackground:             Bool = true                                               // Deprecated
     @objc public var use_themingLogo:                   Bool = false
-    @objc public var use_middlewarePing:                Bool = false
     @objc public var use_storeLocalAutoUploadAll:       Bool = false
     @objc public var use_configuration:                 Bool = false                                                // Don't touch me !!
     @objc public var use_loginflowv2:                   Bool = false                                                // Don't touch me !!
@@ -152,7 +150,7 @@ class NCBrandColor: NSObject {
             backgroundForm = UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0)
             textView = .black
             separator = UIColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1.0)
-            select = self.brand.withAlphaComponent(0.1)
+            select = self.brandElement.withAlphaComponent(0.1)
         }
     }
 }

+ 2 - 1
iOSClient/CCGlobal.h

@@ -85,7 +85,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         120
+#define k_databaseSchemaVersion                         121
 
 // Intro selector
 #define k_intro_login                                   0
@@ -296,6 +296,7 @@
 // Notification Center
 
 #define k_notificationCenter_applicationDidEnterBackground  @"applicationDidEnterBackground"
+#define k_notificationCenter_applicationWillEnterForeground @"applicationWillEnterForeground"
 
 #define k_notificationCenter_initializeMain             @"initializeMain"
 #define k_notificationCenter_setTitleMain               @"setTitleMain"

+ 0 - 2
iOSClient/Database/NCDatabase.swift

@@ -48,8 +48,6 @@ class tableAccount: Object {
     @objc dynamic var company = ""
     @objc dynamic var country = ""
     @objc dynamic var displayName = ""
-    @objc dynamic var dateUpdateNewMedia: NSDate? = nil
-    @objc dynamic var dateLessMedia: NSDate? = nil
     @objc dynamic var email = ""
     @objc dynamic var enabled: Bool = false
     @objc dynamic var groups = ""

+ 0 - 80
iOSClient/Database/NCManageDatabase.swift

@@ -671,40 +671,6 @@ class NCManageDatabase: NSObject {
     }
     #endif
     
-    @objc func setAccountDateUpdateNewMedia(clear: Bool = false) {
-        
-        let realm = try! Realm()
-
-        do {
-            try realm.write {
-                if let result = realm.objects(tableAccount.self).filter("active == true").first {
-                    if clear {
-                        result.dateUpdateNewMedia = nil
-                    } else {
-                        result.dateUpdateNewMedia = Date() as NSDate
-                    }
-                }
-            }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-        }
-    }
-    
-    @objc func setAccountDateLessMedia(date: NSDate?) {
-        
-        let realm = try! Realm()
-
-        do {
-            try realm.write {
-                if let result = realm.objects(tableAccount.self).filter("active == true").first {
-                    result.dateLessMedia = date
-                }
-            }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-        }
-    }
-    
     //MARK: -
     //MARK: Table Activity
 
@@ -2438,52 +2404,6 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    func updateMetadatasMedia(_ metadatasSource: [tableMetadata], lteDate: Date, gteDate: Date, account: String) -> (isDifferent: Bool, newInsert: Int) {
-
-        let realm = try! Realm()
-        realm.refresh()
-        
-        var numDelete: Int = 0
-        var numInsert: Int = 0
-        
-        var etagsDelete: [String] = []
-        var etagsInsert: [String] = []
-        
-        var isDifferent: Bool = false
-        var newInsert: Int = 0
-        
-        do {
-            try realm.write {
-                
-                // DELETE
-                let results = realm.objects(tableMetadata.self).filter("account == %@ AND date >= %@ AND date <= %@ AND (typeFile == %@ OR typeFile == %@ OR typeFile == %@)", account, gteDate, lteDate, k_metadataTypeFile_image, k_metadataTypeFile_video, k_metadataTypeFile_audio)
-                etagsDelete = Array(results.map { $0.etag })
-                numDelete = results.count
-                
-                // INSERT
-                let photos = Array(metadatasSource.map { tableMetadata.init(value:$0) })
-                etagsInsert = Array(photos.map { $0.etag })
-                numInsert = photos.count
-                
-                // CALCULATE DIFFERENT RETURN
-                if etagsDelete.count == etagsInsert.count && etagsDelete.sorted() == etagsInsert.sorted() {
-                    isDifferent = false
-                } else {
-                    isDifferent = true
-                    newInsert = numInsert - numDelete
-                    
-                    realm.delete(results)
-                    realm.add(photos, update: .all)
-                }
-            }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
-            realm.cancelWrite()
-        }
-        
-        return(isDifferent, newInsert)
-    }
-
     //MARK: -
     //MARK: Table Photo Library
     

+ 0 - 1
iOSClient/Favorites/CCFavorites.h

@@ -42,7 +42,6 @@
 
 - (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector;
 - (void)listingFavorites;
-
 - (void)actionDelete:(NSIndexPath *)indexPath;
 
 @end

+ 52 - 52
iOSClient/Favorites/CCFavorites.m

@@ -85,9 +85,10 @@
     }
     
     // calculate _serverUrl
-    if (!_serverUrl)
+    if (!_serverUrl) {
         _serverUrl = nil;
-  
+    }
+    
     // Title
     if (_titleViewControl)
         self.title = _titleViewControl;
@@ -103,8 +104,12 @@
     
     // Active Main
     appDelegate.activeFavorites = self;
-    
+
     [self reloadDatasource];
+
+    if (self.serverUrl == nil) {
+        [self listingFavorites];
+    }
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -176,56 +181,51 @@
         return;
 
     [[NCCommunication shared] listingFavoritesWithShowHiddenFiles:[CCUtility getShowHiddenFiles] customUserAgent:nil addCustomHeaders:nil completionHandler:^(NSString *account, NSArray *files, NSInteger errorCode, NSString *errorMessage) {
-        
-         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount] && files != nil) {
-             
-             [[NCManageDatabase sharedInstance] convertNCCommunicationFilesToMetadatas:files useMetadataFolder:false account:account completion:^(tableMetadata *metadataFolder, NSArray<tableMetadata *> *metadatasFolder, NSArray<tableMetadata *> *metadatas) {
-                 
-                 NSString *father = @"";
-                 NSMutableArray *filesOcId = [NSMutableArray new];
-                 
-                 for (tableMetadata *metadata in metadatas) {
-                     
-                     // insert for test NOT favorite
-                     [filesOcId addObject:metadata.ocId];
-                     
-                     NSString *serverUrl = metadata.serverUrl;
-                     NSString *serverUrlSon = [CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName];
-                     
-                     if (![serverUrlSon containsString:father]) {
-                         
-                         if (metadata.directory) {
-                             
-                             if ([CCUtility getFavoriteOffline])
-                                 [[CCSynchronize sharedSynchronize] readFolder:[CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName] selector:selectorReadFolderWithDownload account:account];
-                             else
-                                 [[CCSynchronize sharedSynchronize] readFolder:[CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName] selector:selectorReadFolder account:account];
-                             
-                         } else {
-                             
-                             if ([CCUtility getFavoriteOffline])
-                                 [[CCSynchronize sharedSynchronize] readFile:metadata.ocId fileName:metadata.fileName serverUrl:serverUrl selector:selectorReadFileWithDownload account:account];
-                             else
-                                 [[CCSynchronize sharedSynchronize] readFile:metadata.ocId fileName:metadata.fileName serverUrl:serverUrl selector:selectorReadFile account:account];
-                         }
-                         
-                         father = serverUrlSon;
-                     }
-                 }
+        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount] && files != nil) {
+            [[NCManageDatabase sharedInstance] convertNCCommunicationFilesToMetadatas:files useMetadataFolder:false account:account completion:^(tableMetadata *metadataFolder, NSArray<tableMetadata *> *metadatasFolder, NSArray<tableMetadata *> *metadatas) {
+                NSString *father = @"";
+                NSMutableArray *filesOcId = [NSMutableArray new];
                  
-                 // Verify remove favorite
-                 NSArray *allRecordFavorite = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND favorite == true", account] sorted:nil ascending:NO];
+                for (tableMetadata *metadata in metadatas) {
+                    // insert for test NOT favorite
+                    [filesOcId addObject:metadata.ocId];
+                    NSString *serverUrl = metadata.serverUrl;
+                    NSString *serverUrlSon = [CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName];
+                    if (![serverUrlSon containsString:father]) {
+                        if (metadata.directory) {
+                            if ([CCUtility getFavoriteOffline])
+                                [[CCSynchronize sharedSynchronize] readFolder:[CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName] selector:selectorReadFolderWithDownload account:account];
+                            else
+                                [[CCSynchronize sharedSynchronize] readFolder:[CCUtility stringAppendServerUrl:serverUrl addFileName:metadata.fileName] selector:selectorReadFolder account:account];
+                        } else {
+                            if ([CCUtility getFavoriteOffline])
+                                [[CCSynchronize sharedSynchronize] readFile:metadata.ocId fileName:metadata.fileName serverUrl:serverUrl selector:selectorReadFileWithDownload account:account];
+                            else
+                                [[CCSynchronize sharedSynchronize] readFile:metadata.ocId fileName:metadata.fileName serverUrl:serverUrl selector:selectorReadFile account:account];
+                        }
+                        father = serverUrlSon;
+                    }
+                    tableMetadata *metadataFavorite = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
+                    if (metadataFavorite == nil) {
+                        [[NCManageDatabase sharedInstance] addMetadata:metadata];
+                    } else if (!metadataFavorite.favorite) {
+                        [[NCManageDatabase sharedInstance] setMetadataFavoriteWithOcId:metadata.ocId favorite:true];
+                    }
+                }
                  
-                 for (tableMetadata *metadata in allRecordFavorite)
-                     if (![filesOcId containsObject:metadata.ocId])
-                         [[NCManageDatabase sharedInstance] setMetadataFavoriteWithOcId:metadata.ocId favorite:NO];
-             }];
-        
-         } else if (errorCode != 0) {
-             [[NCContentPresenter shared] messageNotification:@"_error_" description:errorMessage delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-         } else {
-             NSLog(@"[LOG] It has been changed user during networking process, error.");
-         }
+                // Verify remove favorite
+                NSArray *allRecordFavorite = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND favorite == true", account] sorted:nil ascending:NO];
+                for (tableMetadata *metadata in allRecordFavorite)
+                    if (![filesOcId containsObject:metadata.ocId])
+                        [[NCManageDatabase sharedInstance] setMetadataFavoriteWithOcId:metadata.ocId favorite:NO];
+                
+                [self reloadDatasource];
+            }];
+        } else if (errorCode != 0) {
+            [[NCContentPresenter shared] messageNotification:@"_error_" description:errorMessage delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
+        } else {
+            NSLog(@"[LOG] It has been changed user during networking process, error.");
+        }
     }];
 }
 
@@ -435,7 +435,7 @@
         
     } else {
         
-        recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, _serverUrl] sorted:nil ascending:NO];
+        recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl] sorted:nil ascending:NO];
     }
     
     sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:nil filterTypeFileImage:NO filterTypeFileVideo:NO filterLivePhoto:YES sorted:sorted ascending:[CCUtility getAscendingSettings] activeAccount:appDelegate.activeAccount];

+ 2 - 2
iOSClient/Login/NCAppConfigView.swift

@@ -38,7 +38,7 @@ class NCAppConfigView: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        self.view.backgroundColor = NCBrandColor.sharedInstance.brand
+        self.view.backgroundColor = NCBrandColor.sharedInstance.brandElement
         titleLabel.textColor = NCBrandColor.sharedInstance.brandText
         
         titleLabel.text = NSLocalizedString("_appconfig_view_title_", comment: "")
@@ -92,7 +92,7 @@ class NCAppConfigView: UIViewController {
                     }
                     
                     self.appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token!)
-                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
                     
                     self.dismiss(animated: true) {}
                 } else {

+ 3 - 3
iOSClient/Login/NCLoginWeb.swift

@@ -234,7 +234,7 @@ extension NCLoginWeb: WKNavigationDelegate {
             
         if (CCUtility.getIntro()) {
             
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
             self.dismiss(animated: true)
                 
         } else {
@@ -243,7 +243,7 @@ extension NCLoginWeb: WKNavigationDelegate {
             if (self.presentingViewController == nil) {
                 let splitController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                 splitController?.modalPresentationStyle = .fullScreen
-                NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
                 splitController!.view.alpha = 0
                 appDelegate.window.rootViewController = splitController!
                 appDelegate.window.makeKeyAndVisible()
@@ -251,7 +251,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                     splitController!.view.alpha = 1
                 }
             } else {
-                NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_initializeMain)
                 self.dismiss(animated: true)
             }
         }

+ 1 - 1
iOSClient/Main/AppDelegate+Swift.swift

@@ -36,7 +36,7 @@ extension AppDelegate {
             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.brand
+        viewController.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandElement
         viewController.navigationController?.navigationBar.setNeedsLayout()
     }
     

+ 2 - 2
iOSClient/Main/CCMain+Swift.swift

@@ -27,7 +27,7 @@ extension CCMain {
                 self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
                 self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
                 self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
-                self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
+                self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandElement
                 self.navigationController?.navigationBar.shadowImage = nil
                 self.navigationController?.navigationBar.setValue(false, forKey: "hidesShadow")
             }
@@ -50,7 +50,7 @@ extension CCMain {
                 self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
                 self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
                 self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
-                self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
+                self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandElement
                 self.navigationController?.navigationBar.shadowImage = UIImage()
                 self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
             }

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -33,7 +33,6 @@
 #import "CCSection.h"
 #import "CCUtility.h"
 #import "CCHud.h"
-#import "CCMenuAccount.h"
 #import "CCPeekPop.h"
 #import <MGSwipeTableCell/MGSwipeTableCell.h>
 

+ 73 - 159
iOSClient/Main/CCMain.m

@@ -71,6 +71,13 @@
     
     CGFloat heightRichWorkspace;
     CGFloat heightSearchBar;
+    
+    //
+    NSMutableArray *arrayDeleteMetadata;
+    NSMutableArray *arrayMoveMetadata;
+    NSMutableArray *arrayMoveServerUrlTo;
+    NSMutableArray *arrayCopyMetadata;
+    NSMutableArray *arrayCopyServerUrlTo;
 }
 @end
 
@@ -114,6 +121,12 @@
     _cellFavouriteImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"favorite"] width:50 height:50 color:[UIColor whiteColor]];
     _cellTrashImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"trash"] width:50 height:50 color:[UIColor whiteColor]];
     
+    arrayDeleteMetadata = [NSMutableArray new];
+    arrayMoveMetadata = [NSMutableArray new];
+    arrayMoveServerUrlTo = [NSMutableArray new];
+    arrayCopyMetadata = [NSMutableArray new];
+    arrayCopyServerUrlTo = [NSMutableArray new];
+    
     // delegate
     self.tableView.tableFooterView = [UIView new];
     self.tableView.emptyDataSetDelegate = self;
@@ -137,7 +150,7 @@
     self.searchController.dimsBackgroundDuringPresentation = NO;
     UIButton *searchButton = self.searchController.searchBar.subviews.firstObject.subviews.lastObject;
     if (searchButton && [searchButton isKindOfClass:[UIButton class]]) {
-        [searchButton setTitleColor:NCBrandColor.sharedInstance.brand forState:UIControlStateNormal];
+        [searchButton setTitleColor:NCBrandColor.sharedInstance.brandElement forState:UIControlStateNormal];
     }
     UITextField *searchTextField = [self.searchController.searchBar valueForKey:@"searchField"];
     if (searchTextField && [searchTextField isKindOfClass:[UITextField class]]) {
@@ -154,8 +167,8 @@
     self.sortButton = self.viewRichWorkspace.sortButton;
     heightSearchBar = self.viewRichWorkspace.topView.frame.size.height;
 
-    [self.sortButton setTitleColor:NCBrandColor.sharedInstance.brand forState:UIControlStateNormal];
-    [self.sortButton addTarget:self action:@selector(toggleReMainMenu) forControlEvents:UIControlEventTouchUpInside];
+    [self.sortButton setTitleColor:NCBrandColor.sharedInstance.brandElement forState:UIControlStateNormal];
+    [self.sortButton addTarget:self action:@selector(toggleSortMenu) forControlEvents:UIControlEventTouchUpInside];
     
     heightRichWorkspace = UIScreen.mainScreen.bounds.size.height / 4 + heightSearchBar;
     [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, heightRichWorkspace)];
@@ -328,13 +341,13 @@
     refreshControl.tintColor = UIColor.lightGrayColor;
     refreshControl.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
 
-    [self.sortButton setTitleColor:NCBrandColor.sharedInstance.brand forState:UIControlStateNormal];
+    [self.sortButton setTitleColor:NCBrandColor.sharedInstance.brandElement forState:UIControlStateNormal];
     // color searchbar
-    self.searchController.searchBar.tintColor = NCBrandColor.sharedInstance.brand;
+    self.searchController.searchBar.tintColor = NCBrandColor.sharedInstance.brandElement;
     // color searchbbar button text (cancel)
     UIButton *searchButton = self.searchController.searchBar.subviews.firstObject.subviews.lastObject;
     if (searchButton && [searchButton isKindOfClass:[UIButton class]]) {
-        [searchButton setTitleColor:NCBrandColor.sharedInstance.brand forState:UIControlStateNormal];
+        [searchButton setTitleColor:NCBrandColor.sharedInstance.brandElement forState:UIControlStateNormal];
     }
     // color textview searchbbar
     UITextField *searchTextView = [self.searchController.searchBar valueForKey:@"searchField"];
@@ -429,54 +442,76 @@
 
 - (void)deleteFile:(NSNotification *)notification
 {
-    if (self.view.window == nil) { return; }
-    
     NSDictionary *userInfo = notification.userInfo;
     tableMetadata *metadata = userInfo[@"metadata"];
     NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
     NSString *errorDescription = userInfo[@"errorDescription"];
     
-    if (errorCode == 0 && metadata) {
-        if ([metadata.serverUrl isEqualToString:self.serverUrl]) {
-            if ([metadata.fileNameView.lowercaseString isEqualToString:k_fileNameRichWorkspace.lowercaseString]) {
-                [self readFileReloadFolder];
-            } else {
-                if (self.searchController.isActive) {
-                    [self readFolder:self.serverUrl];
-                }
+    if (![metadata.serverUrl isEqualToString:self.serverUrl]) { return; }
+    
+    if (arrayDeleteMetadata.count > 0) {
+        tableMetadata *metadata = arrayDeleteMetadata.firstObject;
+        [arrayDeleteMetadata removeObjectAtIndex:0];
+        [[NCNetworking shared] deleteMetadata:metadata account:metadata.account url:metadata.url completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+    }
+
+    if (errorCode == 0 ) {
+        if ([metadata.fileNameView.lowercaseString isEqualToString:k_fileNameRichWorkspace.lowercaseString]) {
+            [self readFileReloadFolder];
+        } else {
+            if (self.searchController.isActive) {
+                [self readFolder:self.serverUrl];
             }
         }
-    } else {
+    }
+    
+    if (errorCode != 0 && self.view.window != nil) {
         [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
     }
 }
 
 - (void)moveFile:(NSNotification *)notification
 {
-    if (self.view.window == nil) { return; }
-    
     NSDictionary *userInfo = notification.userInfo;
-//    tableMetadata *metadata = userInfo[@"metadata"];
+    tableMetadata *metadata = userInfo[@"metadata"];
 //    tableMetadata *metadataNew = userInfo[@"metadataNew"];
     NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
     NSString *errorDescription = userInfo[@"errorDescription"];
     
-    if (errorCode != 0) {
+    if (![metadata.serverUrl isEqualToString:self.serverUrl]) { return; }
+    
+    if (arrayMoveMetadata.count > 0) {
+        tableMetadata *metadata = arrayMoveMetadata.firstObject;
+        NSString *serverUrlTo = arrayMoveServerUrlTo.firstObject;
+        [arrayMoveMetadata removeObjectAtIndex:0];
+        [arrayMoveServerUrlTo removeObjectAtIndex:0];
+        [[NCNetworking shared] moveMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+    }
+    
+    if (errorCode != 0 && self.view.window != nil) {
         [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
     }
 }
 
 - (void)copyFile:(NSNotification *)notification
 {
-    if (self.view.window == nil) { return; }
-    
     NSDictionary *userInfo = notification.userInfo;
-//    tableMetadata *metadata = userInfo[@"metadata"];
+    tableMetadata *metadata = userInfo[@"metadata"];
 //    NSString *serverUrlTo = userInfo[@"serverUrlTo"];
     NSInteger errorCode = [userInfo[@"errorCode"] integerValue];
     NSString *errorDescription = userInfo[@"errorDescription"];
     
-    if (errorCode != 0) {
+    if (![metadata.serverUrl isEqualToString:self.serverUrl]) { return; }
+    
+    if (arrayCopyMetadata.count > 0) {
+        tableMetadata *metadata = arrayCopyMetadata.firstObject;
+        NSString *serverUrlTo = arrayCopyServerUrlTo.firstObject;
+        [arrayCopyMetadata removeObjectAtIndex:0];
+        [arrayCopyServerUrlTo removeObjectAtIndex:0];
+        [[NCNetworking shared] copyMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+    }
+    
+    if (errorCode != 0 && self.view.window != nil) {
         [[NCContentPresenter shared] messageNotification:@"_error_" description:errorDescription delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
     }
 }
@@ -687,7 +722,7 @@
 
 - (void)setUINavigationBarSelected
 {    
-    UIBarButtonItem *buttonMore = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigationMore"] style:UIBarButtonItemStylePlain target:self action:@selector(toggleReSelectMenu)];
+    UIBarButtonItem *buttonMore = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigationMore"] style:UIBarButtonItemStylePlain target:self action:@selector(toggleSelectMenu)];
     UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(cancelSelect)];
     
     self.navigationItem.leftBarButtonItem = leftButton;
@@ -1218,7 +1253,7 @@
 - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
 {
     // Color text "Cancel"
-    [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTintColor:NCBrandColor.sharedInstance.brand];
+    [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTintColor:NCBrandColor.sharedInstance.brandElement];
     
     if (searchController.isActive) {
         [self deleteRefreshControl];
@@ -1293,13 +1328,13 @@
         return;
      
     if ([_selectedocIdsMetadatas count] > 0) {
-        [appDelegate.arrayDeleteMetadata addObjectsFromArray:[_selectedocIdsMetadatas allValues]];
+        [arrayDeleteMetadata addObjectsFromArray:[_selectedocIdsMetadatas allValues]];
     } else {
-        [appDelegate.arrayDeleteMetadata addObject:self.metadata];
+        [arrayDeleteMetadata addObject:self.metadata];
     }
     
-    [[NCNetworking shared] deleteMetadata:appDelegate.arrayDeleteMetadata.firstObject account:appDelegate.activeAccount url:appDelegate.activeUrl completion:^(NSInteger errorCode, NSString *errorDescription) { }];
-    [appDelegate.arrayDeleteMetadata removeObjectAtIndex:0];
+    [[NCNetworking shared] deleteMetadata:arrayDeleteMetadata.firstObject account:appDelegate.activeAccount url:appDelegate.activeUrl completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+    [arrayDeleteMetadata removeObjectAtIndex:0];
         
     // End Select Table View
     [self tableViewSelect:false];
@@ -1317,11 +1352,11 @@
     NSMutableArray *arrayMetadata, *arrayServerUrlTo;
     
     if (move) {
-        arrayMetadata = appDelegate.arrayMoveMetadata;
-        arrayServerUrlTo = appDelegate.arrayMoveServerUrlTo;
+        arrayMetadata = arrayMoveMetadata;
+        arrayServerUrlTo = arrayMoveServerUrlTo;
     } else {
-        arrayMetadata = appDelegate.arrayCopyMetadata;
-        arrayServerUrlTo = appDelegate.arrayCopyServerUrlTo;
+        arrayMetadata = arrayCopyMetadata;
+        arrayServerUrlTo = arrayCopyServerUrlTo;
     }
     
     if ([_selectedocIdsMetadatas count] > 0) {
@@ -1566,133 +1601,12 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ==== Menu LOGO ====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)menuLogo:(UIGestureRecognizer *)theGestureRecognizer
-{
-    
-    // Brand
-    if ([NCBrandOptions sharedInstance].disable_multiaccount)
-        return;
-    
-    NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
-    
-    NSMutableArray *menuArray = [NSMutableArray new];
-    
-    for (NSString *account in listAccount) {
-    
-        CCMenuItem *item = [[CCMenuItem alloc] init];
-        
-        item.title = [account stringByTruncatingToWidth:self.view.bounds.size.width - 100 withFont:[UIFont systemFontOfSize:12.0] atEnd:YES];
-        item.argument = account;
-        
-        tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ ", account]];
-        
-        NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-%@.png", [CCUtility getDirectoryUserData], [CCUtility getStringUser:tableAccount.user activeUrl:tableAccount.url], tableAccount.user];
-        UIImage *avatar = [UIImage imageWithContentsOfFile:fileNamePath];
-        if (avatar) {
-            
-            avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(25, 25) isAspectRation:YES];
-            CCAvatar *avatarImageView = [[CCAvatar alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
-            CGSize imageSize = avatarImageView.bounds.size;
-            UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
-            CGContextRef context = UIGraphicsGetCurrentContext();
-            [avatarImageView.layer renderInContext:context];
-            avatar = UIGraphicsGetImageFromCurrentImageContext();
-            UIGraphicsEndImageContext();
-            
-        } else {
-            
-            avatar = [UIImage imageNamed:@"menuLogoUser"];
-        }
-        
-        item.image = avatar;
-        item.target = self;
-        
-        if ([account isEqualToString:appDelegate.activeAccount]) {
-            
-            item.action = nil;
-            [menuArray insertObject:item atIndex:0];
-            
-        } else {
-        
-            item.action = @selector(changeDefaultAccount:);
-            [menuArray addObject:item];
-        }
-    }
-    
-    // Add + new account
-    CCMenuItem *item = [[CCMenuItem alloc] init];
-    
-    item.title = NSLocalizedString(@"_add_account_", nil);
-    item.argument = @"";
-    item.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"add"] width:50 height:50 color:NCBrandColor.sharedInstance.textView];
-    item.target = self;
-    item.action = @selector(addNewAccount:);
-    
-    [menuArray addObject:item];
-    
-    OptionalConfiguration options;
-    Color backgroundColor;
-    
-    const CGFloat *componentsBackgroundColor = CGColorGetComponents(NCBrandColor.sharedInstance.backgroundForm.CGColor);
-    backgroundColor.R = componentsBackgroundColor[0];
-    backgroundColor.G = componentsBackgroundColor[1];
-    backgroundColor.B = componentsBackgroundColor[2];
-    
-    options.arrowSize = 9;
-    options.marginXSpacing = 7;
-    options.marginYSpacing = 10;
-    options.intervalSpacing = 20;
-    options.menuCornerRadius = 6.5;
-    options.maskToBackground = NO;
-    options.shadowOfMenu = YES;
-    options.hasSeperatorLine = YES;
-    options.seperatorLineHasInsets = YES;
-    options.textColor = NCBrandColor.sharedInstance.textView;
-    options.menuBackgroundColor = backgroundColor;
-    options.separatorColor = NCBrandColor.sharedInstance.separator;
-    
-    CGRect rect = self.view.frame;
-    CGFloat locationY = [theGestureRecognizer locationInView: self.navigationController.navigationBar].y;
-    CGFloat safeAreaTop = 0;
-    CGFloat offsetY = 35;
-    safeAreaTop = [UIApplication sharedApplication].delegate.window.safeAreaInsets.top / 2;
-    rect.origin.y = locationY + safeAreaTop + offsetY;
-    rect.size.height = rect.size.height - locationY - safeAreaTop - offsetY;
-    
-    [CCMenuAccount setTitleFont:[UIFont systemFontOfSize:12.0]];
-    [CCMenuAccount showMenuInView:self.navigationController.view fromRect:rect menuItems:menuArray withOptions:options];    
-}
-
-- (void)changeDefaultAccount:(CCMenuItem *)sender
-{
-    // LOGOUT
-    
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:[sender argument]];
-    if (tableAccount) {
-            
-        // LOGIN
-        [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
-    
-        // go to home sweet home
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
-    }
-}
-
-- (void)addNewAccount:(CCMenuItem *)sender
-{
-    [appDelegate openLoginView:self selector:k_intro_login openLoginWeb:false];
-}
-
-- (void)toggleReMainMenu
+- (void)toggleSortMenu
 {
     [self toggleMenuWithViewController:self.navigationController];
 }
 
-- (void)toggleReSelectMenu
+- (void)toggleSelectMenu
 {
     [self toggleSelectMenuWithViewController:self.navigationController];
 }
@@ -2309,7 +2223,7 @@
     UIVisualEffect *blurEffect;
     blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
     visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
-    visualEffectView.backgroundColor = [NCBrandColor.sharedInstance.brand colorWithAlphaComponent:0.2];
+    visualEffectView.backgroundColor = [NCBrandColor.sharedInstance.brandElement colorWithAlphaComponent:0.2];
     
     if ([[CCUtility getGroupBySettings] isEqualToString:@"alphabetic"]) {
         

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -380,7 +380,7 @@ import NCCommunication
     
     func getTemplate() {
      
-        indicator.color = NCBrandColor.sharedInstance.brand
+        indicator.color = NCBrandColor.sharedInstance.brandElement
         indicator.startAnimating()
         
         if self.editorId == k_editor_text || self.editorId == k_editor_onlyoffice {

+ 2 - 6
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -139,7 +139,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         row.title = NSLocalizedString("_quality_medium_", comment: "")
         row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
 
-        row.cellConfig["slider.minimumTrackTintColor"] = NCBrandColor.sharedInstance.brand
+        row.cellConfig["slider.minimumTrackTintColor"] = NCBrandColor.sharedInstance.brandElement
         
         row.cellConfig["slider.maximumValue"] = 1
         row.cellConfig["slider.minimumValue"] = 0
@@ -201,7 +201,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         row.value = "PDF"
         row.cellConfig["backgroundColor"] = NCBrandColor.sharedInstance.backgroundForm
 
-        row.cellConfig["tintColor"] = NCBrandColor.sharedInstance.brand
+        row.cellConfig["tintColor"] = NCBrandColor.sharedInstance.brandElement
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
         row.cellConfig["textLabel.textColor"] = NCBrandColor.sharedInstance.textView
         
@@ -660,10 +660,6 @@ class NCCreateScanDocument : NSObject, ImageScannerControllerDelegate {
         
         let scannerVC = ImageScannerController()
         scannerVC.imageScannerDelegate = self
-        scannerVC.navigationBar.isTranslucent = false
-        scannerVC.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
-        scannerVC.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
-        scannerVC.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
         
         self.viewController?.present(scannerVC, animated: true, completion: nil)
     }

+ 1 - 3
iOSClient/Main/Menu/AppDelegate+Menu.swift

@@ -102,7 +102,6 @@ extension AppDelegate {
             )
         } 
         
-        #if !targetEnvironment(simulator)
         actions.append(
             NCMenuAction(
                 title: NSLocalizedString("_scans_document_", comment: ""),
@@ -112,7 +111,6 @@ extension AppDelegate {
                 }
             )
         )
-        #endif
 
         actions.append(
             NCMenuAction(
@@ -126,7 +124,7 @@ extension AppDelegate {
 
         actions.append(
             NCMenuAction(title: NSLocalizedString("_create_folder_", comment: ""),
-                icon: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brand),
+                icon: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement),
                 action: { menuAction in
                     appDelegate.activeMain.createFolder()
                 }

+ 8 - 8
iOSClient/Main/Menu/CCMain+Menu.swift

@@ -75,7 +75,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("fileName")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":self.serverUrl ?? ""])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.serverUrl ?? ""])
                 }
             )
         )
@@ -95,7 +95,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("date")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":self.serverUrl ?? ""])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.serverUrl ?? ""])
                 }
             )
         )
@@ -115,7 +115,7 @@ extension CCMain {
                         CCUtility.setOrderSettings("size")
                     }
                     self.SetSortButtonText()
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":self.serverUrl ?? ""])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.serverUrl ?? ""])
                 }
             )
         )
@@ -128,7 +128,7 @@ extension CCMain {
                 on: CCUtility.getDirectoryOnTop(),
                 action: { menuAction in
                     CCUtility.setDirectoryOnTop(!CCUtility.getDirectoryOnTop())
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":self.serverUrl ?? ""])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.serverUrl ?? ""])
                 }
             )
         )
@@ -325,7 +325,7 @@ extension CCMain {
                             if(isOffline) {
                                 CCSynchronize.shared()?.readFolder(serverUrl, selector: selectorReadFolderWithDownload, account: appDelegate.activeAccount)
                             }
-                            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                         }
                     )
                 )
@@ -344,7 +344,7 @@ extension CCMain {
                                     NCManageDatabase.sharedInstance.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: true, richWorkspace: nil, account: metadata.account)
                                     NCManageDatabase.sharedInstance.setMetadataEncrypted(ocId: metadata.ocId, encrypted: true)
                                     
-                                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                                 } else {
                                     NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_mark_folder_", comment: ""), description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: .error, errorCode: errorCode)
                                 }
@@ -367,7 +367,7 @@ extension CCMain {
                                     NCManageDatabase.sharedInstance.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: false, richWorkspace: nil, account: metadata.account)
                                     NCManageDatabase.sharedInstance.setMetadataEncrypted(ocId: metadata.ocId, encrypted: false)
                                     
-                                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                                 } else {
                                     NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_delete_mark_folder_", comment: ""), description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: .error, errorCode: errorCode)
                                 }
@@ -494,7 +494,7 @@ extension CCMain {
                                 
                             } else {
                                 NCManageDatabase.sharedInstance.setLocalFile(ocId: metadata.ocId, offline: !localFile!.offline)
-                                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                             }
                         }
                     )

+ 4 - 4
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -179,7 +179,7 @@ extension NCDetailNavigationController {
                 NCMenuAction(title: NSLocalizedString("_search_", comment: ""),
                     icon: CCGraphics.changeThemingColorImage(UIImage(named: "search"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                     action: { menuAction in
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue:k_notificationCenter_menuSearchTextPDF), object: nil)
+                        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_menuSearchTextPDF)
                     }
                 )
             )
@@ -193,7 +193,7 @@ extension NCDetailNavigationController {
                     NCMenuAction(title: NSLocalizedString("_download_image_max_", comment: ""),
                         icon: CCGraphics.changeThemingColorImage(UIImage(named: "downloadImageFullRes"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                         action: { menuAction in
-                            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDownloadImage), object: nil, userInfo: ["metadata": metadata])
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_menuDownloadImage, userInfo: ["metadata": metadata])
                         }
                     )
                 )
@@ -207,7 +207,7 @@ extension NCDetailNavigationController {
                         NCMenuAction(title: NSLocalizedString("_livephoto_save_", comment: ""),
                             icon: CCGraphics.changeThemingColorImage(UIImage(named: "livePhoto"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                             action: { menuAction in
-                                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuSaveLivePhoto), object: nil, userInfo: ["metadata": metadata, "metadataMov": metadataLive])
+                                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_menuSaveLivePhoto, userInfo: ["metadata": metadata, "metadataMov": metadataLive])
                             }
                         )
                     )
@@ -221,7 +221,7 @@ extension NCDetailNavigationController {
             NCMenuAction(title: NSLocalizedString("_close_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "exit"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                 action: { menuAction in
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDetailClose), object: nil)
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_menuDetailClose)
                 }
             )
         )

+ 7 - 9
iOSClient/Main/NCDetailViewController.swift

@@ -118,13 +118,7 @@ class NCDetailViewController: UIViewController {
                         
         appDelegate.progressViewDetail.frame = CGRect(x: 0, y: navigationController.navigationBar.frame.height - 2, width: navigationController.navigationBar.frame.width, height: 2)
         progress(0)
-        
-        if NCBrandColor.sharedInstance.brand.isLight() {
-            appDelegate.progressViewDetail.tintColor = NCBrandColor.sharedInstance.brand.darker(by: 10)
-        } else {
-            appDelegate.progressViewDetail.tintColor = NCBrandColor.sharedInstance.brand.lighter(by: 20)
-        }
-        
+        appDelegate.progressViewDetail.tintColor = NCBrandColor.sharedInstance.brandElement
         appDelegate.progressViewDetail.trackTintColor = .clear
         appDelegate.progressViewDetail.transform = CGAffineTransform(scaleX: 1, y: 1)
         
@@ -172,7 +166,7 @@ class NCDetailViewController: UIViewController {
         appDelegate.changeTheming(self, tableView: nil, collectionView: nil, form: false)
         
         if backgroundView.image != nil {
-            backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
+            backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brandElement.withAlphaComponent(0.4))
         }
         
         if navigationController?.isNavigationBarHidden == false {
@@ -428,7 +422,7 @@ class NCDetailViewController: UIViewController {
         self.navigationController?.isNavigationBarHidden = false
         view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
         
-        backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
+        backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brandElement.withAlphaComponent(0.4))
     }
     
     private func closeAllSubView() {
@@ -795,6 +789,7 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
     
     func viewerImageViewControllerLongPressBegan(_ viewerImageViewController: NCViewerImageViewController, metadata: tableMetadata) {
         
+        viewerImageViewController.statusView.isHidden = true
         viewerImageViewControllerLongPressInProgress = true
         
         let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
@@ -802,6 +797,7 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
             
             if CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView) > 0 {
                 
+                AudioServicesPlaySystemSound(1519) // peek feedback
                 viewMOV(viewerImageViewController: viewerImageViewController, metadata: metadata)
                 
             } else {
@@ -822,6 +818,7 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
                     if errorCode == 0 && account == metadata.account {
                         
                         NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
+                        AudioServicesPlaySystemSound(1519) // peek feedback
                         self.viewMOV(viewerImageViewController: viewerImageViewController, metadata: metadata)
                     }
                 }
@@ -833,6 +830,7 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
         
         viewerImageViewControllerLongPressInProgress = false
         
+        viewerImageViewController.statusView.isHidden = false
         appDelegate.player?.pause()
         videoLayer?.removeFromSuperlayer()
     }

+ 2 - 2
iOSClient/Main/NCMainCommon.swift

@@ -175,7 +175,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
                         catch { }
                         NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-                            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
                         }
                     }
                 }
@@ -783,7 +783,7 @@ class NCMainCommon: NSObject, NCAudioRecorderViewControllerDelegate, UIDocumentI
         
         if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata": metadata, "selector": selector, "errorCode": 0, "errorDescription": "" ])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadedFile, userInfo: ["metadata": metadata, "selector": selector, "errorCode": 0, "errorDescription": "" ])
                                     
         } else {
             

+ 1 - 1
iOSClient/Main/NCMasterNavigationController.swift

@@ -55,7 +55,7 @@ class NCMasterNavigationController: UINavigationController {
 
     @objc func changeTheming() {
         navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
-        navigationBar.tintColor = NCBrandColor.sharedInstance.brand
+        navigationBar.tintColor = NCBrandColor.sharedInstance.brandElement
     }
 }
 

+ 3 - 9
iOSClient/Main/NCPhotosPickerViewController.swift

@@ -49,7 +49,7 @@ class NCPhotosPickerViewController: NSObject {
         configure.tapHereToChange = NSLocalizedString("_tap_here_to_change_", comment: "")
         
         configure.maxSelectedAssets = self.maxSelectedAssets
-        configure.selectedColor = NCBrandColor.sharedInstance.brand
+        configure.selectedColor = NCBrandColor.sharedInstance.brandElement
         configure.singleSelectedMode = singleSelectedMode
         
         let viewController = customPhotoPickerViewController(withTLPHAssets: { (assets) in
@@ -100,13 +100,7 @@ class customPhotoPickerViewController: TLPhotosPickerViewController {
     override func makeUI() {
         super.makeUI()
         
-        self.customNavItem.leftBarButtonItem?.tintColor = NCBrandColor.sharedInstance.brand
-        self.customNavItem.rightBarButtonItem?.tintColor = NCBrandColor.sharedInstance.brand
-      
-        /*
-        self.titleLabel.textColor = NCBrandColor.sharedInstance.brand
-        self.subTitleLabel.textColor = NCBrandColor.sharedInstance.brand
-        self.subTitleArrowImageView.image = CCGraphics.changeThemingColorImage(self.subTitleArrowImageView.image, width: 100, height: 100, color: NCBrandColor.sharedInstance.brand)
-        */
+        self.customNavItem.leftBarButtonItem?.tintColor = NCBrandColor.sharedInstance.brandElement
+        self.customNavItem.rightBarButtonItem?.tintColor = NCBrandColor.sharedInstance.brandElement
     }
 }

+ 2 - 2
iOSClient/Main/NCSplitViewController.swift

@@ -63,7 +63,7 @@ class NCSplitViewController: UISplitViewController {
     }
     
     @objc func timerHandlerChangeTheming(_ timer: Timer) {
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_changeTheming), object: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_changeTheming)
     }
 }
 
@@ -74,6 +74,6 @@ extension NCSplitViewController: UISplitViewControllerDelegate {
     }
     
     func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) {
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_splitViewChangeDisplayMode), object: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_splitViewChangeDisplayMode)
     }
 }

+ 156 - 109
iOSClient/Media/NCMedia.swift

@@ -35,6 +35,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     
     public var metadatas: [tableMetadata] = []
     private var metadataPush: tableMetadata?
+    private var predicate: NSPredicate?
     
     private var isEditMode = false
     private var selectocId: [String] = []
@@ -63,6 +64,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         appDelegate.activeMedia = self
         
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(applicationWillEnterForeground), name: NSNotification.Name(rawValue: k_notificationCenter_applicationWillEnterForeground), object: nil)
     }
     
     override func viewDidLoad() {
@@ -71,7 +73,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         collectionView.register(UINib.init(nibName: "NCGridMediaCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
         
         collectionView.alwaysBounceVertical = true
-        collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0);
+        collectionView.contentInset = UIEdgeInsets(top: 75, left: 0, bottom: 50, right: 0);
                 
         gridLayout = NCGridMediaLayout()
         gridLayout.itemPerLine = CGFloat(min(CCUtility.getMediaWidthImage(), 5))
@@ -105,9 +107,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         mediaCommandView?.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
         mediaCommandView?.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
         mediaCommandView?.heightAnchor.constraint(equalToConstant: 150).isActive = true
-        if self.metadatas.count == 0 {
-            self.mediaCommandView?.isHidden = true
-        }
+        self.updateMediaControlVisibility()
         
         changeTheming()
     }
@@ -119,9 +119,9 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
         
-        mediaCommandTitle()
-        readFiles()
-        searchNewPhotoVideo()
+        reloadDataSourceWithCompletion {
+            self.searchNewPhotoVideo()
+        }
     }
     
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@@ -136,6 +136,14 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         return .lightContent
     }
     
+    //MARK: - Notification
+    
+    @objc func applicationWillEnterForeground() {
+        if self.view.window != nil {
+            self.viewDidAppear(false)
+        }
+    }
+    
     //MARK: - Command
     
     func mediaCommandTitle() {
@@ -186,15 +194,17 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         var actions: [NCMenuAction] = []
 
         if !isEditMode {
-            actions.append(
-                NCMenuAction(
-                    title: NSLocalizedString("_select_", comment: ""),
-                    icon: CCGraphics.changeThemingColorImage(UIImage(named: "selectFull"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
-                    action: { menuAction in
-                        self.isEditMode = true
-                    }
+            if metadatas.count > 0 {
+                actions.append(
+                    NCMenuAction(
+                        title: NSLocalizedString("_select_", comment: ""),
+                        icon: CCGraphics.changeThemingColorImage(UIImage(named: "selectFull"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                        action: { menuAction in
+                            self.isEditMode = true
+                        }
+                    )
                 )
-            )
+            }
 
             actions.append(
                 NCMenuAction(
@@ -274,21 +284,23 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     @objc func deleteFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
-                
-                let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
-                self.metadatas = metadatas
+                if metadata.account == appDelegate.activeAccount {
                     
-                if self.metadatas.count  > 0 {
-                    self.mediaCommandView?.isHidden = false
-                } else {
-                    self.mediaCommandView?.isHidden = true
-                }
-                
-                self.reloadDataSource()
+                    let indexes = self.metadatas.indices.filter { self.metadatas[$0].ocId == metadata.ocId }
+                    let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
+                    self.metadatas = metadatas
+                    
+                    if let row = indexes.first {
+                        let indexPath = IndexPath(row: row, section: 0)
+                        collectionView?.deleteItems(at: [indexPath])
+                    }
                     
-                if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
-                    let userInfo: [String : Any] = ["metadata": metadata, "type": "delete"]
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_synchronizationMedia), object: nil, userInfo: userInfo)
+                    self.updateMediaControlVisibility()
+                        
+                    if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
+                        let userInfo: [String : Any] = ["metadata": metadata, "type": "delete"]
+                        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
+                    }
                 }
             }
         }
@@ -297,12 +309,14 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     @objc func moveFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let metadataNew = userInfo["metadataNew"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
-                
-                self.reloadDataSource()
+                if metadata.account == appDelegate.activeAccount {
+                    self.reloadDataSourceWithCompletion() {
 
-                if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
-                    let userInfo: [String : Any] = ["metadata": metadata, "metadataNew": metadataNew, "type": "move"]
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_synchronizationMedia), object: nil, userInfo: userInfo)
+                        if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
+                            let userInfo: [String : Any] = ["metadata": metadata, "metadataNew": metadataNew, "type": "move"]
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
+                        }
+                    }
                 }
             }
         }
@@ -311,12 +325,14 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     @objc func renameFile(_ notification: NSNotification) {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let metadata = userInfo["metadata"] as? tableMetadata, let errorCode = userInfo["errorCode"] as? Int {
-                
-                self.reloadDataSource()
+                if metadata.account == appDelegate.activeAccount {
+                    self.reloadDataSourceWithCompletion() {
 
-                if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
-                    let userInfo: [String : Any] = ["metadata": metadata, "type": "rename"]
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_synchronizationMedia), object: nil, userInfo: userInfo)
+                        if errorCode == 0 && (metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio) {
+                            let userInfo: [String : Any] = ["metadata": metadata, "type": "rename"]
+                            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_synchronizationMedia, userInfo: userInfo)
+                        }
+                    }
                 }
             }
         }
@@ -392,7 +408,6 @@ extension NCMedia: UIViewControllerPreviewingDelegate {
     func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
         
         guard let indexPath = collectionView?.indexPathForItem(at: previewingContext.sourceRect.origin) else { return }
-        
         collectionView(collectionView, didSelectItemAt: indexPath)
     }
 }
@@ -438,16 +453,18 @@ extension NCMedia: UICollectionViewDataSource {
     }
 
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        if indexPath.row < metadatas.count {
-            let metadata = metadatas[indexPath.row]
+        if indexPath.row < self.metadatas.count {
+            let metadata = self.metadatas[indexPath.row]
             NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
+            NCOperationQueue.shared.readFileForMedia(metadata: metadata)
         }
     }
     
     func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        if indexPath.row < metadatas.count {
+        if !collectionView.indexPathsForVisibleItems.contains(indexPath) && indexPath.row < metadatas.count {
             let metadata = metadatas[indexPath.row]
             NCOperationQueue.shared.cancelDownloadThumbnail(metadata: metadata)
+            NCOperationQueue.shared.cancelReadFileForMedia(metadata: metadata)
         }
     }
 
@@ -523,75 +540,46 @@ extension NCMedia: UICollectionViewDelegateFlowLayout {
 extension NCMedia {
 
     @objc func reloadDataSource() {
+        self.reloadDataSourceWithCompletion { }
+    }
+    
+    private func reloadDataSourceWithCompletion(_ completion: @escaping () -> Void) {
         
-        if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
-            return
-        }
-        
-        var predicate: NSPredicate?
-        
+        if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) { return }
+                
         if filterTypeFileImage {
-            predicate = NSPredicate(format: "account == %@ AND typeFile == %@", appDelegate.activeAccount, k_metadataTypeFile_video)
+            predicate = NSPredicate(format: "account == %@ AND typeFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.activeAccount, k_metadataTypeFile_video)
         } else if filterTypeFileVideo {
-            predicate = NSPredicate(format: "account == %@ AND typeFile == %@", appDelegate.activeAccount, k_metadataTypeFile_image)
+            predicate = NSPredicate(format: "account == %@ AND typeFile == %@ AND NOT (session CONTAINS[c] 'upload')", appDelegate.activeAccount, k_metadataTypeFile_image)
         } else {
-            predicate = NSPredicate(format: "account == %@ AND (typeFile == %@ OR typeFile == %@)", appDelegate.activeAccount, k_metadataTypeFile_image, k_metadataTypeFile_video)
+            predicate = NSPredicate(format: "account == %@ AND (typeFile == %@ OR typeFile == %@) AND NOT (session CONTAINS[c] 'upload')", appDelegate.activeAccount, k_metadataTypeFile_image, k_metadataTypeFile_video)
         }
                 
         NCManageDatabase.sharedInstance.getMetadatasMedia(predicate: predicate!) { (metadatas) in
             DispatchQueue.main.sync {
                 self.metadatas = metadatas
                 
-                if self.metadatas.count  > 0 {
-                    self.mediaCommandView?.isHidden = false
-                } else {
-                    self.mediaCommandView?.isHidden = true
-                }
+                self.updateMediaControlVisibility()
+                
                 self.reloadDataThenPerform {
                     self.mediaCommandTitle()
+                    completion()
                 }
             }
         }
     }
     
-    @objc func searchNewPhotoVideo() {
-        
-        if newInProgress { return }
-        else { newInProgress = true }
-        collectionView.reloadData()
-        
-        let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
-        
-        //let elementDate = "nc:upload_time/"
-        //let lteDate: Int = Int(Date().timeIntervalSince1970)
-        //let gteDate: Int = Int(fromDate!.timeIntervalSince1970)
-        
-        guard let lessDate = Calendar.current.date(byAdding: .second, value: 1, to: Date()) else { return }
-        guard var greaterDate = Calendar.current.date(byAdding: .day, value: -30, to: Date()) else { return }
-        
-        if let date = tableAccount?.dateUpdateNewMedia {
-            greaterDate = date as Date
-        }
-                
-        NCCommunication.shared.searchMedia(lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
-            
-            self.newInProgress = false
-            self.collectionView.reloadData()
-
-            if errorCode == 0 && files?.count ?? 0 > 0 {
-                
-                NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
-                if tableAccount?.dateLessMedia == nil {
-                    NCManageDatabase.sharedInstance.setAccountDateLessMedia(date: files?.last?.date)
-                }
-                NCManageDatabase.sharedInstance.setAccountDateUpdateNewMedia()
-                
-                self.reloadDataSource()
-            }
-            
-            if errorCode == 0 && files?.count ?? 0 == 0 && self.metadatas.count == 0 {
-                self.searchOldPhotoVideo()
+    func updateMediaControlVisibility() {
+        if self.metadatas.count == 0 {
+            if !self.filterTypeFileImage && !self.filterTypeFileVideo {
+                self.mediaCommandView?.isHidden = true
+            } else {
+                self.mediaCommandView?.toggleEmptyView(isEmpty: true)
+                self.mediaCommandView?.isHidden = false
             }
+        } else {
+            self.mediaCommandView?.toggleEmptyView(isEmpty: false)
+            self.mediaCommandView?.isHidden = false
         }
     }
     
@@ -602,12 +590,12 @@ extension NCMedia {
         collectionView.reloadData()
 
         var lessDate = Date()
-        let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
-        if let date = tableAccount?.dateLessMedia {
-            lessDate = date as Date
-        }
         var greaterDate: Date
         
+        if metadatas.count > 0 {
+            lessDate = metadatas.last!.date as Date
+        }
+        
         if value == -999 {
             greaterDate = Date.distantPast
         } else {
@@ -623,11 +611,10 @@ extension NCMedia {
             NCUtility.sharedInstance.stopActivityIndicator()
             self.collectionView.reloadData()
 
-            if errorCode == 0 {
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
                 if files?.count ?? 0 > 0 {
                     
                     NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
-                    NCManageDatabase.sharedInstance.setAccountDateLessMedia(date: files?.last?.date)
                     self.reloadDataSource()
                     
                 } else {
@@ -644,22 +631,66 @@ extension NCMedia {
         }
     }
     
-    private func downloadThumbnail() {
-        guard let collectionView = self.collectionView else { return }
-        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-            for indexPath in collectionView.indexPathsForVisibleItems {
-                let metadata = self.metadatas[indexPath.row]
-                NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
+    @objc func searchNewPhotoVideo() {
+        
+        guard var lessDate = Calendar.current.date(byAdding: .second, value: 1, to: Date()) else { return }
+        guard var greaterDate = Calendar.current.date(byAdding: .day, value: -30, to: Date()) else { return }
+        
+        if let visibleCells = self.collectionView?.indexPathsForVisibleItems.sorted(by: { $0.row < $1.row }).compactMap({ self.collectionView?.cellForItem(at: $0) }) {
+            if let cell = visibleCells.first as? NCGridMediaCell {
+                if cell.date != nil {
+                    if cell.date != metadatas.first?.date as Date? {
+                        lessDate = Calendar.current.date(byAdding: .second, value: 1, to: cell.date!)!
+                    }
+                }
+            }
+            if let cell = visibleCells.last as? NCGridMediaCell {
+                if cell.date != nil {
+                    greaterDate = Calendar.current.date(byAdding: .second, value: -1, to: cell.date!)!
+                }
+            }
+        }
+        
+        newInProgress = true
+        collectionView.reloadData()
+        
+        NCCommunication.shared.searchMedia(lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
+            
+            self.newInProgress = false
+            
+            if errorCode == 0 && account == self.appDelegate.activeAccount && files?.count ?? 0 > 0 {
+               DispatchQueue.global().async {
+                
+                    let predicate = NSPredicate(format: "date > %@ AND date < %@", greaterDate as NSDate, lessDate as NSDate)
+                    let newPredicate = NSCompoundPredicate.init(andPredicateWithSubpredicates:[predicate, self.predicate!])
+                
+                    if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: newPredicate, sorted: nil, ascending: false){
+                        let etagsMetadatas = Array(metadatas.map { $0.etag })
+                        let etagsFiles = Array(files!.map { $0.etag })
+                        for etag in etagsFiles {
+                            if !etagsMetadatas.contains(etag) {
+                                NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
+                                self.reloadDataSource()
+                                break;
+                            }
+                        }
+                    } else {
+                        NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
+                        self.reloadDataSource()
+                    }
+                }
+            } else if errorCode == 0 && files?.count ?? 0 == 0 && self.metadatas.count == 0 {
+                self.searchOldPhotoVideo()
             }
         }
     }
     
-    private func readFiles() {
+    private func downloadThumbnail() {
         guard let collectionView = self.collectionView else { return }
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
             for indexPath in collectionView.indexPathsForVisibleItems {
                 let metadata = self.metadatas[indexPath.row]
-                NCOperationQueue.shared.readFileForMedia(metadata: metadata)
+                NCOperationQueue.shared.downloadThumbnail(metadata: metadata, activeUrl: self.appDelegate.activeUrl, view: self.collectionView as Any, indexPath: indexPath)
             }
         }
     }
@@ -685,7 +716,7 @@ extension NCMedia: UIScrollViewDelegate {
     func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
         
         if !decelerate {
-            self.readFiles()
+            self.searchNewPhotoVideo()
             
             if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)) {
                 searchOldPhotoVideo()
@@ -694,7 +725,7 @@ extension NCMedia: UIScrollViewDelegate {
     }
     
     func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
-        self.readFiles()
+        self.searchNewPhotoVideo()
         
         if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)) {
             searchOldPhotoVideo()
@@ -732,6 +763,22 @@ class NCMediaCommandView: UIView {
         title.text = ""
     }
     
+    func toggleEmptyView(isEmpty: Bool) {
+        if isEmpty {
+            UIView.animate(withDuration: 0.3) {
+                self.moreView.effect = UIBlurEffect(style: .dark)
+                self.gradient.isHidden = true
+                self.controlButtonView.isHidden = true
+            }
+        } else {
+            UIView.animate(withDuration: 0.3) {
+                self.moreView.effect = UIBlurEffect(style: .regular)
+                self.gradient.isHidden = false
+                self.controlButtonView.isHidden = false
+            }
+        }
+    }
+    
     @IBAction func moreButtonPressed(_ sender: UIButton) {
         mediaView?.openMenuButtonMore(sender)
     }

+ 5 - 5
iOSClient/Media/NCMediaCommandView.xib

@@ -15,7 +15,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="i1s-Qa-dG1">
-                    <rect key="frame" x="272" y="8" width="40" height="40"/>
+                    <rect key="frame" x="224" y="8" width="40" height="40"/>
                     <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="e3Q-e0-SQa">
                         <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -106,7 +106,7 @@
                     <nil key="highlightedColor"/>
                 </label>
                 <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="enp-xt-Y5y">
-                    <rect key="frame" x="224" y="8" width="40" height="40"/>
+                    <rect key="frame" x="272" y="8" width="40" height="40"/>
                     <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="KKR-Hr-av8">
                         <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -137,12 +137,12 @@
             </subviews>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
-                <constraint firstItem="i1s-Qa-dG1" firstAttribute="leading" secondItem="enp-xt-Y5y" secondAttribute="trailing" constant="8" id="MZA-3x-aIl"/>
-                <constraint firstItem="enp-xt-Y5y" firstAttribute="leading" secondItem="IxY-xH-yZQ" secondAttribute="trailing" constant="8" id="TQe-hh-Fom"/>
+                <constraint firstItem="i1s-Qa-dG1" firstAttribute="leading" secondItem="IxY-xH-yZQ" secondAttribute="trailing" constant="8" id="Owq-aa-Sr6"/>
+                <constraint firstItem="enp-xt-Y5y" firstAttribute="leading" secondItem="i1s-Qa-dG1" secondAttribute="trailing" constant="8" id="XcU-G8-k0a"/>
                 <constraint firstItem="IxY-xH-yZQ" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="8" id="ZhO-pY-Qwi"/>
                 <constraint firstItem="i1s-Qa-dG1" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="cWc-xe-8un"/>
                 <constraint firstItem="IxY-xH-yZQ" firstAttribute="centerY" secondItem="i1s-Qa-dG1" secondAttribute="centerY" id="mJJ-pT-yA3"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="i1s-Qa-dG1" secondAttribute="trailing" constant="8" id="wDQ-gZ-xCh"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="enp-xt-Y5y" secondAttribute="trailing" constant="8" id="rSU-Dz-YXW"/>
                 <constraint firstItem="enp-xt-Y5y" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="z6I-sd-mmD"/>
             </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>

+ 0 - 83
iOSClient/MenuAccount/CCMenuAccount.h

@@ -1,83 +0,0 @@
-//
-//  CCMenuAccount.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 07/04/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface CCMenuItem : NSObject
-
-@property (readwrite, nonatomic, strong) UIImage *image;
-@property (readwrite, nonatomic, strong) NSString *title;
-@property (readwrite, nonatomic, strong) NSString *argument;
-@property (readwrite, nonatomic, weak) id target;
-@property (readwrite, nonatomic) SEL action;
-@property (readwrite, nonatomic, strong) UIColor *foreColor;
-@property (readwrite, nonatomic) NSTextAlignment alignment;
-
-+ (instancetype)menuItem:(NSString *)title argument:(NSString*)argument image:(UIImage *)image target:(id)target action:(SEL)action;
-
-@end
-
-typedef struct {
-    
-    CGFloat R;
-    CGFloat G;
-    CGFloat B;
-
-} Color;
-
-typedef struct {
-    
-    CGFloat arrowSize;
-    CGFloat marginXSpacing;
-    CGFloat marginYSpacing;
-    CGFloat intervalSpacing;
-    CGFloat menuCornerRadius;
-    Boolean maskToBackground;
-    Boolean shadowOfMenu;
-    Boolean hasSeperatorLine;
-    Boolean seperatorLineHasInsets;
-    UIColor *textColor;
-    UIColor *separatorColor;
-    Color menuBackgroundColor;
-    
-} OptionalConfiguration;
-
-@interface CCMenuView : UIView
-
-@property (atomic, assign) OptionalConfiguration CCMenuViewOptions;
-
-@end
-
-@interface CCMenuAccount : NSObject
-
-+ (void)showMenuInView:(UIView *)view fromRect:(CGRect)rect menuItems:(NSArray *)menuItems withOptions:(OptionalConfiguration)options;
-
-+ (void)dismissMenu;
-
-+ (UIColor *)tintColor;
-+ (void)setTintColor:(UIColor *)tintColor;
-
-+ (UIFont *)titleFont;
-+ (void)setTitleFont:(UIFont *)titleFont;
-
-@end

+ 0 - 794
iOSClient/MenuAccount/CCMenuAccount.m

@@ -1,794 +0,0 @@
-//
-//  CCMenuAccount.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 07/04/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <Foundation/Foundation.h>
-#import <QuartzCore/QuartzCore.h>
-
-#import "CCMenuAccount.h"
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-@interface CCMenuOverlay : UIView
-@end
-
-@implementation CCMenuOverlay
-
-- (id)initWithFrame:(CGRect)frame maskSetting:(Boolean)mask
-{
-    self = [super initWithFrame:frame];
-    
-    if (self) {
-        
-        if (mask) {
-            self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.17];
-        } else {
-            self.backgroundColor = [UIColor clearColor];
-        }
-        
-        UITapGestureRecognizer *gestureRecognizer;
-        gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
-                                                                    action:@selector(singleTap:)];
-        
-        [self addGestureRecognizer:gestureRecognizer];
-    }
-    return self;
-}
-
-// thank horaceho https://github.com/horaceho
-// for his solution described in https://github.com/kolyvan/kxmenu/issues/9
-
-- (void)singleTap:(UITapGestureRecognizer *)recognizer
-{
-    for (UIView *v in self.subviews) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wundeclared-selector"
-        if ([v isKindOfClass:[CCMenuView class]] && [v respondsToSelector:@selector(dismissMenu:)]) {
-            [v performSelector:@selector(dismissMenu:) withObject:@(YES)];
-        }
-#pragma clang diagnostic pop
-    }
-}
-
-@end
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-@implementation CCMenuItem
-
-+ (instancetype) menuItem:(NSString *)title argument:(NSString*)argument image:(UIImage *)image target:(id)target action:(SEL)action
-{
-    return [[CCMenuItem alloc] init:title argument:argument image:image target:target action:action];
-}
-
-- (id)init:(NSString *)title argument:(NSString*)argument image:(UIImage *)image target:(id)target action:(SEL)action
-{
-    NSParameterAssert(title.length || image);
-    
-    self = [super init];
-    if (self) {
-        
-        _title = title;
-        _argument = argument;
-        _image = image;
-        _target = target;
-        _action = action;
-    }
-    return self;
-}
-
-- (BOOL)enabled
-{
-    return _target != nil && _action != NULL;
-}
-
-- (void)performAction
-{
-    __strong id target = self.target;
-    
-    if (target && [target respondsToSelector:_action]) {
-        
-        [target performSelectorOnMainThread:_action withObject:self waitUntilDone:YES];
-    }
-}
-
-- (NSString *)description
-{
-    return [NSString stringWithFormat:@"<%@ #%p %@>", [self class], self, _title];
-}
-
-@end
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-typedef enum {
-    
-    CCMenuViewArrowDirectionNone,
-    CCMenuViewArrowDirectionUp,
-    CCMenuViewArrowDirectionDown,
-    CCMenuViewArrowDirectionLeft,
-    CCMenuViewArrowDirectionRight,
-    
-} CCMenuViewArrowDirection;
-
-@implementation CCMenuView {
-    
-    CCMenuViewArrowDirection    _arrowDirection;
-    CGFloat                     _arrowPosition;
-    UIView                      *_contentView;
-    NSArray                     *_menuItems;
-}
-
-- (id)init
-{
-    self = [super initWithFrame:CGRectZero];
-    if(self) {
-        
-        self.backgroundColor = [UIColor clearColor];
-        
-        self.opaque = YES;
-        self.alpha = 0;
-    }
-    
-    return self;
-}
-
-- (void)setupFrameInView:(UIView *)view fromRect:(CGRect)fromRect
-{
-    const CGSize contentSize = _contentView.frame.size;
-    const CGFloat outerWidth = view.bounds.size.width;
-    const CGFloat rectXM = fromRect.origin.x + fromRect.size.width * 0.5f;
-    const CGFloat widthHalf = contentSize.width * 0.5f;
-    const CGFloat kMargin = 5.f;
-    const CGFloat rectY = fromRect.origin.y;
-    
-    if (self.CCMenuViewOptions.shadowOfMenu) {
-        self.layer.shadowOpacity = 0.5;
-        self.layer.shadowOffset = CGSizeMake(2, 2);
-        self.layer.shadowRadius = 2;
-        
-        self.layer.shadowColor = [[UIColor blackColor] CGColor];
-    }
-    
-    _arrowDirection = CCMenuViewArrowDirectionUp;
-    
-    CGPoint point = (CGPoint){
-        rectXM - widthHalf,
-        rectY - 4
-    };
-    
-    if (point.x < kMargin)
-        point.x = kMargin;
-    
-    if ((point.x + contentSize.width + kMargin) > outerWidth)
-        point.x = outerWidth - contentSize.width - kMargin;
-    
-    _arrowPosition = rectXM - point.x;
-    _contentView.frame = (CGRect){CGPointZero, contentSize};
-    
-    self.frame = (CGRect) {
-        
-        point,
-        contentSize.width,
-        contentSize.height - self.CCMenuViewOptions.arrowSize
-    };
-}
-
-- (void)showMenuInView:(UIView *)view fromRect:(CGRect)rect menuItems:(NSArray *)menuItems withOptions:(OptionalConfiguration)options
-{
-    
-    self.CCMenuViewOptions = options;
-    
-    _menuItems = menuItems;
-    
-    _contentView = [self mkContentView];
-    [self addSubview:_contentView];
-    
-    [self setupFrameInView:view fromRect:rect];
-    
-    CCMenuOverlay *overlay = [[CCMenuOverlay alloc] initWithFrame:view.bounds maskSetting:self.CCMenuViewOptions.maskToBackground];
-
-    [overlay addSubview:self];
-    [view addSubview:overlay];
-    
-    _contentView.hidden = YES;
-    const CGRect toFrame = self.frame;
-    self.frame = (CGRect){self.arrowPoint, 1, 1};
-    
-    [UIView animateWithDuration:0.2
-                     animations:^(void) {
-                         
-                         self.alpha = 1.0f;
-                         self.frame = toFrame;
-                         
-                     } completion:^(BOOL completed) {
-                         _contentView.hidden = NO;
-                     }];
-    
-}
-
-- (void)dismissMenu:(BOOL) noAnimated
-{
-    if (self.superview) {
-        
-        if (!noAnimated) {
-            
-            const CGRect toFrame = (CGRect){self.arrowPoint, 1, 1};
-            _contentView.hidden = YES;
-            
-            [UIView animateWithDuration:0.1
-                             animations:^(void) {
-                                 
-                                 self.alpha = 0;
-                                 self.frame = toFrame;
-                                 
-                             } completion:^(BOOL finished) {
-                                 
-                                 if ([self.superview isKindOfClass:[CCMenuOverlay class]])
-                                     [self.superview removeFromSuperview];
-                                 [self removeFromSuperview];
-                             }];
-            
-        } else {
-            
-            if ([self.superview isKindOfClass:[CCMenuOverlay class]])
-                [self.superview removeFromSuperview];
-            [self removeFromSuperview];
-        }
-    }
-}
-
-- (void)performAction:(id)sender
-{
-    [self dismissMenu:YES];
-    
-    UIButton *button = (UIButton *)sender;
-    CCMenuItem *menuItem = _menuItems[button.tag];
-    [menuItem performAction];
-}
-
-- (UIView *)mkContentView
-{
-    for (UIView *v in self.subviews) {
-        [v removeFromSuperview];
-    }
-    
-    if (!_menuItems.count)
-        return nil;
-    
-    const CGFloat kMinMenuItemHeight = 32.f;
-    const CGFloat kMinMenuItemWidth = 32.f;
-    const CGFloat kMarginX = self.CCMenuViewOptions.marginXSpacing;
-    const CGFloat kMarginY = self.CCMenuViewOptions.marginYSpacing;
-    
-    UIFont *titleFont = [CCMenuAccount titleFont];
-    if (!titleFont) titleFont = [UIFont boldSystemFontOfSize:16];
-    
-    CGFloat maxImageWidth = 0;
-    CGFloat maxItemHeight = 0;
-    CGFloat maxItemWidth = 0;
-    
-    for (CCMenuItem *menuItem in _menuItems) {
-        
-        const CGSize imageSize = menuItem.image.size;
-        if (imageSize.width > maxImageWidth)
-            maxImageWidth = imageSize.width;
-    }
-    
-    if (maxImageWidth) {
-        maxImageWidth += kMarginX;
-    }
-    
-    for (CCMenuItem *menuItem in _menuItems) {
-        
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
-        const CGSize titleSize = [menuItem.title sizeWithAttributes:@{NSFontAttributeName: titleFont}];
-#else
-        const CGSize titleSize = [menuItem.title sizeWithFont:titleFont];
-#endif       
-        const CGSize imageSize = menuItem.image.size;
-        
-        const CGFloat itemHeight = MAX(titleSize.height, imageSize.height) + kMarginY * 2;
-        
-        const CGFloat itemWidth = ((!menuItem.enabled && !menuItem.image) ? titleSize.width : maxImageWidth + titleSize.width) + kMarginX * 2 + self.CCMenuViewOptions.intervalSpacing;
-        
-        if (itemHeight > maxItemHeight)
-            maxItemHeight = itemHeight;
-        
-        if (itemWidth > maxItemWidth)
-            maxItemWidth = itemWidth;
-    }
-    
-    maxItemWidth  = MAX(maxItemWidth, kMinMenuItemWidth);
-    maxItemHeight = MAX(maxItemHeight, kMinMenuItemHeight);
-    
-    const CGFloat titleX = maxImageWidth + self.CCMenuViewOptions.intervalSpacing;
-    
-    const CGFloat titleWidth = maxItemWidth - titleX - kMarginX *2;
-    
-    UIImage *selectedImage = [CCMenuView selectedImage:(CGSize){maxItemWidth, maxItemHeight + 2}];
-    int insets = 0;
-    
-    if (self.CCMenuViewOptions.seperatorLineHasInsets) {
-        insets = 4;
-    }
-    
-    UIImage *gradientLine = [CCMenuView gradientLine: (CGSize){maxItemWidth- kMarginX * insets, 0.4} color:self.CCMenuViewOptions.separatorColor];
-    
-    UIView *contentView = [[UIView alloc] initWithFrame:CGRectZero];
-    contentView.autoresizingMask = UIViewAutoresizingNone;
-    
-    contentView.backgroundColor = [UIColor clearColor];
-    
-    contentView.opaque = NO;
-    
-    CGFloat itemY = kMarginY * 2;
-    
-    NSUInteger itemNum = 0;
-    
-    for (CCMenuItem *menuItem in _menuItems) {
-        
-        const CGRect itemFrame = (CGRect){0, itemY-kMarginY * 2 + self.CCMenuViewOptions.menuCornerRadius, maxItemWidth, maxItemHeight};
-        
-        UIView *itemView = [[UIView alloc] initWithFrame:itemFrame];
-        itemView.autoresizingMask = UIViewAutoresizingNone;
-        
-        itemView.opaque = NO;
-        
-        [contentView addSubview:itemView];
-        
-        if (menuItem.enabled) {
-            
-            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
-            button.tag = itemNum;
-            button.frame = itemView.bounds;
-            button.enabled = menuItem.enabled;
-            
-            button.backgroundColor = [UIColor clearColor];
-            
-            button.opaque = NO;
-            button.autoresizingMask = UIViewAutoresizingNone;
-            
-            [button addTarget:self
-                       action:@selector(performAction:)
-             forControlEvents:UIControlEventTouchUpInside];
-            
-            [button setBackgroundImage:selectedImage forState:UIControlStateHighlighted];
-            
-            [itemView addSubview:button];
-        }
-        
-        if (menuItem.title.length) {
-            
-            CGRect titleFrame;
-            
-            if (!menuItem.enabled && !menuItem.image) {
-                
-                titleFrame = (CGRect){
-                    kMarginX * 2,
-                    kMarginY,
-                    maxItemWidth - kMarginX * 4,
-                    maxItemHeight - kMarginY * 2
-                };
-                
-            } else {
-                
-                titleFrame = (CGRect){
-                    titleX,
-                    kMarginY,
-                    titleWidth,
-                    maxItemHeight - kMarginY * 2
-                };
-            }
-            
-            UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleFrame];
-            titleLabel.text = menuItem.title;
-            titleLabel.font = titleFont;
-            titleLabel.textAlignment = menuItem.alignment;
-            
-            titleLabel.textColor = self.CCMenuViewOptions.textColor;
-            
-            titleLabel.backgroundColor = [UIColor clearColor];
-            
-            titleLabel.autoresizingMask = UIViewAutoresizingNone;
-            
-            [itemView addSubview:titleLabel];
-        }
-        
-        if (menuItem.image) {
-            
-            const CGRect imageFrame = {kMarginX * 2, kMarginY, maxImageWidth, maxItemHeight - kMarginY * 2};
-            UIImageView *imageView = [[UIImageView alloc] initWithFrame:imageFrame];
-            imageView.image = menuItem.image;
-            imageView.clipsToBounds = YES;
-            imageView.contentMode = UIViewContentModeCenter;
-            imageView.autoresizingMask = UIViewAutoresizingNone;
-            [itemView addSubview:imageView];
-        }
-        
-        if (itemNum < _menuItems.count - 1) {
-            
-            UIImageView *gradientView = [[UIImageView alloc] initWithImage:gradientLine];
-            
-            if (self.CCMenuViewOptions.seperatorLineHasInsets) {
-                gradientView.frame = (CGRect){kMarginX * 2, maxItemHeight + 1, gradientLine.size};
-            } else {
-                gradientView.frame = (CGRect){0, maxItemHeight + 1 , gradientLine.size};
-            }
-            
-            gradientView.contentMode = UIViewContentModeLeft;
-            
-            if (self.CCMenuViewOptions.hasSeperatorLine) {
-                [itemView addSubview:gradientView];
-                itemY += 2;
-            }
-            
-            itemY += maxItemHeight;
-        }
-        
-        ++itemNum;
-    }
-    
-    itemY += self.CCMenuViewOptions.menuCornerRadius;
-    
-    contentView.frame = (CGRect){0, 0, maxItemWidth, itemY + kMarginY * 2 + 5.5 + self.CCMenuViewOptions.menuCornerRadius};
-    
-    return contentView;
-}
-
-- (CGPoint)arrowPoint
-{
-    CGPoint point;
-    
-    if (_arrowDirection == CCMenuViewArrowDirectionUp) {
-        
-        point = (CGPoint){ CGRectGetMinX(self.frame) + _arrowPosition, CGRectGetMinY(self.frame) };
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionDown) {
-        
-        point = (CGPoint){ CGRectGetMinX(self.frame) + _arrowPosition, CGRectGetMaxY(self.frame) };
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionLeft) {
-        
-        point = (CGPoint){ CGRectGetMinX(self.frame), CGRectGetMinY(self.frame) + _arrowPosition  };
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionRight) {
-        
-        point = (CGPoint){ CGRectGetMaxX(self.frame), CGRectGetMinY(self.frame) + _arrowPosition  };
-        
-    } else {
-        
-        point = self.center;
-    }
-    
-    return point;
-}
-
-+ (UIImage *)selectedImage:(CGSize)size
-{
-
-    const CGFloat locations[] = {0,1};
-
-    const CGFloat components[] = {
-        0.890,0.890,0.890,1,
-        0.890,0.890,0.890,1
-    };
-    
-    return [self gradientImageWithSize:size locations:locations components:components count:2];
-}
-
-+ (UIImage *)gradientLine:(CGSize)size color:(UIColor *)color
-{
-    if (color == nil) color = UIColor.lightGrayColor;
-    const CGFloat locations[5] = {0,0.2,0.5,0.8,1};
-    const CGFloat *componentsColor = CGColorGetComponents(color.CGColor);
-    const CGFloat R = componentsColor[0], G = componentsColor[1], B = componentsColor[2];
-    
-    const CGFloat components[20] = {
-        R,G,B,1,
-        R,G,B,1,
-        R,G,B,1,
-        R,G,B,1,
-        R,G,B,1
-    };
-    
-    return [self gradientImageWithSize:size locations:locations components:components count:5];
-}
-
-+ (UIImage *)gradientImageWithSize:(CGSize)size locations:(const CGFloat [])locations components:(const CGFloat [])components count:(NSUInteger)count
-{
-    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGGradientRef colorGradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, 2);
-    CGColorSpaceRelease(colorSpace);
-    CGContextDrawLinearGradient(context, colorGradient, (CGPoint){0, 0}, (CGPoint){size.width, 0}, 0);
-    CGGradientRelease(colorGradient);
-    
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
-    return image;
-}
-
-- (void)drawRect:(CGRect)rect
-{
-    [self drawBackground:self.bounds inContext:UIGraphicsGetCurrentContext()];
-}
-
-- (void)drawBackground:(CGRect)frame inContext:(CGContextRef)context
-{
-    CGFloat R0 = self.CCMenuViewOptions.menuBackgroundColor.R, G0 = self.CCMenuViewOptions.menuBackgroundColor.G, B0 = self.CCMenuViewOptions.menuBackgroundColor.B;
-    
-    CGFloat R1 = R0, G1 = G0, B1 = B0;
-    
-    UIColor *tintColor = [CCMenuAccount tintColor];
-    if (tintColor) {
-        
-        CGFloat a;
-        [tintColor getRed:&R0 green:&G0 blue:&B0 alpha:&a];
-    }
-    
-    CGFloat X0 = frame.origin.x;
-    CGFloat X1 = frame.origin.x + frame.size.width;
-    CGFloat Y0 = frame.origin.y;
-    CGFloat Y1 = frame.origin.y + frame.size.height;
-    
-    // render arrow
-    
-    UIBezierPath *arrowPath = [UIBezierPath bezierPath];
-    
-    // fix the issue with gap of arrow's base if on the edge
-    const CGFloat kEmbedFix = 3.f;
-    
-    if (_arrowDirection == CCMenuViewArrowDirectionUp) {
-        
-        const CGFloat arrowXM = _arrowPosition;
-        const CGFloat arrowX0 = arrowXM - self.CCMenuViewOptions.arrowSize;
-        const CGFloat arrowX1 = arrowXM + self.CCMenuViewOptions.arrowSize;
-        const CGFloat arrowY0 = Y0;
-        const CGFloat arrowY1 = Y0 + self.CCMenuViewOptions.arrowSize + kEmbedFix;
-        
-        [arrowPath moveToPoint:    (CGPoint){arrowXM, arrowY0}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY1}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX0, arrowY1}];
-        [arrowPath addLineToPoint: (CGPoint){arrowXM, arrowY0}];
-        
-        
-        [[UIColor colorWithRed:R0 green:G0 blue:B0 alpha:1] set];
-        
-        Y0 += self.CCMenuViewOptions.arrowSize;
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionDown) {
-        
-        const CGFloat arrowXM = _arrowPosition;
-        const CGFloat arrowX0 = arrowXM - self.CCMenuViewOptions.arrowSize;
-        const CGFloat arrowX1 = arrowXM + self.CCMenuViewOptions.arrowSize;
-        const CGFloat arrowY0 = Y1 - self.CCMenuViewOptions.arrowSize - kEmbedFix;
-        const CGFloat arrowY1 = Y1;
-        
-        [arrowPath moveToPoint:    (CGPoint){arrowXM, arrowY1}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY0}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX0, arrowY0}];
-        [arrowPath addLineToPoint: (CGPoint){arrowXM, arrowY1}];
-        
-        [[UIColor colorWithRed:R1 green:G1 blue:B1 alpha:1] set];
-        
-        Y1 -= self.CCMenuViewOptions.arrowSize;
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionLeft) {
-        
-        const CGFloat arrowYM = _arrowPosition;
-        const CGFloat arrowX0 = X0;
-        const CGFloat arrowX1 = X0 + self.CCMenuViewOptions.arrowSize + kEmbedFix;
-        const CGFloat arrowY0 = arrowYM - self.CCMenuViewOptions.arrowSize;;
-        const CGFloat arrowY1 = arrowYM + self.CCMenuViewOptions.arrowSize;
-        
-        [arrowPath moveToPoint:    (CGPoint){arrowX0, arrowYM}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY0}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY1}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX0, arrowYM}];
-        
-        [[UIColor colorWithRed:R0 green:G0 blue:B0 alpha:1] set];
-        
-        X0 += self.CCMenuViewOptions.arrowSize;
-        
-    } else if (_arrowDirection == CCMenuViewArrowDirectionRight) {
-        
-        const CGFloat arrowYM = _arrowPosition;
-        const CGFloat arrowX0 = X1;
-        const CGFloat arrowX1 = X1 - self.CCMenuViewOptions.arrowSize - kEmbedFix;
-        const CGFloat arrowY0 = arrowYM - self.CCMenuViewOptions.arrowSize;;
-        const CGFloat arrowY1 = arrowYM + self.CCMenuViewOptions.arrowSize;
-        
-        [arrowPath moveToPoint:    (CGPoint){arrowX0, arrowYM}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY0}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX1, arrowY1}];
-        [arrowPath addLineToPoint: (CGPoint){arrowX0, arrowYM}];
-        
-        [[UIColor colorWithRed:R1 green:G1 blue:B1 alpha:1] set];
-        
-        X1 -= self.CCMenuViewOptions.arrowSize;
-    }
-    
-    [arrowPath fill];
-    
-    // render body
-    
-    const CGRect bodyFrame = {X0, Y0, X1 - X0, Y1 - Y0};
-    
-    UIBezierPath *borderPath = [UIBezierPath bezierPathWithRoundedRect:bodyFrame cornerRadius:self.CCMenuViewOptions.menuCornerRadius];
-    
-    const CGFloat locations[] = {0, 1};
-    const CGFloat components[] = {
-        R0, G0, B0, 1,
-        R1, G1, B1, 1,
-    };
-    
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, sizeof(locations)/sizeof(locations[0]));
-    CGColorSpaceRelease(colorSpace);
-    
-    [borderPath addClip];
-    
-    CGPoint start, end;
-    
-    if (_arrowDirection == CCMenuViewArrowDirectionLeft ||
-        _arrowDirection == CCMenuViewArrowDirectionRight) {
-        
-        start = (CGPoint){X0, Y0};
-        end = (CGPoint){X1, Y0};
-        
-    } else {
-        
-        start = (CGPoint){X0, Y0};
-        end = (CGPoint){X0, Y1};
-    }
-    
-    CGContextDrawLinearGradient(context, gradient, start, end, 0);
-    
-    CGGradientRelease(gradient);
-}
-
-@end
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-static CCMenuAccount *gMenu;
-static UIColor *gTintColor;
-static UIFont *gTitleFont;
-
-@implementation CCMenuAccount {
-    
-    CCMenuView *_menuView;
-    BOOL        _observing;
-}
-
-+ (instancetype)sharedMenu
-{
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-        
-        gMenu = [[CCMenuAccount alloc] init];
-    });
-    return gMenu;
-}
-
-- (id)init
-{
-    NSAssert(!gMenu, @"singleton object");
-    
-    self = [super init];
-    if (self) {
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    if (_observing) {
-        [[NSNotificationCenter defaultCenter] removeObserver:self];
-    }
-}
-
-- (void)showMenuInView:(UIView *)view fromRect:(CGRect)rect menuItems:(NSArray *)menuItems withOptions:(OptionalConfiguration) options
-{
-    NSParameterAssert(view);
-    NSParameterAssert(menuItems.count);
-    
-    if (_menuView) {
-        
-        [_menuView dismissMenu:NO];
-        _menuView = nil;
-    }
-    
-    if (!_observing) {
-        
-        _observing = YES;
-        
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
-    }
-    
-    
-    _menuView = [[CCMenuView alloc] init];
-    [_menuView showMenuInView:view fromRect:rect menuItems:menuItems withOptions:options];
-}
-
-- (void)dismissMenu
-{
-    if (_menuView) {
-        
-        [_menuView dismissMenu:NO];
-        _menuView = nil;
-    }
-    
-    if (_observing) {
-        
-        _observing = NO;
-        [[NSNotificationCenter defaultCenter] removeObserver:self];
-    }
-}
-
-- (void)orientationWillChange: (NSNotification *) n
-{
-    [self dismissMenu];
-}
-
-+ (void)showMenuInView:(UIView *)view fromRect:(CGRect)rect menuItems:(NSArray *)menuItems withOptions:(OptionalConfiguration)options
-{
-    [[self sharedMenu] showMenuInView:view fromRect:rect menuItems:menuItems withOptions:options];
-}
-
-+ (void)dismissMenu
-{
-    [[self sharedMenu] dismissMenu];
-}
-
-+ (UIColor *)tintColor
-{
-    return gTintColor;
-}
-
-+ (void)setTintColor:(UIColor *)tintColor
-{
-    if (tintColor != gTintColor) {
-        gTintColor = tintColor;
-    }
-}
-
-+ (UIFont *)titleFont
-{
-    return gTitleFont;
-}
-
-+ (void)setTitleFont:(UIFont *)titleFont
-{
-    if (titleFont != gTitleFont) {
-        gTitleFont = titleFont;
-    }
-}
-
-@end

+ 57 - 40
iOSClient/Networking/NCNetworking.swift

@@ -65,7 +65,7 @@ import Alamofire
             lastReachability = false
         }
         
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_setTitleMain), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_setTitleMain)
         #endif
     }
     
@@ -179,7 +179,7 @@ import Alamofire
                 
                 NCManageDatabase.sharedInstance.addMetadata(metadata)
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
             }
         }
     }
@@ -197,19 +197,19 @@ import Alamofire
         metadata.session = NCCommunicationCommon.shared.sessionIdentifierDownload
         if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
         
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
-                
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+        
         NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (request) in
             
             self.downloadRequest[fileNameLocalPath] = request
             metadata.status = Int(k_metadataStatusDownloading)
             if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account":metadata.account])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadFileStart, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account":metadata.account])
             
         }, progressHandler: { (progress) in
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInDownload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInDownload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
             
         }) { (account, etag, date, length, error, errorCode, errorDescription) in
                         
@@ -217,7 +217,6 @@ import Alamofire
            
             if errorCode == 0 {
                
-                metadata.date = date ?? NSDate()
                 metadata.etag = etag ?? ""
                 if setFavorite { metadata.favorite = true }
                 
@@ -235,7 +234,7 @@ import Alamofire
                 }
                 #endif
                                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadedFile, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
                 
             } else if error?.isExplicitlyCancelledError ?? false {
                                 
@@ -261,10 +260,10 @@ import Alamofire
                 }
                 #endif
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_downloadedFile), object: nil, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_downloadedFile, userInfo: ["metadata":metadata, "selector":selector, "errorCode":errorCode, "errorDescription":errorDescription])
             }
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
             
             completion(errorCode)
         }
@@ -282,11 +281,11 @@ import Alamofire
             CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
             NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
         }
     }
     
-    @objc func upload(metadata: tableMetadata) {
+    @objc func upload(metadata: tableMetadata, background: Bool = true, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->())  {
            
         var metadataForUpload: tableMetadata?
         var e2eEncrypted = false
@@ -294,7 +293,8 @@ import Alamofire
         var fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
            
         guard let account = NCManageDatabase.sharedInstance.getAccount(predicate: NSPredicate(format: "account == %@", metadata.account)) else {
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"Internal error"])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"Internal error"])
+            completion(Int(k_CCErrorInternalError), "Internal error")
             return
         }
            
@@ -316,7 +316,8 @@ import Alamofire
             metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNameLocalPath)
                
             if metadata.size > Double(k_max_filesize_E2EE) {
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
+                completion(Int(k_CCErrorInternalError), "E2E Error file too big")
                 return
             }
                
@@ -324,10 +325,12 @@ import Alamofire
            
             if e2eEncrypted {
                 #if !EXTENSION
-                NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
+                NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account, completion: completion)
                 #endif
+            } else if background {
+                uploadFileInBackground(metadata: metadataForUpload!, account: account, completion: completion)
             } else {
-                uploadFile(metadata: metadataForUpload!, account: account)
+                uploadFile(metadata: metadataForUpload!, account: account, completion: completion)
             }
            
         } else {
@@ -336,6 +339,7 @@ import Alamofire
                    
                 guard let extractMetadata = extractMetadata else {
                     NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+                    completion(Int(k_CCErrorInternalError), "Internal error")
                     return
                 }
                        
@@ -343,7 +347,8 @@ import Alamofire
                 CCUtility.moveFile(atPath: fileNamePath, toPath: fileNameLocalPath)
 
                 if e2eEncrypted && (extractMetadata.size > Double(k_max_filesize_E2EE)) {
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"E2E Error file too big"])
+                    completion(Int(k_CCErrorInternalError), "E2E Error file too big")
                     return
                 }
                        
@@ -351,16 +356,24 @@ import Alamofire
                
                 if e2eEncrypted {
                     #if !EXTENSION
-                    NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account)
+                    NCNetworkingE2EE.shared.upload(metadata: metadataForUpload!, account: account, completion: completion)
                     #endif
+                } else if background {
+                    self.uploadFileInBackground(metadata: metadataForUpload!, account: account, completion: completion)
                 } else {
-                    self.uploadFile(metadata: metadataForUpload!, account: account)
+                    self.uploadFile(metadata: metadataForUpload!, account: account, completion: completion)
                 }
             }
         }
     }
     
-    private func uploadFile(metadata: tableMetadata, account: tableAccount) {
+    //
+    private func uploadFile(metadata: tableMetadata, account: tableAccount, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
+        
+        completion(0, "")
+    }
+    
+    private func uploadFileInBackground(metadata: tableMetadata, account: tableAccount, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
         
         var session: URLSession?
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
@@ -383,8 +396,12 @@ import Alamofire
             CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, typeFile: metadata.typeFile)
             #endif
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "task":task, "serverUrl":metadata.serverUrl, "account":metadata.account])
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadFileStart, userInfo: ["ocId":metadata.ocId, "task":task, "serverUrl":metadata.serverUrl, "account":metadata.account])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+            
+            completion(0, "")
+        } else {
+            completion(Int(k_CCErrorInternalError), "task null")
         }
     }
     
@@ -393,7 +410,7 @@ import Alamofire
         
         if let metadata = NCManageDatabase.sharedInstance.getMetadataInSessionFromFileName(fileName, serverUrl: serverUrl, taskIdentifier: task.taskIdentifier) {
                         
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress), "totalBytes":NSNumber(value: totalBytes), "totalBytesExpected":NSNumber(value: totalBytesExpected)])
         }
     }
     
@@ -413,7 +430,7 @@ import Alamofire
                 CCUtility.moveFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), toPath:  CCUtility.getDirectoryProviderStorageOcId(ocId))
                 NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                     
-                metadata.date = date ?? NSDate()
+                metadata.uploadDate = date ?? NSDate()
                 metadata.etag = etag ?? ""
                 metadata.ocId = ocId!
                 
@@ -436,7 +453,7 @@ import Alamofire
                 }
                 
                 #if !EXTENSION                
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
                 #endif
                 
             } else if errorCode == NSURLErrorCancelled {
@@ -449,8 +466,8 @@ import Alamofire
                     metadata.status = Int(k_metadataStatusInUpload)
                     
                     if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
-                    NCNetworking.shared.upload(metadata: metadata)
-                        
+                    NCNetworking.shared.upload(metadata: metadata) { (_, _) in }
+                                            
                 } else {
                     
                     CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
@@ -480,12 +497,12 @@ import Alamofire
                 metadata.sessionTaskIdentifier = 0
                 metadata.status = Int(k_metadataStatusUploadError)
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
                 
                 if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
             }
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
         }
     }
     
@@ -506,7 +523,7 @@ import Alamofire
                     metadata.status = Int(k_metadataStatusNormal)
                     NCManageDatabase.sharedInstance.addMetadata(metadata)
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                 }
             }
         }
@@ -520,7 +537,7 @@ import Alamofire
                     CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
                     NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
                 }
             }
         }
@@ -623,7 +640,7 @@ import Alamofire
                         NCManageDatabase.sharedInstance.addMetadatas(metadatasInUpload!)
                     }
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrl])
                     
                     completion(account, metadataFolderInserted, metadatasInserted, errorCode, "")
                 }
@@ -703,7 +720,7 @@ import Alamofire
                     }
                 }
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrl])
                 
             } else if errorCode == 405 && overwrite {
                 self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": 0], errorDescription: "", completion: completion)
@@ -775,7 +792,7 @@ import Alamofire
                     NCManageDatabase.sharedInstance.deleteDirectoryAndSubDirectory(serverUrl: CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName), account: metadata.account)
                 }
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
             }
             
             self.NotificationPost(name: k_notificationCenter_deleteFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -809,7 +826,7 @@ import Alamofire
             if errorCode == 0 && metadata.account == account {
                 NCManageDatabase.sharedInstance.setMetadataFavorite(ocId: metadata.ocId, favorite: favorite)
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
             }
             
             self.NotificationPost(name: k_notificationCenter_favoriteFile, userInfo: ["metadata": metadata, "favorite": favorite, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -904,7 +921,7 @@ import Alamofire
                     } catch { }
                 }
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
             }
                     
             self.NotificationPost(name: k_notificationCenter_renameFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -953,8 +970,8 @@ import Alamofire
                     metadataNew = metadataMove
                 }
                                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":metadata.serverUrl])
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrlTo])
             }
                     
             self.NotificationPost(name: k_notificationCenter_moveFile, userInfo: ["metadata": metadata, "metadataNew": metadataNew, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
@@ -991,7 +1008,7 @@ import Alamofire
         
         NCCommunication.shared.copyFileOrFolder(serverUrlFileNameSource: serverUrlFileNameSource, serverUrlFileNameDestination: serverUrlFileNameDestination, overwrite: overwrite) { (account, errorCode, errorDescription) in
                     
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["serverUrl":serverUrlTo])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":serverUrlTo])
 
             self.NotificationPost(name: k_notificationCenter_copyFile, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
         }
@@ -1006,7 +1023,7 @@ import Alamofire
             if errorDescription == nil { userInfo["errorDescription"] = "" }
             else { userInfo["errorDescription"] = NSLocalizedString(errorDescription as! String, comment: "") }
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: name), object: nil, userInfo: userInfo)
+            NotificationCenter.default.postOnMainThread(name: name, userInfo: userInfo)
             
             completion(userInfo["errorCode"] as! Int, userInfo["errorDescription"] as! String)
         }

+ 19 - 12
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -175,7 +175,7 @@ import Alamofire
                     } catch { }
                 }
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                 self.NotificationPost(name: k_notificationCenter_deleteFile, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
             }
         }
@@ -183,7 +183,7 @@ import Alamofire
     
     //MARK: - Upload
     
-    func upload(metadata: tableMetadata, account: tableAccount) {
+    func upload(metadata: tableMetadata, account: tableAccount, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
         
         var metadata = metadata
         let objectE2eEncryption = tableE2eEncryption()
@@ -199,7 +199,9 @@ import Alamofire
         
         if NCEndToEndEncryption.sharedManager()?.encryptFileName(metadata.fileNameView, fileNameIdentifier: metadata.fileName, directory: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId), key: &key, initializationVector: &initializationVector, authenticationTag: &authenticationTag) == false {
             
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"_e2e_error_create_encrypted_"])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"_e2e_error_create_encrypted_"])
+            
+            completion(Int(k_CCErrorInternalError), "_e2e_error_create_encrypted_")
             return
         }
         
@@ -226,7 +228,8 @@ import Alamofire
         objectE2eEncryption.version = Int(e2eeApiVersion) ?? 1
         
         if NCManageDatabase.sharedInstance.addE2eEncryption(objectE2eEncryption) == false {
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"_e2e_error_create_encrypted_"])
+            NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":k_CCErrorInternalError, "errorDescription":"_e2e_error_create_encrypted_"])
+            completion(Int(k_CCErrorInternalError), "_e2e_error_create_encrypted_")
             return
         }
         
@@ -239,7 +242,7 @@ import Alamofire
                 metadata.session = NCCommunicationCommon.shared.sessionIdentifierUpload
                 if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
                 
                 NCCommunication.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: metadata.date as Date, dateModificationFile: metadata.date as Date, addCustomHeaders: ["e2e-token":e2eToken!], requestHandler: { (request) in
                     
@@ -247,11 +250,11 @@ import Alamofire
                     metadata.status = Int(k_metadataStatusUploading)
                     if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadFileStart), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account": metadata.account])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadFileStart, userInfo: ["ocId":metadata.ocId, "serverUrl":serverUrl, "account": metadata.account])
                     
                 }, progressHandler: { (progress) in
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_progressTask), object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
                     
                 }) { (account, ocId, etag, date, size, error, errorCode, errorDescription) in
                 
@@ -275,7 +278,7 @@ import Alamofire
                         
                         //CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, filterGrayScale: false, typeFile: metadata.typeFile, writeImage: true)
                         
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
+                        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":""])
                                                         
                     } else if error?.isExplicitlyCancelledError ?? false { 
                         
@@ -305,17 +308,21 @@ import Alamofire
                        
                         if let result = NCManageDatabase.sharedInstance.addMetadata(metadata) { metadata = result }
                         
-                        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
+                        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription])
                     }
                         
                     NCNetworkingE2EE.shared.unlock(account: metadata.account, serverUrl: serverUrl) { (_, _, _, _) in }
                     
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+                    
+                    completion(errorCode, errorDescription)                    
                 }
                 
             } else {
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_uploadedFile), object: nil, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription ?? ""])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_uploadedFile, userInfo: ["metadata":metadata, "errorCode":errorCode, "errorDescription":errorDescription ?? ""])
+                
+                completion(errorCode, errorDescription ?? "")
             }
         }
     }
@@ -428,7 +435,7 @@ import Alamofire
             if errorDescription == nil { userInfo["errorDescription"] = "" }
             else { userInfo["errorDescription"] = NSLocalizedString(errorDescription as! String, comment: "") }
                
-            NotificationCenter.default.post(name: Notification.Name.init(rawValue: name), object: nil, userInfo: userInfo)
+            NotificationCenter.default.postOnMainThread(name: name, userInfo: userInfo)
                
             completion(userInfo["errorCode"] as! Int, userInfo["errorDescription"] as! String)
         }

+ 12 - 2
iOSClient/Networking/NCOperationQueue.swift

@@ -87,13 +87,23 @@ import NCCommunication
     }
     
     // Verify exists yet file
+    
     @objc func readFileForMedia(metadata: tableMetadata) {
         
-        for operation in  readFileForMediaQueue.operations {
+        for operation in readFileForMediaQueue.operations {
             if (operation as! NCOperationReadFileForMediaQueue).metadata.ocId == metadata.ocId { return }
         }
         readFileForMediaQueue.addOperation(NCOperationReadFileForMediaQueue.init(metadata: metadata))
     }
+    
+    func cancelReadFileForMedia(metadata: tableMetadata) {
+        for operation in  readFileForMediaQueue.operations {
+            if (operation as! NCOperationReadFileForMediaQueue).metadata.ocId == metadata.ocId {
+                (operation as! NCOperationReadFileForMediaQueue).cancel()
+            }
+        }
+    }
+    
     @objc func readFileForMediaCancelAll() {
         readFileForMediaQueue.cancelAll()
     }
@@ -244,7 +254,7 @@ class NCOperationReadFileForMediaQueue: ConcurrentOperation {
             NCCommunication.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", requestBody: requestBody.data(using: .utf8)) { (account, files, responseData, errorCode, errorDescription) in
                 if errorCode == 404 {
                     NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", self.metadata.ocId))
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_deleteFile), object: nil, userInfo: ["metadata": self.metadata, "errorCode": errorCode])
+                    NotificationCenter.default.postOnMainThread(name: k_notificationCenter_deleteFile, userInfo: ["metadata": self.metadata, "errorCode": errorCode])
                 }
                 self.finish()
             }

+ 2 - 9
iOSClient/Networking/NCService.swift

@@ -107,7 +107,7 @@ class NCService: NSObject {
                     }
                 }
                       
-                NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_changeUserProfile), object: nil)
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_changeUserProfile)
                     
                 
                 // Get Capabilities
@@ -219,14 +219,7 @@ class NCService: NSObject {
             }
         }
     }
-    
-    @objc public func middlewarePing() {
-        
-        if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
-            return
-        }
-    }
-    
+   
     //MARK: - Thirt Part
     
     private func requestHC() {

+ 1 - 1
iOSClient/Notification/NCNotification.swift

@@ -178,7 +178,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, DZNEmpt
         cell.primary.setTitleColor(.white, for: .normal)
         cell.primary.layer.cornerRadius = 15
         cell.primary.layer.masksToBounds = true
-        cell.primary.layer.backgroundColor = NCBrandColor.sharedInstance.brand.cgColor
+        cell.primary.layer.backgroundColor = NCBrandColor.sharedInstance.brandElement.cgColor
         
         cell.secondary.isEnabled = false
         cell.secondary.isHidden = true

+ 2 - 2
iOSClient/Offline/NCOffline.swift

@@ -86,7 +86,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
         
         // Configure Refresh Control
         refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
-        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brand
+        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brandElement
         refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
         
         // empty Data Source
@@ -257,7 +257,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
         menuView?.delegate = self
         menuView?.rowHeight = 45
         menuView?.sectionHeaderHeight = 0.3
-        menuView?.highlightColor = NCBrandColor.sharedInstance.brand
+        menuView?.highlightColor = NCBrandColor.sharedInstance.brandElement
         menuView?.tableView.alwaysBounceVertical = false
         menuView?.tableViewSeperatorColor = NCBrandColor.sharedInstance.separator
         menuView?.tableViewBackgroundColor = NCBrandColor.sharedInstance.backgroundForm

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -73,7 +73,7 @@
  
     if (self.showOpenIn && !self.metadata.directory) {
         UIPreviewAction *item = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_open_in_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController) {
-            [[NCMainCommon sharedInstance]  downloadOpenWithMetadata:self.metadata selector:selectorOpenIn];
+            [[NCMainCommon sharedInstance] downloadOpenWithMetadata:self.metadata selector:selectorOpenIn];
         }];
         [items addObject:item];
     }

+ 9 - 7
iOSClient/ScanDocument/ScanCollectionView.swift

@@ -59,7 +59,6 @@ class DragDropViewController: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        
         collectionViewSource.dragInteractionEnabled = true
         collectionViewSource.dragDelegate = self
         collectionViewSource.dropDelegate = self
@@ -78,8 +77,8 @@ class DragDropViewController: UIViewController {
         segmentControlFilter.setTitle(NSLocalizedString("_filter_grayscale_", comment: ""), forSegmentAt: 1)
         segmentControlFilter.setTitle(NSLocalizedString("_filter_bn_", comment: ""), forSegmentAt: 2)
 
-        add.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "add"), multiplier:2, color: NCBrandColor.sharedInstance.brand), for: .normal)
-        transferDown.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "transferDown"), multiplier:2, color: NCBrandColor.sharedInstance.brand), for: .normal)
+        add.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "add"), multiplier:2, color: NCBrandColor.sharedInstance.brandElement), for: .normal)
+        transferDown.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "transferDown"), multiplier:2, color: NCBrandColor.sharedInstance.brandElement), for: .normal)
         
         let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(recognizer:)))
         add.addGestureRecognizer(longPressRecognizer)
@@ -88,10 +87,6 @@ class DragDropViewController: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         changeTheming()
         
-        labelTitlePDFzone.textColor = NCBrandColor.sharedInstance.brandText
-        labelTitlePDFzone.backgroundColor = NCBrandColor.sharedInstance.brand
-        segmentControlFilter.tintColor = NCBrandColor.sharedInstance.brand
-        
         loadImage()
     }
     
@@ -100,6 +95,13 @@ class DragDropViewController: UIViewController {
         
         collectionViewSource.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
         collectionViewDestination.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
+        
+        labelTitlePDFzone.textColor = NCBrandColor.sharedInstance.textView
+        if #available(iOS 13.0, *) {
+            labelTitlePDFzone.backgroundColor = .systemBackground
+        } else {
+            labelTitlePDFzone.backgroundColor = .systemGray
+        }
     }
     
     //MARK: Button Action

+ 2 - 2
iOSClient/Select/NCSelect.swift

@@ -117,7 +117,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         
         // Configure Refresh Control
         refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
-        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brand
+        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brandElement
         refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
         
         // empty Data Source
@@ -368,7 +368,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         menuView?.delegate = self
         menuView?.rowHeight = 45
         menuView?.sectionHeaderHeight = 8
-        menuView?.highlightColor = NCBrandColor.sharedInstance.brand
+        menuView?.highlightColor = NCBrandColor.sharedInstance.brandElement
         menuView?.tableView.alwaysBounceVertical = false
         menuView?.tableViewSeperatorColor = NCBrandColor.sharedInstance.separator
         menuView?.tableViewBackgroundColor = NCBrandColor.sharedInstance.backgroundForm

+ 0 - 2
iOSClient/Settings/CCAdvanced.m

@@ -238,8 +238,6 @@
     [KTVHTTPCache cacheDeleteAllCaches];
     
     [[NCManageDatabase sharedInstance] clearDatabaseWithAccount:appDelegate.activeAccount removeAccount:false];
-    [[NCManageDatabase sharedInstance] setAccountDateUpdateNewMediaWithClear:true];
-    [[NCManageDatabase sharedInstance] setAccountDateLessMediaWithDate:nil];
     
     [CCUtility removeGroupDirectoryProviderStorage];
     [CCUtility removeGroupLibraryDirectory];

+ 3 - 3
iOSClient/Share/NCShare.swift

@@ -232,11 +232,11 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
     /// MARK: - NCShareNetworkingDelegate
     
     func readShareCompleted() {
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func shareCompleted() {
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func unShareCompleted() { }
@@ -462,7 +462,7 @@ class NCShareUserCell: UITableViewCell {
         super.awakeFromNib()
         
         switchCanEdit.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchCanEdit.onTintColor = NCBrandColor.sharedInstance.brand
+        switchCanEdit.onTintColor = NCBrandColor.sharedInstance.brandElement
         buttonMenu.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMenu"), width:100, height: 100, color: UIColor.gray), for: .normal)
     }
     

+ 2 - 2
iOSClient/Share/NCShareCommon.swift

@@ -34,7 +34,7 @@ class NCShareCommon: NSObject {
         
         let size: CGFloat = 200
         
-        let bottomImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "circle"), width: size, height: size, color: NCBrandColor.sharedInstance.brand)
+        let bottomImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "circle"), width: size, height: size, color: NCBrandColor.sharedInstance.brandElement)
         let topImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: size, height: size, color: UIColor.white)
         UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
         bottomImage?.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: size, height: size)))
@@ -166,7 +166,7 @@ class NCShareCommon: NSObject {
         calendar.appearance.weekdayTextColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)
         calendar.appearance.weekdayFont = UIFont.systemFont(ofSize: 12)
         
-        calendar.appearance.todayColor = NCBrandColor.sharedInstance.brand
+        calendar.appearance.todayColor = NCBrandColor.sharedInstance.brandElement
         calendar.appearance.titleFont = UIFont.systemFont(ofSize: 12)
         
         viewWindow.addSubview(calendar)

+ 9 - 9
iOSClient/Share/NCShareLinkMenuView.swift

@@ -84,19 +84,19 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         layer.shadowOpacity = 0.2
         
         switchAllowEditing?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchAllowEditing?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchAllowEditing?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchReadOnly?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchReadOnly?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchReadOnly?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchAllowUploadAndEditing?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchAllowUploadAndEditing?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchAllowUploadAndEditing?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchFileDrop?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchFileDrop?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchFileDrop?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchHideDownload.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchHideDownload.onTintColor = NCBrandColor.sharedInstance.brand
+        switchHideDownload.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchPasswordProtect.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchPasswordProtect.onTintColor = NCBrandColor.sharedInstance.brand
+        switchPasswordProtect.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchSetExpirationDate.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchSetExpirationDate.onTintColor = NCBrandColor.sharedInstance.brand
+        switchSetExpirationDate.onTintColor = NCBrandColor.sharedInstance.brandElement
         
         labelAllowEditing?.text = NSLocalizedString("_share_allow_editing_", comment: "")
         labelAllowEditing?.textColor = NCBrandColor.sharedInstance.textView
@@ -381,12 +381,12 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     
     func shareCompleted() {
         unLoad()
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func unShareCompleted() {
         unLoad()
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func updateShareWithError(idShare: Int) {

+ 2 - 2
iOSClient/Share/NCSharePaging.swift

@@ -83,7 +83,7 @@ class NCSharePaging: UIViewController {
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         
-        NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
     }
     
     @objc func exitTapped() {
@@ -100,7 +100,7 @@ class NCSharePaging: UIViewController {
         pagingViewController.selectedBackgroundColor = NCBrandColor.sharedInstance.backgroundForm
         pagingViewController.textColor = NCBrandColor.sharedInstance.textView
         pagingViewController.selectedTextColor = NCBrandColor.sharedInstance.textView
-        pagingViewController.indicatorColor = NCBrandColor.sharedInstance.brand
+        pagingViewController.indicatorColor = NCBrandColor.sharedInstance.brandElement
         (pagingViewController.view as! NCSharePagingView).setupConstraints()
         pagingViewController.reloadMenu()
     }

+ 7 - 7
iOSClient/Share/NCShareUserMenuView.swift

@@ -73,15 +73,15 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         layer.shadowOpacity = 0.2
         
         switchCanReshare.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchCanReshare.onTintColor = NCBrandColor.sharedInstance.brand
+        switchCanReshare.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchCanCreate?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchCanCreate?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchCanCreate?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchCanChange?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchCanChange?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchCanChange?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchCanDelete?.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchCanDelete?.onTintColor = NCBrandColor.sharedInstance.brand
+        switchCanDelete?.onTintColor = NCBrandColor.sharedInstance.brandElement
         switchSetExpirationDate.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
-        switchSetExpirationDate.onTintColor = NCBrandColor.sharedInstance.brand
+        switchSetExpirationDate.onTintColor = NCBrandColor.sharedInstance.brandElement
         
         labelCanReshare?.text = NSLocalizedString("_share_can_reshare_", comment: "")
         labelCanReshare?.textColor = NCBrandColor.sharedInstance.textView
@@ -313,12 +313,12 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     
     func shareCompleted() {
         unLoad()
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func unShareCompleted() {
         unLoad()
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
+        NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataNCShare)
     }
     
     func updateShareWithError(idShare: Int) {

BIN
iOSClient/Supporting Files/ca.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/fr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/gl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/it.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/sl.lproj/Localizable.strings


+ 2 - 1
iOSClient/Transfers/CCTransfers.m

@@ -251,7 +251,8 @@
     } else {
         metadataForRecognizer.status = k_metadataStatusInUpload;
         metadataForRecognizer.session = NCCommunicationCommon.shared.sessionIdentifierBackground;
-        [[NCNetworking shared] uploadWithMetadata:[[NCManageDatabase sharedInstance] addMetadata:metadataForRecognizer]];
+       
+        [[NCNetworking shared] uploadWithMetadata:[[NCManageDatabase sharedInstance] addMetadata:metadataForRecognizer]   background: true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
     }
 }
 

+ 1 - 1
iOSClient/Trash/NCTrash.swift

@@ -122,7 +122,7 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
         appDelegate.changeTheming(self, tableView: nil, collectionView: collectionView, form: false)
         
         refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
-        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brand
+        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brandElement
     }
     
     // MARK: DZNEmpty

+ 5 - 9
iOSClient/Utility/NCContentPresenter.swift

@@ -90,14 +90,10 @@ class NCContentPresenter: NSObject {
             //case Int(kOCErrorServerUnauthorized), Int(kOCErrorServerForbidden):
             //    break
             default:
-                var description = description
-                if description == nil { description = "" }
-                if type == messageType.error {
-                    description = NSLocalizedString("_error_", comment: "") + " " + NSLocalizedString(description!, comment: "")
-                } else {
-                    description = NSLocalizedString(description!, comment: "")
-                }
-                self.flatTop(title: NSLocalizedString(title, comment: ""), description: description!, delay: delay, imageName: nil, type: type, name: "\(errorCode)")
+                guard var description = description else { return }
+                if description.trimmingCharacters(in: .whitespacesAndNewlines) == "" { return }
+                description = NSLocalizedString(description, comment: "")
+                self.flatTop(title: NSLocalizedString(title, comment: ""), description: description, delay: delay, imageName: nil, type: type, name: "\(errorCode)")
             }
         }
     }
@@ -204,7 +200,7 @@ class NCContentPresenter: NSObject {
     private func getBackgroundColorFromType(_ type: messageType) -> UIColor {
         switch type {
         case .info:
-            return NCBrandColor.sharedInstance.brand
+            return NCBrandColor.sharedInstance.brandElement
         case .error:
             return UIColor(red: 1, green: 0, blue: 0, alpha: 0.9)
         case .success:

+ 4 - 4
iOSClient/Utility/NCUtility.swift

@@ -111,7 +111,7 @@ class NCUtility: NSObject {
         
         blurEffectView.frame = frame
         blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-        blurEffectView.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.2)
+        blurEffectView.backgroundColor = NCBrandColor.sharedInstance.brandElement.withAlphaComponent(0.2)
         
         return blurEffectView
     }
@@ -228,7 +228,7 @@ class NCUtility: NSObject {
     
         guard let view = view else { return }
         
-        activityIndicator.color = NCBrandColor.sharedInstance.brand
+        activityIndicator.color = NCBrandColor.sharedInstance.brandElement
         activityIndicator.hidesWhenStopped = true
             
         view.addSubview(activityIndicator)
@@ -274,12 +274,12 @@ class NCUtility: NSObject {
     @objc func blink(cell: AnyObject?) {
         DispatchQueue.main.async {
             if let cell = cell as? UITableViewCell {
-                cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+                cell.backgroundColor = NCBrandColor.sharedInstance.brandElement.withAlphaComponent(0.3)
                 UIView.animate(withDuration: 2) {
                     cell.backgroundColor = .clear
                 }
             } else if let cell = cell as? UICollectionViewCell {
-                cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+                cell.backgroundColor = NCBrandColor.sharedInstance.brandElement.withAlphaComponent(0.3)
                 UIView.animate(withDuration: 2) {
                     cell.backgroundColor = .clear
                 }

+ 34 - 0
iOSClient/Utility/NotificationCenter+MainThread.swift

@@ -0,0 +1,34 @@
+//
+//  NotificationCenter+MainThread.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 16/06/2020.
+//  Copyright © 2020 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+
+extension NotificationCenter {
+
+    func postOnMainThread(name: String, object anObject: Any? = nil, userInfo aUserInfo: [AnyHashable : Any]? = nil) {
+        DispatchQueue.main.async {
+            NotificationCenter.default.post(name: Notification.Name.init(rawValue: name), object: anObject, userInfo: aUserInfo)
+        }
+    }
+}
+

+ 4 - 6
iOSClient/Viewer/NCViewerImage/NCViewerImageCommon.swift

@@ -35,9 +35,9 @@ class NCViewerImageCommon: NSObject {
     static var offOutlineImage: UIImage?
 
     override init() {
-        NCViewerImageCommon.offOutlineAudio = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineAudio"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brand)
-        NCViewerImageCommon.offOutlineVideo = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineVideo"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brand)
-        NCViewerImageCommon.offOutlineImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineImage"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brand)
+        NCViewerImageCommon.offOutlineAudio = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineAudio"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brandElement)
+        NCViewerImageCommon.offOutlineVideo = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineVideo"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brandElement)
+        NCViewerImageCommon.offOutlineImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "offOutlineImage"), width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width, color: NCBrandColor.sharedInstance.brandElement)
     }
     
     func getMetadatasDatasource(metadata: tableMetadata?, metadatas: [tableMetadata], favoriteDatasorce: Bool, mediaDatasorce: Bool, offLineDatasource: Bool) -> [tableMetadata]? {
@@ -122,9 +122,7 @@ class NCViewerImageCommon: NSObject {
             // AUTOMATIC DOWNLOAD FOR GIF
             
             if (ext == "GIF" || ext == "SVG")  && metadata.session == "" {
-                DispatchQueue.main.async {
-                    NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_menuDownloadImage), object: nil, userInfo: ["metadata": metadata])
-                }
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_menuDownloadImage, userInfo: ["metadata": metadata])
             }
         }
         

+ 1 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImageContentView.swift

@@ -109,7 +109,7 @@ public class NCViewerImageContentView: UIScrollView {
 
     private lazy var indicatorContainer: UIView = {
         let container = UIView()
-        container.backgroundColor = NCBrandColor.sharedInstance.brand
+        container.backgroundColor = NCBrandColor.sharedInstance.brandElement
         container.layer.cornerRadius = Constants.indicatorViewSize * 0.5
         container.layer.masksToBounds = true
         return container

+ 1 - 1
iOSClient/Viewer/NCViewerVideo.swift

@@ -107,7 +107,7 @@ class NCViewerVideo: NSObject {
                 _ = NCManageDatabase.sharedInstance.addLocalFile(metadata: self.metadata)
                 KTVHTTPCache.cacheDelete(with: self.videoURL)
                 
-                NotificationCenter.default.post(name: Notification.Name.init(rawValue: k_notificationCenter_reloadDataSource), object: nil, userInfo: ["ocId":self.metadata.ocId, "serverUrl":self.metadata.serverUrl])
+                NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["ocId":self.metadata.ocId, "serverUrl":self.metadata.serverUrl])
             }
         }
     }