Browse Source

Merge branch 'develop' into newdrawer

Signed-off-by: Philippe Weidmann <philippe.weidmann@infomaniak.com>

# Conflicts:
#	iOSClient/Main/CCMain.h
Philippe Weidmann 5 years ago
parent
commit
3d4eb8c223
52 changed files with 497 additions and 300 deletions
  1. 1 1
      Cartfile
  2. 1 1
      Cartfile.resolved
  3. 6 3
      File Provider Extension/FileProviderData.swift
  4. 20 12
      Nextcloud.xcodeproj/project.pbxproj
  5. 3 1
      Share/ShareViewController.m
  6. 8 13
      iOSClient/Activity/NCActivity.swift
  7. 3 2
      iOSClient/AppDelegate.m
  8. 1 2
      iOSClient/CCGlobal.h
  9. 8 14
      iOSClient/Login/NCLoginWeb.swift
  10. 1 4
      iOSClient/Main/CCDetail.m
  11. 1 0
      iOSClient/Main/CCMain.h
  12. 34 39
      iOSClient/Main/CCMain.m
  13. 4 12
      iOSClient/Main/CCMore.swift
  14. 5 5
      iOSClient/Main/Main.storyboard
  15. 9 18
      iOSClient/Main/NCMainCommon.swift
  16. 17 6
      iOSClient/Networking/NCService.swift
  17. 1 1
      iOSClient/Networking/OCNetworking.h
  18. 2 1
      iOSClient/Networking/OCNetworking.m
  19. 9 13
      iOSClient/Notification/CCNotification.swift
  20. 5 1
      iOSClient/RichWorkspace/NCRichWorkspace.swift
  21. 1 1
      iOSClient/RichWorkspace/NCRichWorkspace.xib
  22. 110 0
      iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift
  23. 17 11
      iOSClient/RichWorkspace/NCViewerRichWorkSpaceNextcloudText.swift
  24. 7 21
      iOSClient/RichWorkspace/NCViewerRichWorkspace.storyboard
  25. 30 40
      iOSClient/RichWorkspace/NCViewerRichWorkspace.swift
  26. 0 23
      iOSClient/Settings/CCManageAccount.m
  27. 19 27
      iOSClient/Share/NCShare.swift
  28. 8 0
      iOSClient/Share/NCShareComments.swift
  29. 21 23
      iOSClient/Share/NCShareCommentsCell.xib
  30. BIN
      iOSClient/Supporting Files/ca.lproj/Localizable.strings
  31. BIN
      iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings
  32. BIN
      iOSClient/Supporting Files/de.lproj/Localizable.strings
  33. BIN
      iOSClient/Supporting Files/es-DO.lproj/Localizable.strings
  34. BIN
      iOSClient/Supporting Files/es.lproj/Localizable.strings
  35. BIN
      iOSClient/Supporting Files/eu.lproj/Localizable.strings
  36. BIN
      iOSClient/Supporting Files/fa.lproj/Localizable.strings
  37. BIN
      iOSClient/Supporting Files/gl.lproj/Localizable.strings
  38. BIN
      iOSClient/Supporting Files/hr.lproj/Localizable.strings
  39. BIN
      iOSClient/Supporting Files/it.lproj/Localizable.strings
  40. BIN
      iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings
  41. BIN
      iOSClient/Supporting Files/lt_LT.lproj/Localizable.strings
  42. BIN
      iOSClient/Supporting Files/nl.lproj/Localizable.strings
  43. BIN
      iOSClient/Supporting Files/pl.lproj/Localizable.strings
  44. BIN
      iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings
  45. BIN
      iOSClient/Supporting Files/ru.lproj/Localizable.strings
  46. BIN
      iOSClient/Supporting Files/sl.lproj/Localizable.strings
  47. BIN
      iOSClient/Supporting Files/sv.lproj/Localizable.strings
  48. BIN
      iOSClient/Supporting Files/tr.lproj/Localizable.strings
  49. BIN
      iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings
  50. 6 5
      iOSClient/Utility/NCUtility.swift
  51. 137 0
      iOSClient/Viewer/NCViewerNextcloudText.swift
  52. 2 0
      iOSClient/Viewer/NCViewerRichdocument.swift

+ 1 - 1
Cartfile

@@ -1,4 +1,4 @@
-github "nextcloud/ios-communication-library" "v0.4"
+github "nextcloud/ios-communication-library" "develop"
 github "tilltue/TLPhotoPicker" "2.0.7"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "danielsaidi/Sheeeeeeeeet" "3.0.9"

+ 1 - 1
Cartfile.resolved

@@ -17,7 +17,7 @@ github "krzyzanowskim/OpenSSL" "1.0.218"
 github "malcommac/SwiftRichString" "3.6.0"
 github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/FastScroll" "81967c2309d29bc2c330d422da612160a30bade8"
-github "nextcloud/ios-communication-library" "v0.4"
+github "nextcloud/ios-communication-library" "da0bdaee5e3b6b3a8ab0ed64dee83fe082a56cef"
 github "realm/realm-cocoa" "v4.1.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.1"

+ 6 - 3
File Provider Extension/FileProviderData.swift

@@ -74,6 +74,7 @@ class fileProviderData: NSObject {
         if domain == nil {
             
             guard let tableAccount = NCManageDatabase.sharedInstance.getAccountActive() else { return false }
+            guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
             
             account = tableAccount.account
             accountUser = tableAccount.user
@@ -82,7 +83,7 @@ class fileProviderData: NSObject {
             accountUrl = tableAccount.url
             homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
             
-            NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID,  password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, delegate: NCNetworking.sharedInstance)
+            NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID,  password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
             NCNetworking.sharedInstance.setup(account: tableAccount.account, delegate: providerExtension as? NCNetworkingDelegate)
             
             return true
@@ -96,6 +97,7 @@ class fileProviderData: NSObject {
             guard let host = url.host else { continue }
             let accountDomain = tableAccount.userID + " (" + host + ")"
             if accountDomain == domain {
+                guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
                 account = tableAccount.account
                 accountUser = tableAccount.user
                 accountUserID = tableAccount.userID
@@ -104,7 +106,7 @@ class fileProviderData: NSObject {
                 accountUrl = tableAccount.url
                 homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
                 
-                NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID, password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, delegate: NCNetworking.sharedInstance)
+                NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID, password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
                 NCNetworking.sharedInstance.setup(account: tableAccount.account, delegate: providerExtension as? NCNetworkingDelegate)
 
                 foundAccount = true
@@ -125,6 +127,7 @@ class fileProviderData: NSObject {
         
         for tableAccount in tableAccounts {
             if accountFromItemIdentifier == tableAccount.account {
+                guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: tableAccount.account) else { return false }
                 account = tableAccount.account
                 accountUser = tableAccount.user
                 accountUserID = tableAccount.userID
@@ -132,7 +135,7 @@ class fileProviderData: NSObject {
                 accountUrl = tableAccount.url
                 homeServerUrl = CCUtility.getHomeServerUrlActiveUrl(tableAccount.url)
                 
-                NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID, password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, delegate: NCNetworking.sharedInstance)
+                NCCommunicationCommon.sharedInstance.setup(username: accountUser, userID: accountUserID, password: accountPassword, userAgent: CCUtility.getUserAgent(), capabilitiesGroup: NCBrandOptions.sharedInstance.capabilitiesGroups, nextcloudVersion: capabilities.versionMajor, delegate: NCNetworking.sharedInstance)
                 NCNetworking.sharedInstance.setup(account: tableAccount.account, delegate: providerExtension as? NCNetworkingDelegate)
                 
                 foundAccount = true

+ 20 - 12
Nextcloud.xcodeproj/project.pbxproj

@@ -101,6 +101,7 @@
 		F72AAECA1E5C60C700BB17E1 /* AHKActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = F72AAEC31E5C60C700BB17E1 /* AHKActionSheet.m */; };
 		F72AAECB1E5C60C700BB17E1 /* AHKActionSheetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F72AAEC51E5C60C700BB17E1 /* AHKActionSheetViewController.m */; };
 		F72D1007210B6882009C96B7 /* NCPushNotificationEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = F72D1005210B6882009C96B7 /* NCPushNotificationEncryption.m */; };
+		F72D404923D2082500A97FD0 /* NCViewerNextcloudText.swift in Sources */ = {isa = PBXBuildFile; fileRef = F72D404823D2082500A97FD0 /* NCViewerNextcloudText.swift */; };
 		F72E0B9D21AD60BC00898D7B /* WeScan.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F72E0B9C21AD60BC00898D7B /* WeScan.framework */; };
 		F732BA061D76CE1500E9878B /* CCNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F732BA041D76CE1500E9878B /* CCNetworking.m */; };
 		F732BA0B1D76DBA500E9878B /* CCNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F732BA041D76CE1500E9878B /* CCNetworking.m */; };
@@ -239,6 +240,7 @@
 		F75A9EE823796C6F0044CFCE /* NCNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75A9EE523796C6F0044CFCE /* NCNetworking.swift */; };
 		F75AC2431F1F62450073EC19 /* NCManageAutoUploadFileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75AC2421F1F62450073EC19 /* NCManageAutoUploadFileName.swift */; };
 		F75ADF451DC75FFE008A7347 /* CCLogin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F75ADF441DC75FFE008A7347 /* CCLogin.storyboard */; };
+		F75C0C4823D1FAE300163CC8 /* NCRichWorkspaceCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */; };
 		F75EDFBD1E8C112F00E6F369 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */; };
 		F75EDFBF1E8C116D00E6F369 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */; };
 		F760F77B21F21F61006B1A73 /* icomoon.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F760F75721F21F61006B1A73 /* icomoon.ttf */; };
@@ -398,7 +400,7 @@
 		F781996B22636BFA00EBDF6A /* HCFeatures.m in Sources */ = {isa = PBXBuildFile; fileRef = F781996822636BFA00EBDF6A /* HCFeatures.m */; };
 		F78295311F962EFA00A572F5 /* NCEndToEndEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = F70CAE391F8CF31A008125FD /* NCEndToEndEncryption.m */; };
 		F787704F22E7019900F287A9 /* NCShareLinkCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F787704E22E7019900F287A9 /* NCShareLinkCell.xib */; };
-		F78A18B623CDD07D00F681F3 /* NCViewerNextcloudText.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B523CDD07D00F681F3 /* NCViewerNextcloudText.swift */; };
+		F78A18B623CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B523CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift */; };
 		F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */; };
 		F78AA20621F783E900D0F205 /* SwiftRichString.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F78AA20521F783E900D0F205 /* SwiftRichString.framework */; };
 		F78ACD4021903CC20088454D /* NCGridCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD3F21903CC20088454D /* NCGridCell.swift */; };
@@ -773,6 +775,7 @@
 		F72AAEC51E5C60C700BB17E1 /* AHKActionSheetViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AHKActionSheetViewController.m; sourceTree = "<group>"; };
 		F72D1005210B6882009C96B7 /* NCPushNotificationEncryption.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCPushNotificationEncryption.m; sourceTree = "<group>"; };
 		F72D1006210B6882009C96B7 /* NCPushNotificationEncryption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCPushNotificationEncryption.h; sourceTree = "<group>"; };
+		F72D404823D2082500A97FD0 /* NCViewerNextcloudText.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerNextcloudText.swift; sourceTree = "<group>"; };
 		F72E0B9C21AD60BC00898D7B /* WeScan.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WeScan.framework; path = Carthage/Build/iOS/WeScan.framework; sourceTree = "<group>"; };
 		F73049B81CB567F000C7C320 /* NSString+TruncateToWidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+TruncateToWidth.h"; sourceTree = "<group>"; };
 		F73049B91CB567F000C7C320 /* NSString+TruncateToWidth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+TruncateToWidth.m"; sourceTree = "<group>"; };
@@ -923,6 +926,7 @@
 		F75B91E21ECAE17800199C96 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F75B91F71ECAE26300199C96 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F75B923D1ECAE55E00199C96 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
+		F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCRichWorkspaceCommon.swift; sourceTree = "<group>"; };
 		F75CDBF51DF063AD00116AD0 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; name = .gitignore; path = ../.gitignore; sourceTree = "<group>"; };
 		F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; };
 		F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
@@ -1119,7 +1123,7 @@
 		F781996722636BFA00EBDF6A /* HCFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HCFeatures.h; sourceTree = "<group>"; };
 		F781996822636BFA00EBDF6A /* HCFeatures.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HCFeatures.m; sourceTree = "<group>"; };
 		F787704E22E7019900F287A9 /* NCShareLinkCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareLinkCell.xib; sourceTree = "<group>"; };
-		F78A18B523CDD07D00F681F3 /* NCViewerNextcloudText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerNextcloudText.swift; sourceTree = "<group>"; };
+		F78A18B523CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkSpaceNextcloudText.swift; sourceTree = "<group>"; };
 		F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkspace.swift; sourceTree = "<group>"; };
 		F78AA20521F783E900D0F205 /* SwiftRichString.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftRichString.framework; path = Carthage/Build/iOS/SwiftRichString.framework; sourceTree = "<group>"; };
 		F78ACD3F21903CC20088454D /* NCGridCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCGridCell.swift; sourceTree = "<group>"; };
@@ -2255,6 +2259,7 @@
 		F79630EC215526B60015EEA5 /* Viewer */ = {
 			isa = PBXGroup;
 			children = (
+				F72D404823D2082500A97FD0 /* NCViewerNextcloudText.swift */,
 				F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */,
 				F7FB1D3D215E191D00D669EA /* NCViewerDocumentWeb.swift */,
 				F79630ED215527D40015EEA5 /* NCViewerMedia.swift */,
@@ -2526,11 +2531,12 @@
 		F7CADB3D23CCDDA1000EEC78 /* RichWorkspace */ = {
 			isa = PBXGroup;
 			children = (
-				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
-				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
-				F78A18B523CDD07D00F681F3 /* NCViewerNextcloudText.swift */,
 				F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */,
 				F722814223C8C34500C41898 /* NCRichWorkspace.xib */,
+				F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */,
+				F78A18B523CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift */,
+				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
+				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
 			);
 			path = RichWorkspace;
 			sourceTree = "<group>";
@@ -3553,7 +3559,7 @@
 				F7B6ACD622FC2BD4008AB646 /* NCXMLCommentsParser.m in Sources */,
 				F738E8421F90FFD100F95C8E /* NCManageEndToEndEncryption.m in Sources */,
 				F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */,
-				F78A18B623CDD07D00F681F3 /* NCViewerNextcloudText.swift in Sources */,
+				F78A18B623CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift in Sources */,
 				F75A9EE623796C6F0044CFCE /* NCNetworking.swift in Sources */,
 				F760F79D21F21F61006B1A73 /* CropRectView.swift in Sources */,
 				F73B4F091F470D9100BBEE4B /* nsEUCKRProber.cpp in Sources */,
@@ -3569,6 +3575,7 @@
 				F7DFB7EB219C5A2E00680748 /* NCCreateMenuAdd.swift in Sources */,
 				F7F54D0A1E5B14C800E19C62 /* MWPhotoBrowser.m in Sources */,
 				F762CB081EACB66200B38484 /* XLFormOptionsViewController.m in Sources */,
+				F72D404923D2082500A97FD0 /* NCViewerNextcloudText.swift in Sources */,
 				F73CC0721E813DFF006E3047 /* BKPasscodeLockScreenManager.m in Sources */,
 				F760F78B21F21F61006B1A73 /* UIImage+Crop.swift in Sources */,
 				F73B4F101F470D9100BBEE4B /* nsSBCharSetProber.cpp in Sources */,
@@ -3616,6 +3623,7 @@
 				F760F77D21F21F61006B1A73 /* ColorsCollectionViewDelegate.swift in Sources */,
 				F7BAADC81ED5A87C00B7EAD4 /* NCDatabase.swift in Sources */,
 				F70022E61EC4C9100080073F /* OCXMLServerErrorsParser.m in Sources */,
+				F75C0C4823D1FAE300163CC8 /* NCRichWorkspaceCommon.swift in Sources */,
 				F762CB171EACB66200B38484 /* XLFormRegexValidator.m in Sources */,
 				F729B92D217A2F1B00FE2150 /* NCActionSheetHeaderView.swift in Sources */,
 				F760F78721F21F61006B1A73 /* PhotoEditor+Font.swift in Sources */,
@@ -3862,7 +3870,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -3906,7 +3914,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -3956,7 +3964,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4006,7 +4014,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4048,7 +4056,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4095,7 +4103,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 7;
+				CURRENT_PROJECT_VERSION = 8;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (

+ 3 - 1
Share/ShareViewController.m

@@ -61,8 +61,10 @@
         
     } else {
         
+        tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:tableAccount.account];
+
         // Networking
-        [[NCCommunicationCommon sharedInstance] setupWithUsername:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups delegate:[NCNetworking sharedInstance]];
+        [[NCCommunicationCommon sharedInstance] setupWithUsername:tableAccount.user userID:tableAccount.userID password:[CCUtility getPassword:tableAccount.account] userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
        
         _activeAccount = tableAccount.account;
         

+ 8 - 13
iOSClient/Activity/NCActivity.swift

@@ -24,6 +24,7 @@
 import Foundation
 import UIKit
 import SwiftRichString
+import NCCommunication
 
 class NCActivity: UIViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
     
@@ -210,15 +211,14 @@ extension NCActivity: UITableViewDataSource {
                     if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.icon.image = image }
                 } else {
                     DispatchQueue.global().async {
-                        let encodedString = activity.icon.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                        OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
+                        NCCommunication.sharedInstance.downloadContent(urlString: activity.icon, account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
                             if errorCode == 0 {
                                 do {
                                     try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
                                     if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.icon.image = image }
                                 } catch { return }
                             }
-                        })
+                        }
                     }
                 }
             }
@@ -236,16 +236,11 @@ extension NCActivity: UITableViewDataSource {
                     }
                 } else {
                     DispatchQueue.global().async {
-                        let url = self.appDelegate.activeUrl + k_avatar + activity.user + "/" + k_avatar_size
-                        let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                        OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                            if errorCode == 0 && UIImage(data: data!) != nil {
-                                do {
-                                    try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                                } catch { return }
+                        NCCommunication.sharedInstance.downloadAvatar(urlString: self.appDelegate.activeUrl, userID: activity.user, fileNameLocalPath: fileNameLocalPath, size: Int(k_avatar_size), account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                            if errorCode == 0 && account == self.appDelegate.activeAccount && UIImage(data: data!) != nil {
                                 cell.avatar.image = UIImage(data: data!)
                             }
-                        })
+                        }
                     }
                 }
             }
@@ -458,7 +453,7 @@ extension activityTableViewCell: UICollectionViewDataSource {
                 
                 let source = activityPreview.source
                 
-                NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false) { (imageNamePath) in
+                NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false, account: appDelegate.activeAccount) { (imageNamePath) in
                     if imageNamePath != nil {
                         if let image = UIImage(contentsOfFile: imageNamePath!) {
                             cell.imageView.image = image
@@ -472,7 +467,7 @@ extension activityTableViewCell: UICollectionViewDataSource {
                     
                     let source = activityPreview.source
                     
-                    NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false) { (imageNamePath) in
+                    NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false, account: appDelegate.activeAccount) { (imageNamePath) in
                         if imageNamePath != nil {
                             if let image = UIImage(contentsOfFile: imageNamePath!) {
                                 cell.imageView.image = image

+ 3 - 2
iOSClient/AppDelegate.m

@@ -430,12 +430,13 @@ PKPushRegistry *pushRegistry;
     self.activeUser = activeUser;
     self.activeUserID = activeUserID;
     self.activePassword = activePassword;
-    
+    tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:activeAccount];
+
     // Setting Account to Networking
     [CCNetworking sharedNetworking].delegate = [NCNetworkingMain sharedInstance];
     
     [[NCNetworking sharedInstance] setupWithAccount:activeAccount delegate:nil];
-    [[NCCommunicationCommon sharedInstance] setupWithUsername:activeUser userID:activeUserID password:activePassword userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups delegate:[NCNetworking sharedInstance]];
+    [[NCCommunicationCommon sharedInstance] setupWithUsername:activeUser userID:activeUserID password:activePassword userAgent:[CCUtility getUserAgent] capabilitiesGroup:[NCBrandOptions sharedInstance].capabilitiesGroups nextcloudVersion:capabilities.versionMajor delegate:[NCNetworking sharedInstance]];
 }
 
 - (void)deleteAccount:(NSString *)account wipe:(BOOL)wipe

+ 1 - 2
iOSClient/CCGlobal.h

@@ -68,8 +68,7 @@
 #define k_flowEndpoint                                  @"/index.php/login/flow"
 
 // Avatar
-#define k_avatar                                        @"/index.php/avatar/"
-#define k_avatar_size                                   "128"
+#define k_avatar_size                                   128
 
 // Passphrase test EndToEnd Encryption
 #define k_passphrase_test                               @"more over television factory tendency independence international intellectual impress interest sentence pony"

+ 8 - 14
iOSClient/Login/NCLoginWeb.swift

@@ -34,14 +34,6 @@ class NCLoginWeb: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        if (NCBrandOptions.sharedInstance.use_login_web_personalized) {
-            if let accountCount = NCManageDatabase.sharedInstance.getAccounts()?.count {
-                if(accountCount > 0) {
-                    self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .stop, target: self, action: #selector(self.closeView(sender:)))
-                }
-            }
-        }
-        
         let config = WKWebViewConfiguration()
         config.websiteDataStore = WKWebsiteDataStore.nonPersistent()
 
@@ -55,7 +47,7 @@ class NCLoginWeb: UIViewController {
         webView!.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
         
         // ADD k_flowEndpoint for Web Flow
-        if urlBase != NCBrandOptions.sharedInstance.linkloginPreferredProviders {
+        if NCBrandOptions.sharedInstance.use_login_web_personalized == false && urlBase != NCBrandOptions.sharedInstance.linkloginPreferredProviders {
             urlBase =  urlBase + k_flowEndpoint
         }
         
@@ -93,10 +85,6 @@ class NCLoginWeb: UIViewController {
         webView.load(request)
     }
     
-    @objc func closeView(sender: UIBarButtonItem) {
-        self.dismiss(animated: true, completion: nil)
-    }
-    
 }
 
 extension NCLoginWeb: WKNavigationDelegate {
@@ -141,6 +129,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                 // NO account found, clear
                 if NCManageDatabase.sharedInstance.getAccounts() == nil { NCUtility.sharedInstance.removeAllSettings() }
                 
+                
                 // Add new account
                 NCManageDatabase.sharedInstance.deleteAccount(account)
                 NCManageDatabase.sharedInstance.addAccount(account, url: serverUrl, user: username, password: token)
@@ -162,7 +151,12 @@ extension NCLoginWeb: WKNavigationDelegate {
                         let splitController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                         splitController?.modalPresentationStyle = .fullScreen
                         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
-                        self.navigationController?.present(splitController!, animated: true)
+                        splitController!.view.alpha = 0
+                        appDelegate.window.rootViewController = splitController!
+                        appDelegate.window.makeKeyAndVisible()
+                        UIView.animate(withDuration: 0.5) {
+                            splitController!.view.alpha = 1
+                        }
                     } else {
                         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
                         self.dismiss(animated: true)

+ 1 - 4
iOSClient/Main/CCDetail.m

@@ -216,7 +216,6 @@
             return;
         }
         
-        /*
         // Nextcloud Text - RichWorkspace
         if ([[NCUtility sharedInstance] isDirectEditing:self.metadataDetail] != nil && appDelegate.reachability.isReachable) {
             
@@ -257,9 +256,7 @@
             }
             
             return;
-        }
-        */
-        
+        }        
         
         // RichDocument
         if ([[NCUtility sharedInstance] isRichDocument:self.metadataDetail] && appDelegate.reachability.isReachable) {

+ 1 - 0
iOSClient/Main/CCMain.h

@@ -56,6 +56,7 @@
 
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleMain;
+@property (nonatomic, strong) NSString *richWorkspace;
 @property (nonatomic, weak) CCDetail *detailViewController;
 @property (nonatomic, strong) UISearchController *searchController;
 @property (nonatomic, strong) UIView *reMenuBackgroundView;

+ 34 - 39
iOSClient/Main/CCMain.m

@@ -34,7 +34,7 @@
 #import "NCNetworkingEndToEnd.h"
 #import "PKDownloadButton.h"
 
-@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, NCSelectDelegate, UITextFieldDelegate>
+@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, NCSelectDelegate, UITextFieldDelegate, UIAdaptivePresentationControllerDelegate>
 {
     AppDelegate *appDelegate;
         
@@ -70,9 +70,7 @@
     
     // Folder
     BOOL _loadingFolder;
-    tableMetadata *_metadataFolder;
-    
-    NSString *richWorkspace;
+    tableMetadata *_metadataFolder;    
 }
 @end
 
@@ -195,6 +193,10 @@
     // Get Shares
     appDelegate.shares = [[NCManageDatabase sharedInstance] getTableSharesWithAccount:appDelegate.activeAccount serverUrl:self.serverUrl];
     
+    // Get RichWorkspace
+    tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
+    self.richWorkspace = directory.richWorkspace;
+    
     // Query data source
     if (self.searchController.isActive == false) {
         [self queryDatasourceWithReloadData:YES serverUrl:self.serverUrl];
@@ -265,10 +267,16 @@
             // Landscape
         }
         
+        [self setTableViewHeader];
         [self.tableView reloadData];
     }];
 }
 
+- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController
+{
+    [self viewDidAppear:true];
+}
+
 - (BOOL)prefersStatusBarHidden
 {
     return NO;
@@ -297,6 +305,7 @@
     // color searchbar
     self.searchController.searchBar.barTintColor = NCBrandColor.sharedInstance.brand;
     self.searchController.searchBar.backgroundColor = NCBrandColor.sharedInstance.brand;
+    self.view.backgroundColor = NCBrandColor.sharedInstance.brand;
     // color searchbbar button text (cancel)
     UIButton *searchButton = self.searchController.searchBar.subviews.firstObject.subviews.lastObject;
     if (searchButton && [searchButton isKindOfClass:[UIButton class]]) {
@@ -1111,6 +1120,11 @@
     if (!_serverUrl || !appDelegate.activeAccount || appDelegate.maintenanceMode)
         return;
     
+    // RichWorkspace
+    tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
+    self.richWorkspace = directory.richWorkspace;
+    [self setTableViewHeader];
+    
     // Load Datasource
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
         [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
@@ -1120,14 +1134,13 @@
           
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
-            tableMetadata *metadataFolder;
+            tableMetadata *metadataFolder = [tableMetadata new];
             (void)[[NCNetworking sharedInstance] convertFiles:files urlString:appDelegate.activeUrl serverUrl:self.serverUrl user:appDelegate.activeUser metadataFolder:&metadataFolder];
             
             // Rich Workspace
-            if (metadataFolder != nil) {
-                [[NCManageDatabase sharedInstance] setDirectoryWithOcId:metadataFolder.ocId serverUrl:self.serverUrl richWorkspace:metadataFolder.richWorkspace account:account];
-                [self setTableViewHeader];
-            }
+            [[NCManageDatabase sharedInstance] setDirectoryWithOcId:metadataFolder.ocId serverUrl:self.serverUrl richWorkspace:metadataFolder.richWorkspace account:account];
+            self.richWorkspace = metadataFolder.richWorkspace;
+            [self setTableViewHeader];
             
             tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, metadataFolder.serverUrl]];
             
@@ -1306,8 +1319,8 @@
             searchTextView.textColor = NCBrandColor.sharedInstance.textView;
         }
         
-        self.tableView.tableHeaderView = self.searchController.searchBar;
-        [self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height - self.tableView.contentOffset.y)];
+        //self.tableView.tableHeaderView = self.searchController.searchBar;
+        //[self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height - self.tableView.contentOffset.y)];
         
     } else {
         
@@ -1939,13 +1952,10 @@
 
 - (void)viewRichWorkspaceTapAction:(UITapGestureRecognizer *)tapGesture
 {
-   tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
-    
     UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCViewerRichWorkspace" bundle:nil] instantiateInitialViewController];
     NCViewerRichWorkspace *viewerRichWorkspace = (NCViewerRichWorkspace *)[navigationController topViewController];
-    viewerRichWorkspace.richWorkspace = directory.richWorkspace;
+    viewerRichWorkspace.richWorkspace = self.richWorkspace;
     viewerRichWorkspace.serverUrl = self.serverUrl;
-    viewerRichWorkspace.titleCloseItem = NSLocalizedString(@"_back_", nil);
     
     navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
     
@@ -1954,25 +1964,13 @@
 
 - (void)createRichWorkspace
 {
+    NCRichWorkspaceTextCommon *richWorkspaceTextCommon = [NCRichWorkspaceTextCommon new];
     tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, self.serverUrl, k_fileNameRichWorkspace.lowercaseString]];
-    if (metadata && [[NCUtility sharedInstance] isDirectEditing:metadata]) {
-        if (appDelegate.reachability.isReachable) {
-            [self shouldPerformSegue:metadata selector:@""];
-        } else {
-            [[NCContentPresenter shared] messageNotification:@"_info_" description:@"_go_online_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:0];
-        }
-    } else if (metadata == nil) {
-        NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:k_fileNameRichWorkspace serverUrl:self.serverUrl activeUrl:appDelegate.activeUrl];
-        [[NCCommunication sharedInstance] NCTextCreateFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor:@"text" templateId:@"" account:appDelegate.activeAccount completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
-            if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-                tableMetadata *metadata = [CCUtility createMetadataWithAccount:appDelegate.activeAccount date:[NSDate date] directory:false ocId:[CCUtility createRandomString:12] serverUrl:self.serverUrl fileName:k_fileNameRichWorkspace etag:@"" size:0 status:k_metadataStatusNormal url:url contentType:@"text/markdown"];
-                [self shouldPerformSegue:metadata selector:@""];
-            } 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.");
-            }
-        }];
+    
+    if (metadata) {
+        [richWorkspaceTextCommon openViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
+    } else {
+        [richWorkspaceTextCommon createViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
     }
 }
 
@@ -2200,7 +2198,6 @@
     //NSString *groupBy = [CCUtility getGroupBySettings];
     NSString *sorted = [CCUtility getOrderSettings];
     BOOL ascending = [CCUtility getAscendingSettings];
-    tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
     
     // ITEM SELECT ----------------------------------------------------------------------------------------------------
@@ -2321,7 +2318,7 @@
                                  
     // REMENU --------------------------------------------------------------------------------------------------------------
 
-    if (capabilities.versionMajor >= k_nextcloud_version_18_0 && directory.richWorkspace.length == 0) {
+    if (capabilities.versionMajor >= k_nextcloud_version_18_0 && self.richWorkspace.length == 0) {
         appDelegate.reMainMenu = [[REMenu alloc] initWithItems:@[appDelegate.selezionaItem, appDelegate.sortFileNameAZItem, appDelegate.sortFileNameZAItem, appDelegate.sortDateMoreRecentItem, appDelegate.sortDateLessRecentItem, appDelegate.sortSmallestItem, appDelegate.sortLargestItem, appDelegate.directoryOnTopItem, appDelegate.addFolderInfo]];
     } else {
         appDelegate.reMainMenu = [[REMenu alloc] initWithItems:@[appDelegate.selezionaItem, appDelegate.sortFileNameAZItem, appDelegate.sortFileNameZAItem, appDelegate.sortDateMoreRecentItem, appDelegate.sortDateLessRecentItem, appDelegate.sortSmallestItem, appDelegate.sortLargestItem, appDelegate.directoryOnTopItem]];
@@ -3864,15 +3861,13 @@
         
     } else {
     
-        tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
-        
-        if (directory.richWorkspace.length == 0) {
+        if (self.richWorkspace.length == 0) {
             
             [self.tableView setTableHeaderView:nil];
             
         } else {
             
-            [self.viewRichWorkspace setRichWorkspaceText:directory.richWorkspace gradient:true];
+            [self.viewRichWorkspace setRichWorkspaceText:self.richWorkspace gradient:true];
             [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, height)];
             [self.tableView setTableHeaderView:self.viewRichWorkspace];
         }

+ 4 - 12
iOSClient/Main/CCMore.swift

@@ -58,7 +58,6 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         tableView.delegate = self
         tableView.dataSource = self
         
-        themingBackground.image = #imageLiteral(resourceName: "themingBackground")
         self.navigationItem.title = NSLocalizedString("_more_", comment: "")
         
         // create tap gesture recognizer
@@ -193,18 +192,11 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         self.view.backgroundColor = NCBrandColor.sharedInstance.brand
         viewQuota.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
         progressQuota.progressTintColor = NCBrandColor.sharedInstance.brandElement
+        themingBackground.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
+            
+        labelUsername.textColor = NCBrandColor.sharedInstance.textView
         
-        let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-themingBackground.png"
-        
-        if let theminBackgroundFile = UIImage.init(contentsOfFile: fileNamePath) {
-            themingBackground.image = theminBackgroundFile
-        } else {
-            themingBackground.image = #imageLiteral(resourceName: "themingBackground")
-        }
-        
-        labelUsername.textColor = NCBrandColor.sharedInstance.brandText
-        
-        disclosureIndicator.image = CCGraphics.changeThemingColorImage(disclosureIndicator.image, width: 48, height: 52, color: NCBrandColor.sharedInstance.brandText)        
+        disclosureIndicator.image = CCGraphics.changeThemingColorImage(disclosureIndicator.image, width: 48, height: 52, color: NCBrandColor.sharedInstance.textView)
     }
     
     @objc func changeUserProfile() {

+ 5 - 5
iOSClient/Main/Main.storyboard

@@ -162,7 +162,7 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" tag="999" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
-                                <rect key="frame" x="95.5" y="369.5" width="223" height="157.5"/>
+                                <rect key="frame" x="-16" y="290.5" width="446" height="315"/>
                             </imageView>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -466,7 +466,7 @@
                                 </constraints>
                             </imageView>
                             <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="disclosureIndicator" translatesAutoresizingMaskIntoConstraints="NO" id="Lgd-72-bTD">
-                                <rect key="frame" x="381" y="115" width="24" height="26"/>
+                                <rect key="frame" x="381" y="125" width="24" height="26"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="26" id="9SQ-KV-aJa"/>
                                     <constraint firstAttribute="width" constant="24" id="KBe-Dy-an6"/>
@@ -517,7 +517,7 @@
                                 </connections>
                             </tableView>
                             <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="oJg-wO-2iv" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
-                                <rect key="frame" x="15" y="103" width="50" height="50"/>
+                                <rect key="frame" x="15" y="113" width="50" height="50"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="50" id="moA-ZW-N2y"/>
                                     <constraint firstAttribute="height" constant="50" id="nQ1-8m-5h7"/>
@@ -532,7 +532,7 @@
                                 </userDefinedRuntimeAttributes>
                             </imageView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="username" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aqE-Wq-B1A">
-                                <rect key="frame" x="78" y="118" width="78" height="20"/>
+                                <rect key="frame" x="78" y="128" width="78" height="20"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
                                 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <nil key="highlightedColor"/>
@@ -584,8 +584,8 @@
                         <constraints>
                             <constraint firstItem="aKC-5k-tLM" firstAttribute="trailing" secondItem="hLP-ql-OiA" secondAttribute="trailing" id="09d-e0-Lbe"/>
                             <constraint firstItem="Lgd-72-bTD" firstAttribute="centerY" secondItem="oJg-wO-2iv" secondAttribute="centerY" id="Aiq-NC-J8Z"/>
+                            <constraint firstItem="oJg-wO-2iv" firstAttribute="centerY" secondItem="qW6-AL-KO3" secondAttribute="centerY" id="HRF-rA-WKN"/>
                             <constraint firstItem="qW6-AL-KO3" firstAttribute="trailing" secondItem="hLP-ql-OiA" secondAttribute="trailing" id="IHF-zg-7RG"/>
-                            <constraint firstItem="aKC-5k-tLM" firstAttribute="top" secondItem="oJg-wO-2iv" secondAttribute="bottom" constant="35" id="Nxn-t4-ybx"/>
                             <constraint firstItem="qW6-AL-KO3" firstAttribute="leading" secondItem="hLP-ql-OiA" secondAttribute="leading" id="Nyf-TZ-gLf"/>
                             <constraint firstItem="aKC-5k-tLM" firstAttribute="leading" secondItem="hLP-ql-OiA" secondAttribute="leading" id="VDo-ak-TEq"/>
                             <constraint firstItem="2rd-9k-q51" firstAttribute="bottom" secondItem="J2k-UZ-XQQ" secondAttribute="bottom" id="bRS-IM-13l"/>

+ 9 - 18
iOSClient/Main/NCMainCommon.swift

@@ -24,6 +24,7 @@
 import Foundation
 import TLPhotoPicker
 import ZIPFoundation
+import NCCommunication
 
 //MARK: - Main Common
 
@@ -347,16 +348,11 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                 } else if FileManager.default.fileExists(atPath: fileNameSource) {
                     cell.shared.image = NCUtility.sharedInstance.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                 } else {
-                    let url = appDelegate.activeUrl + k_avatar + metadata.ownerId + "/" + k_avatar_size
-                    let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                    OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                        if errorCode == 0 {
-                            do {
-                                try data!.write(to: NSURL(fileURLWithPath: fileNameSource) as URL, options: .atomic)
-                                cell.shared.image = NCUtility.sharedInstance.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
-                            } catch {  }
+                    NCCommunication.sharedInstance.downloadAvatar(urlString: appDelegate.activeUrl, userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size), account: appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                        if errorCode == 0 && account == self.appDelegate.activeAccount {
+                            cell.shared.image = NCUtility.sharedInstance.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                         }
-                    })
+                    }
                 }
             }
             
@@ -672,16 +668,11 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                         cell.shared.image = avatar
                     }
                 } else {
-                    let url = appDelegate.activeUrl + k_avatar + metadata.ownerId + "/" + k_avatar_size
-                    let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                    OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                        if errorCode == 0 {
-                            do {
-                                try data!.write(to: NSURL(fileURLWithPath: fileNameSource) as URL, options: .atomic)
-                                 cell.shared.image = NCUtility.sharedInstance.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
-                            } catch {  }
+                    NCCommunication.sharedInstance.downloadAvatar(urlString: appDelegate.activeUrl, userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size), account: appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                        if errorCode == 0 && account == self.appDelegate.activeAccount {
+                            cell.shared.image = NCUtility.sharedInstance.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
                         }
-                    })
+                    }
                 }
             }
             

+ 17 - 6
iOSClient/Networking/NCService.swift

@@ -80,6 +80,17 @@ class NCService: NSObject {
                     let avatarUrl = "\(self.appDelegate.activeUrl!)/index.php/avatar/\(self.appDelegate.activeUser!)/\(k_avatar_size)".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
                     let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(user, activeUrl: url) + "-" + self.appDelegate.activeUser + ".png"
                     
+                    NCCommunication.sharedInstance.downloadContent(urlString: avatarUrl, account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                        if errorCode == 0 {
+                            if let image = UIImage(data: data!) {
+                                try? FileManager.default.removeItem(atPath: fileNamePath)
+                                if let data = image.pngData() {
+                                    try? data.write(to: URL(fileURLWithPath: fileNamePath))
+                                }
+                            }
+                        }
+                    }
+                    /*
                     OCNetworking.sharedManager()?.downloadContents(ofUrl: avatarUrl, completion: { (data, message, errorCode) in
                         if errorCode == 0 {
                             if let image = UIImage(data: data!) {
@@ -90,6 +101,7 @@ class NCService: NSObject {
                             }
                         }
                     })
+                    */
                     
                     DispatchQueue.main.async {
                         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeUserProfile"), object: nil)
@@ -148,14 +160,14 @@ class NCService: NSObject {
                         // Download Logo
                         if NCBrandOptions.sharedInstance.use_themingLogo {
                             let fileNameThemingLogo = CCUtility.getStringUser(self.appDelegate.activeUser, activeUrl: self.appDelegate.activeUrl) + "-themingLogo.png"
-                            NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: capabilities!.themingLogo, fileName: fileNameThemingLogo, width: 40, rewrite: true, closure: { (imageNamePath) in })
+                            NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: capabilities!.themingLogo, fileName: fileNameThemingLogo, width: 40, rewrite: true, account: self.appDelegate.activeAccount, closure: { (imageNamePath) in })
                         }
                         
                         let backgroundURL = capabilities!.themingBackground!.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
                         let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(self.appDelegate.activeUser, activeUrl: self.appDelegate.activeUrl) + "-themingBackground.png"
                         
-                        OCNetworking.sharedManager()?.downloadContents(ofUrl: backgroundURL, completion: { (data, message, errorCode) in
-                            if errorCode == 0 {
+                        NCCommunication.sharedInstance.downloadContent(urlString: backgroundURL, account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                            if errorCode == 0 && account == self.appDelegate.activeAccount {
                                 if let image = UIImage(data: data!) {
                                     try? FileManager.default.removeItem(atPath: fileNamePath)
                                     if let data = image.pngData() {
@@ -163,8 +175,7 @@ class NCService: NSObject {
                                     }
                                 }
                             }
-                        })
-                        
+                        }
                         DispatchQueue.main.async {
                             self.appDelegate.settingThemingColorBrand()
                         }
@@ -204,7 +215,7 @@ class NCService: NSObject {
                                     let id = (notification as! OCNotifications).idNotification
                                     if let icon = (notification as! OCNotifications).icon {
                                         
-                                        NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: icon, fileName: nil, width: 25, rewrite: false, closure: { (imageNamePath) in })                                        
+                                        NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: icon, fileName: nil, width: 25, rewrite: false, account: self.appDelegate.activeAccount, closure: { (imageNamePath) in })                                        
                                     }
                                     new = new + String(describing: id)
                                 }

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -39,7 +39,7 @@
 
 - (void)checkServerUrl:(NSString *)serverUrl user:(NSString *)user userID:(NSString *)userID password:(NSString *)password completion:(void (^)(NSString *message, NSInteger errorCode))completion;
 //- (void)serverStatusUrl:(NSString *)serverUrl completion:(void(^)(NSString *serverProductName, NSInteger versionMajor, NSInteger versionMicro, NSInteger versionMinor, BOOL extendedSupport, NSString *message, NSInteger errorCode))completion;
-- (void)downloadContentsOfUrl:(NSString *)serverUrl completion:(void(^)(NSData *data, NSString *message, NSInteger errorCode))completion;
+//- (void)downloadContentsOfUrl:(NSString *)serverUrl completion:(void(^)(NSData *data, NSString *message, NSInteger errorCode))completion;
 - (void)getAppPassword:(NSString *)serverUrl username:(NSString *)username password:(NSString *)password completion:(void(^)(NSString *token, NSString *message, NSInteger errorCode))completion;
 
 #pragma mark ===== Download / Upload =====

+ 2 - 1
iOSClient/Networking/OCNetworking.m

@@ -231,7 +231,7 @@
     [task resume];
 }
 */
-
+/*
 - (void)downloadContentsOfUrl:(NSString *)serverUrl completion:(void(^)(NSData *data, NSString *message, NSInteger errorCode))completion
 {
     // Remove stored cookies
@@ -276,6 +276,7 @@
     
     [task resume];
 }
+*/
 
 - (void)getAppPassword:(NSString *)serverUrl username:(NSString *)username password:(NSString *)password completion:(void(^)(NSString *token, NSString *message, NSInteger errorCode))completion
 {

+ 9 - 13
iOSClient/Notification/CCNotification.swift

@@ -22,6 +22,7 @@
 //
 
 import UIKit
+import NCCommunication
 
 class CCNotification: UITableViewController, CCNotificationCelllDelegate {
     
@@ -109,20 +110,15 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate {
                         }
                     } else {
                         DispatchQueue.global().async {
-                            let url = self.appDelegate.activeUrl + k_avatar + name + "/" + k_avatar_size
-                            let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                            OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                                if errorCode == 0 && UIImage(data: data!) != nil  {
-                                    do {
-                                        try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                                        if let image = UIImage(contentsOfFile: fileNameLocalPath) {
-                                            cell.avatar.isHidden = false
-                                            cell.avatarLeadingMargin.constant = 50
-                                            cell.avatar.image = image
-                                        }
-                                    } catch { return }
+                            NCCommunication.sharedInstance.downloadAvatar(urlString: self.appDelegate.activeUrl, userID: name, fileNameLocalPath: fileNameLocalPath, size: Int(k_avatar_size), account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                                if errorCode == 0 && account == self.appDelegate.activeAccount && UIImage(data: data!) != nil {
+                                    if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                                        cell.avatar.isHidden = false
+                                        cell.avatarLeadingMargin.constant = 50
+                                        cell.avatar.image = image
+                                    }
                                 }
-                            })
+                            }
                         }
                     }
                 }

+ 5 - 1
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -106,7 +106,11 @@ import SwiftRichString
             
             gradientLayer.removeFromSuperlayer()
             gradientLayer.frame = CGRect(x: 0.0, y: 0.0, width: self.frame.width, height: self.frame.height)
-            gradientLayer.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
+            if CCUtility.getDarkMode() {
+                gradientLayer.colors = [UIColor.init(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
+            } else {
+                gradientLayer.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
+            }
             gradientLayer.startPoint = CGPoint(x: 0, y: 0.60)
             gradientLayer.endPoint = CGPoint(x: 0, y: 1)
             textView.layer.addSublayer(gradientLayer)

+ 1 - 1
iOSClient/RichWorkspace/NCRichWorkspace.xib

@@ -14,7 +14,7 @@
             <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wri-16-tQY">
+                <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wri-16-tQY">
                     <rect key="frame" x="15" y="5" width="295" height="470"/>
                     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>

+ 110 - 0
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -0,0 +1,110 @@
+//
+//  NCRichWorkspaceCommon.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 17/01/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
+import NCCommunication
+
+@objc class NCRichWorkspaceTextCommon: NSObject {
+
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+    @objc func createViewerNextcloudText(serverUrl: String,viewController: UIViewController) {
+        
+        if !appDelegate.reachability.isReachable() {
+            
+            NCContentPresenter.shared.messageNotification("_error_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: 0)
+            return;
+        }
+        
+        NCUtility.sharedInstance.startActivityIndicator(view: viewController.view, bottom: 0)
+        
+        let fileNamePath = CCUtility.returnFileNamePath(fromFileName: k_fileNameRichWorkspace, serverUrl: serverUrl, activeUrl: appDelegate.activeUrl)!
+        NCCommunication.sharedInstance.NCTextCreateFile(urlString: appDelegate.activeUrl, fileNamePath: fileNamePath, editor: "text", templateId: "", account: appDelegate.activeAccount) { (account, url, errorCode, errorMessage) in
+            
+            NCUtility.sharedInstance.stopActivityIndicator()
+            
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
+                
+                if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                    
+                    viewerRichWorkSpaceText.url = url!
+                    viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                    
+                    viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                }
+                
+            } else if errorCode != 0 {
+                NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: errorCode)
+            }
+        }
+    }
+    
+    @objc func openViewerNextcloudText(serverUrl: String, viewController: UIViewController) {
+        
+        if !appDelegate.reachability.isReachable() {
+            
+            NCContentPresenter.shared.messageNotification("_error_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: 0)
+            return;
+        }
+        
+        if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, serverUrl, k_fileNameRichWorkspace.lowercased())) {
+            
+            if metadata.url == "" {
+                
+                NCUtility.sharedInstance.startActivityIndicator(view: viewController.view, bottom: 0)
+                
+                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
+                NCCommunication.sharedInstance.NCTextOpenFile(urlString: appDelegate.activeUrl, fileNamePath: fileNamePath, editor: "text", account: appDelegate.activeAccount) { (account, url, errorCode, errorMessage) in
+                    
+                    NCUtility.sharedInstance.stopActivityIndicator()
+                    
+                    if errorCode == 0 && account == self.appDelegate.activeAccount {
+                        
+                        if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                            
+                            viewerRichWorkSpaceText.url = url!
+                            viewerRichWorkSpaceText.metadata = metadata
+                            viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                            
+                            viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                        }
+                        
+                    } else if errorCode != 0 {
+                        NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: errorCode)
+                    }
+                }
+                
+            } else {
+                
+                if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                    
+                    viewerRichWorkSpaceText.url = metadata.url
+                    viewerRichWorkSpaceText.metadata = metadata
+                    viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                    
+                    viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                }
+            }
+        }
+    }
+}

+ 17 - 11
iOSClient/RichWorkspace/NCViewerNextcloudText.swift → iOSClient/RichWorkspace/NCViewerRichWorkSpaceNextcloudText.swift

@@ -1,5 +1,5 @@
 //
-//  NCViewerNextcloudText.swift
+//  NCViewerRichWorkSpaceNextcloudText.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 12/12/19.
@@ -23,12 +23,13 @@
 
 import Foundation
 
-class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
+class NCViewerRichWorkSpaceNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
     
     @IBOutlet weak var webView: WKWebView!
+    @IBOutlet weak var webViewBottomConstraint: NSLayoutConstraint!
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    @objc var metadata: tableMetadata!
+    @objc var metadata: tableMetadata?
     @objc var url: String = ""
 
     override func viewDidLoad() {
@@ -51,17 +52,18 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     }
     
     @objc func keyboardDidShow(notification: Notification) {
-        /*
+        var safeAreaInsetsBottom: CGFloat = 0
+        if #available(iOS 11.0, *) {
+            safeAreaInsetsBottom = UIApplication.shared.keyWindow!.safeAreaInsets.bottom
+        }
         guard let info = notification.userInfo else { return }
         guard let frameInfo = info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
         let keyboardFrame = frameInfo.cgRectValue
-        //print("keyboardFrame: \(keyboardFrame)")
-        frame.size.height = detail.view.bounds.height - keyboardFrame.size.height
-        */
+        webViewBottomConstraint.constant = keyboardFrame.size.height - safeAreaInsetsBottom
     }
     
     @objc func keyboardWillHide(notification: Notification) {
-        //frame = detail.view.bounds
+        webViewBottomConstraint.constant = 0
     }
     
     //MARK: -
@@ -72,11 +74,16 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
             
             if message.body as? String == "close" {
                 
-                dismiss(animated: true, completion: nil)
+                if #available(iOS 13.0, *) {
+                    self.presentationController?.delegate?.presentationControllerWillDismiss?(self.presentationController!)
+                }
+                dismiss(animated: true)
             }
             
             if message.body as? String == "share" {
-                NCMainCommon.sharedInstance.openShare(ViewController: self, metadata: metadata, indexPage: 2)
+                if (metadata != nil) {
+                     NCMainCommon.sharedInstance.openShare(ViewController: self, metadata: metadata!, indexPage: 2)
+                }
             }
             
             if message.body as? String == "loading" {
@@ -93,7 +100,6 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
         }
     }
         
-    
     //MARK: -
 
     public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {

+ 7 - 21
iOSClient/RichWorkspace/NCViewerRichWorkspace.storyboard

@@ -16,22 +16,11 @@
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PhD-q3-64a">
-                                <rect key="frame" x="0.0" y="813" width="414" height="49"/>
-                                <items>
-                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="mbx-my-iUr"/>
-                                    <barButtonItem title="Item" id="Hvx-vk-mTM">
-                                        <connections>
-                                            <action selector="editItemAction:" destination="6oU-Ar-6R2" id="Y6f-gQ-0vW"/>
-                                        </connections>
-                                    </barButtonItem>
-                                </items>
-                            </toolbar>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZTH-4c-how" customClass="NCViewRichWorkspace" customModule="Nextcloud" customModuleProvider="target">
-                                <rect key="frame" x="0.0" y="88" width="414" height="725"/>
+                                <rect key="frame" x="0.0" y="88" width="414" height="774"/>
                                 <subviews>
                                     <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="tWU-uH-OcN">
-                                        <rect key="frame" x="15" y="5" width="389" height="720"/>
+                                        <rect key="frame" x="15" y="5" width="389" height="769"/>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
                                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -40,10 +29,10 @@
                                 </subviews>
                                 <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                                 <constraints>
+                                    <constraint firstAttribute="bottom" secondItem="tWU-uH-OcN" secondAttribute="bottom" id="0JY-Sv-nGd"/>
                                     <constraint firstItem="tWU-uH-OcN" firstAttribute="leading" secondItem="ZTH-4c-how" secondAttribute="leading" constant="15" id="Etf-Ey-64j"/>
                                     <constraint firstAttribute="trailing" secondItem="tWU-uH-OcN" secondAttribute="trailing" constant="10" id="b6f-DP-hJI"/>
                                     <constraint firstItem="tWU-uH-OcN" firstAttribute="top" secondItem="ZTH-4c-how" secondAttribute="top" constant="5" id="d81-lI-ub5"/>
-                                    <constraint firstAttribute="bottom" secondItem="tWU-uH-OcN" secondAttribute="bottom" id="v0G-Wp-3yv"/>
                                 </constraints>
                                 <connections>
                                     <outlet property="textView" destination="tWU-uH-OcN" id="kaU-Ye-UzC"/>
@@ -54,17 +43,13 @@
                         <constraints>
                             <constraint firstItem="ZTH-4c-how" firstAttribute="leading" secondItem="Isy-ab-db7" secondAttribute="leading" id="GN8-UG-8rE"/>
                             <constraint firstItem="ZTH-4c-how" firstAttribute="top" secondItem="Isy-ab-db7" secondAttribute="top" id="KgT-gT-3KV"/>
-                            <constraint firstItem="Isy-ab-db7" firstAttribute="bottom" secondItem="PhD-q3-64a" secondAttribute="bottom" id="Wg0-V3-osp"/>
-                            <constraint firstItem="PhD-q3-64a" firstAttribute="leading" secondItem="Isy-ab-db7" secondAttribute="leading" id="ZCg-As-Mj2"/>
-                            <constraint firstItem="Isy-ab-db7" firstAttribute="trailing" secondItem="PhD-q3-64a" secondAttribute="trailing" id="hlV-u7-OaC"/>
+                            <constraint firstItem="Isy-ab-db7" firstAttribute="bottom" secondItem="ZTH-4c-how" secondAttribute="bottom" id="qnK-fT-kwF"/>
                             <constraint firstItem="Isy-ab-db7" firstAttribute="trailing" secondItem="ZTH-4c-how" secondAttribute="trailing" id="xKM-8k-2Bn"/>
-                            <constraint firstItem="PhD-q3-64a" firstAttribute="top" secondItem="ZTH-4c-how" secondAttribute="bottom" id="xPd-wR-Fvh"/>
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="Isy-ab-db7"/>
                     </view>
                     <navigationItem key="navigationItem" id="YSS-NL-35O"/>
                     <connections>
-                        <outlet property="editItem" destination="Hvx-vk-mTM" id="KTx-5P-tI0"/>
                         <outlet property="viewRichWorkspace" destination="ZTH-4c-how" id="Tj4-ng-4pc"/>
                     </connections>
                 </viewController>
@@ -72,10 +57,10 @@
             </objects>
             <point key="canvasLocation" x="1013.0434782608696" y="23.4375"/>
         </scene>
-        <!--Viewer Nextcloud Text-->
+        <!--Viewer Rich Work Space Nextcloud Text-->
         <scene sceneID="FAF-zB-yaq">
             <objects>
-                <viewController storyboardIdentifier="NCViewerNextcloudText" id="Ces-GG-tAv" customClass="NCViewerNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="NCViewerRichWorkSpaceNextcloudText" id="Ces-GG-tAv" customClass="NCViewerRichWorkSpaceNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="T4r-I1-FJU">
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -100,6 +85,7 @@
                     </view>
                     <connections>
                         <outlet property="webView" destination="hsc-I0-5ib" id="xu8-Ll-srm"/>
+                        <outlet property="webViewBottomConstraint" destination="Hsc-5E-1br" id="Xpx-v3-vZA"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="o3L-2f-s1m" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

+ 30 - 40
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -24,22 +24,24 @@
 import Foundation
 import NCCommunication
 
-@objc class NCViewerRichWorkspace: UIViewController {
+@objc class NCViewerRichWorkspace: UIViewController, UIAdaptivePresentationControllerDelegate {
 
     @IBOutlet weak var viewRichWorkspace: NCViewRichWorkspace!
-    @IBOutlet weak var editItem: UIBarButtonItem!
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     @objc public var richWorkspace: String = ""
     @objc public var serverUrl: String = ""
-    @objc public var titleCloseItem: String = ""
    
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        let closeItem = UIBarButtonItem(title: titleCloseItem, style: .plain, target: self, action: #selector(closeItemTapped(_:)))
+        presentationController?.delegate = self
+        
+        let closeItem = UIBarButtonItem(title: NSLocalizedString("_back_", comment: ""), style: .plain, target: self, action: #selector(closeItemTapped(_:)))
         self.navigationItem.leftBarButtonItem = closeItem
-        editItem.image = UIImage(named: "actionSheetModify")
+                
+        let editItem = UIBarButtonItem(image: UIImage(named: "actionSheetModify"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(editItemAction(_:)))
+        self.navigationItem.rightBarButtonItem = editItem
 
         viewRichWorkspace.setRichWorkspaceText(richWorkspace, gradient: false)
         
@@ -47,6 +49,27 @@ import NCCommunication
         changeTheming()
     }
     
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        NCCommunication.sharedInstance.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", account: appDelegate.activeAccount) { (account, files, errorCode, errorMessage) in
+            
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
+                
+                var metadataFolder = tableMetadata()
+                _ = NCNetworking.sharedInstance.convertFiles(files!, urlString: self.appDelegate.activeUrl, serverUrl: self.serverUrl, user: self.appDelegate.activeUser, metadataFolder: &metadataFolder)
+                NCManageDatabase.sharedInstance.setDirectory(ocId: metadataFolder.ocId, serverUrl: metadataFolder.serverUrl, richWorkspace: metadataFolder.richWorkspace, account: account)
+                self.richWorkspace = metadataFolder.richWorkspace
+                self.appDelegate.activeMain.richWorkspace = self.richWorkspace
+                self.viewRichWorkspace.setRichWorkspaceText(self.richWorkspace, gradient: false)
+            }
+        }
+    }
+    
+    public func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
+        self.viewWillAppear(true)
+    }
+    
     @objc func changeTheming() {
         appDelegate.changeTheming(self, tableView: nil, collectionView: nil, form: false)
     }
@@ -57,40 +80,7 @@ import NCCommunication
     
     @IBAction func editItemAction(_ sender: Any) {
         
-        if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, serverUrl, k_fileNameRichWorkspace.lowercased())) {
-            
-            if metadata.url == "" {
-                NCUtility.sharedInstance.startActivityIndicator(view: self.view, bottom: 0)
-                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
-                NCCommunication.sharedInstance.NCTextOpenFile(urlString: appDelegate.activeUrl, fileNamePath: fileNamePath, editor: "text", account: appDelegate.activeAccount) { (account, url, errorCode, errorMessage) in
-                    
-                    NCUtility.sharedInstance.stopActivityIndicator()
-                    
-                    if errorCode == 0 && account == self.appDelegate.activeAccount {
-                        
-                        if let viewerNextcloudText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerNextcloudText") as? NCViewerNextcloudText {
-                            
-                            viewerNextcloudText.url = url!
-                            viewerNextcloudText.metadata = metadata
-                            
-                            self.present(viewerNextcloudText, animated: true, completion: nil)
-                        }
-                        
-                    } else if errorCode != 0 {
-                        NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: errorCode)
-                    }
-                }
-                
-            } else {
-                
-                if let viewerNextcloudText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerNextcloudText") as? NCViewerNextcloudText {
-                    
-                    viewerNextcloudText.url = metadata.url
-                    viewerNextcloudText.metadata = metadata
-                    
-                    self.present(viewerNextcloudText, animated: true, completion: nil)
-                }
-            }
-        }
+        let richWorkspaceTextCommon = NCRichWorkspaceTextCommon()
+        richWorkspaceTextCommon.openViewerNextcloudText(serverUrl: serverUrl, viewController: self)
     }
 }

+ 0 - 23
iOSClient/Settings/CCManageAccount.m

@@ -93,18 +93,6 @@
         section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_manage_account_", nil)];
         [form addFormSection:section];
         
-        // Modify Account
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"changePassword" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_change_password_", nil)];
-        row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
-        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-        [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"rename"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
-        [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-        [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
-
-        row.action.formSelector = @selector(changePassword:);
-        if (listAccount.count == 0) row.disabled = @YES;
-        [section addFormRow:row];
-        
         // Brand
         if ([NCBrandOptions sharedInstance].disable_multiaccount == NO) {
             
@@ -380,17 +368,6 @@
     [appDelegate openLoginView:self selector:k_intro_login openLoginWeb:false];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Modify Account ===
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)changePassword:(XLFormRowDescriptor *)sender
-{    
-    [self deselectFormRow:sender];
-    
-    [appDelegate openLoginView:self selector:k_intro_login openLoginWeb:true];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Delete Account  ===
 #pragma --------------------------------------------------------------------------------------------

+ 19 - 27
iOSClient/Share/NCShare.swift

@@ -24,6 +24,7 @@
 import Foundation
 import Parchment
 import DropDown
+import NCCommunication
 
 class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareUserCellDelegate, NCShareNetworkingDelegate {
    
@@ -81,18 +82,15 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) { sharedWithYouByImage.image = image }
             } else {
-                let url = appDelegate.activeUrl + k_avatar + metadata!.ownerId + "/" + k_avatar_size
-                let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                    if errorCode == 0 && UIImage(data: data!) != nil {
-                        do {
-                            try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                            if let image = UIImage(contentsOfFile: fileNameLocalPath) { self.sharedWithYouByImage.image = image }
-                        } catch { return }
+                NCCommunication.sharedInstance.downloadAvatar(urlString: appDelegate.activeUrl, userID: metadata!.ownerId, fileNameLocalPath: fileNameLocalPath, size: Int(k_avatar_size), account: appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                    if errorCode == 0 && account == self.appDelegate.activeAccount && UIImage(data: data!) != nil {
+                        if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                            self.sharedWithYouByImage.image = image
+                        }
                     } else {
                         self.sharedWithYouByImage.image = UIImage(named: "avatar")
                     }
-                })
+                }
             }
         } 
         
@@ -288,18 +286,15 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
             } else {
                 DispatchQueue.global().async {
-                    let url = self.appDelegate.activeUrl + k_avatar + item.name + "/" + k_avatar_size
-                    let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                    OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                        if errorCode == 0 && UIImage(data: data!) != nil {
-                            do {
-                                try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                                if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
-                            } catch { return }
+                    NCCommunication.sharedInstance.downloadAvatar(urlString: self.appDelegate.activeUrl, userID: item.name, fileNameLocalPath: fileNameLocalPath, size: Int(k_avatar_size), account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                        if errorCode == 0 && account == self.appDelegate.activeAccount && UIImage(data: data!) != nil {
+                            if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                                cell.imageItem.image = image
+                            }
                         } else {
                             cell.imageItem.image = UIImage(named: "avatar")
                         }
-                    })
+                    }
                 }
             }
 
@@ -383,18 +378,15 @@ extension NCShare: UITableViewDataSource {
                     if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
                 } else {
                     DispatchQueue.global().async {
-                        let url = self.appDelegate.activeUrl + k_avatar + tableShare.shareWith + "/" + k_avatar_size
-                        let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                        OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                            if errorCode == 0 && UIImage(data: data!) != nil {
-                                do {
-                                    try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                                    if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
-                                } catch { return }
+                        NCCommunication.sharedInstance.downloadAvatar(urlString: self.appDelegate.activeUrl, userID: tableShare.shareWith, fileNameLocalPath: fileNameLocalPath, size: Int(k_avatar_size), account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                            if errorCode == 0 && account == self.appDelegate.activeAccount && UIImage(data: data!) != nil {
+                                if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                                    cell.imageItem.image = image
+                                }
                             } else {
                                 cell.imageItem.image = UIImage(named: "avatar")
                             }
-                        })
+                        }
                     }
                 }
                 

+ 8 - 0
iOSClient/Share/NCShareComments.swift

@@ -23,6 +23,7 @@
 
 import Foundation
 import Sheeeeeeeeet
+import NCCommunication
 
 class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
    
@@ -242,6 +243,12 @@ extension NCShareComments: UITableViewDataSource {
                 if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
             } else {
                 DispatchQueue.global().async {
+                    NCCommunication.sharedInstance.downloadAvatar(urlString: self.appDelegate.activeUrl, userID: tableComments.actorId, fileNameLocalPath: fileNameLocalPath, size: 128, account: self.appDelegate.activeAccount) { (account, data, errorCode, errorMessage) in
+                        if errorCode == 0 && UIImage(data: data!) != nil {
+                            cell.imageItem.image = UIImage(named: "avatar")
+                        }
+                    }
+                    /*
                     let url = self.appDelegate.activeUrl + k_avatar + tableComments.actorId + "/" + k_avatar_size
                     let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                     OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
@@ -254,6 +261,7 @@ extension NCShareComments: UITableViewDataSource {
                             cell.imageItem.image = UIImage(named: "avatar")
                         }
                     })
+                    */
                 }
             }
             // Username

+ 21 - 23
iOSClient/Share/NCShareCommentsCell.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -15,7 +13,7 @@
             <rect key="frame" x="0.0" y="0.0" width="600" height="122"/>
             <autoresizingMask key="autoresizingMask"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qJF-Yc-gKE" id="3Oe-gU-3Nk">
-                <rect key="frame" x="0.0" y="0.0" width="600" height="121.5"/>
+                <rect key="frame" x="0.0" y="0.0" width="600" height="122"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
@@ -36,25 +34,14 @@
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="user" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="otH-mT-7Z4" userLabel="labelTitle">
                         <rect key="frame" x="55" y="26" width="28.5" height="18"/>
                         <constraints>
-                            <constraint firstAttribute="width" relation="lessThanOrEqual" constant="200" id="4Oa-yZ-HZK"/>
                             <constraint firstAttribute="height" constant="18" id="iet-xr-SX6"/>
                         </constraints>
                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
                         <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <nil key="highlightedColor"/>
                     </label>
-                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QXZ-ax-nlQ">
-                        <rect key="frame" x="470" y="26" width="120" height="18"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="18" id="WZK-ND-Vl1"/>
-                            <constraint firstAttribute="width" constant="120" id="guh-u2-aXB"/>
-                        </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                        <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                        <nil key="highlightedColor"/>
-                    </label>
                     <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J1z-RG-U4A" userLabel="ButtonMenu">
-                        <rect key="frame" x="93.5" y="25" width="20" height="20"/>
+                        <rect key="frame" x="557" y="25" width="20" height="20"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="20" id="G48-LB-BsD"/>
                             <constraint firstAttribute="width" constant="20" id="vLI-cJ-Jqx"/>
@@ -65,26 +52,37 @@
                         </connections>
                     </button>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="message" lineBreakMode="middleTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mNK-Zq-pFW" userLabel="labelTitle">
-                        <rect key="frame" x="55" y="63" width="540" height="43.5"/>
+                        <rect key="frame" x="55" y="71" width="540" height="36"/>
                         <constraints>
                             <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="15" id="tAu-Ct-G3J"/>
                         </constraints>
                         <fontDescription key="fontDescription" type="system" pointSize="14"/>
                         <nil key="highlightedColor"/>
                     </label>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="date" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QXZ-ax-nlQ">
+                        <rect key="frame" x="55" y="49" width="522" height="18"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="18" id="WZK-ND-Vl1"/>
+                        </constraints>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                        <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <nil key="highlightedColor"/>
+                    </label>
                 </subviews>
                 <constraints>
                     <constraint firstItem="mNK-Zq-pFW" firstAttribute="leading" secondItem="3Oe-gU-3Nk" secondAttribute="leading" constant="55" id="1mf-Ih-fHK"/>
-                    <constraint firstAttribute="trailing" secondItem="QXZ-ax-nlQ" secondAttribute="trailing" constant="10" id="2pt-ST-EIP"/>
-                    <constraint firstItem="J1z-RG-U4A" firstAttribute="leading" secondItem="otH-mT-7Z4" secondAttribute="trailing" constant="10" id="43r-67-Pxv"/>
+                    <constraint firstItem="QXZ-ax-nlQ" firstAttribute="leading" secondItem="qDs-UG-Mn7" secondAttribute="trailing" constant="10" id="3EJ-ah-pBt"/>
+                    <constraint firstItem="J1z-RG-U4A" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="otH-mT-7Z4" secondAttribute="trailing" constant="8" id="43r-67-Pxv"/>
                     <constraint firstItem="otH-mT-7Z4" firstAttribute="leading" secondItem="qDs-UG-Mn7" secondAttribute="trailing" constant="10" id="7o5-Rj-6lV"/>
                     <constraint firstAttribute="trailing" secondItem="mNK-Zq-pFW" secondAttribute="trailing" constant="5" id="A2t-sl-Uer"/>
-                    <constraint firstItem="QXZ-ax-nlQ" firstAttribute="centerY" secondItem="qDs-UG-Mn7" secondAttribute="centerY" id="DzK-Ps-SiV"/>
                     <constraint firstItem="qDs-UG-Mn7" firstAttribute="top" secondItem="3Oe-gU-3Nk" secondAttribute="top" constant="15" id="FAO-D8-MXo"/>
                     <constraint firstAttribute="bottom" secondItem="mNK-Zq-pFW" secondAttribute="bottom" constant="15" id="H9H-lE-Gg1"/>
+                    <constraint firstItem="mNK-Zq-pFW" firstAttribute="top" secondItem="QXZ-ax-nlQ" secondAttribute="bottom" constant="4" id="KDw-qu-iO6"/>
                     <constraint firstItem="otH-mT-7Z4" firstAttribute="centerY" secondItem="qDs-UG-Mn7" secondAttribute="centerY" id="KO4-0R-wdL" userLabel="labelTitle.centerY = ImageItem.centerY"/>
                     <constraint firstItem="qDs-UG-Mn7" firstAttribute="leading" secondItem="3Oe-gU-3Nk" secondAttribute="leading" constant="5" id="KOm-wo-CBa"/>
-                    <constraint firstItem="mNK-Zq-pFW" firstAttribute="top" secondItem="qDs-UG-Mn7" secondAttribute="bottom" constant="8" id="ndh-x5-eXA"/>
+                    <constraint firstAttribute="trailingMargin" secondItem="QXZ-ax-nlQ" secondAttribute="trailing" constant="8" id="Pku-hg-qKn"/>
+                    <constraint firstAttribute="trailingMargin" secondItem="J1z-RG-U4A" secondAttribute="trailing" constant="8" id="SgR-6b-z2c"/>
+                    <constraint firstItem="QXZ-ax-nlQ" firstAttribute="top" secondItem="J1z-RG-U4A" secondAttribute="bottom" constant="4" id="qj4-34-HW3"/>
                     <constraint firstItem="J1z-RG-U4A" firstAttribute="centerY" secondItem="qDs-UG-Mn7" secondAttribute="centerY" id="tIg-bm-Clb"/>
                 </constraints>
             </tableViewCellContentView>

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


BIN
iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings


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


BIN
iOSClient/Supporting Files/es-DO.lproj/Localizable.strings


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


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


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


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


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


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


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


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


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


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


BIN
iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings


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


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


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


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


BIN
iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings


+ 6 - 5
iOSClient/Utility/NCUtility.swift

@@ -26,6 +26,7 @@ import SVGKit
 import KTVHTTPCache
 import ZIPFoundation
 import Sheeeeeeeeet
+import NCCommunication
 
 class NCUtility: NSObject {
     @objc static let sharedInstance: NCUtility = {
@@ -177,7 +178,7 @@ class NCUtility: NSObject {
     }
     
     
-    func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, closure: @escaping (String?) -> ()) {
+    func convertSVGtoPNGWriteToUserData(svgUrlString: String, fileName: String?, width: CGFloat?, rewrite: Bool, account: String, closure: @escaping (String?) -> ()) {
         
         var fileNamePNG = ""
         
@@ -198,8 +199,8 @@ class NCUtility: NSObject {
         
         if !FileManager.default.fileExists(atPath: imageNamePath) || rewrite == true {
             
-            OCNetworking.sharedManager()?.downloadContents(ofUrl: iconURL.absoluteString, completion: { (data, message, errorCode) in
-                
+            NCCommunication.sharedInstance.downloadContent(urlString: iconURL.absoluteString, account: account) { (account, data, errorCode, errorMessage) in
+               
                 if errorCode == 0 && data != nil {
                 
                     if let image = UIImage.init(data: data!) {
@@ -253,7 +254,7 @@ class NCUtility: NSObject {
                 } else {
                     return closure(nil)
                 }
-            })
+            }
             
         } else {
             return closure(imageNamePath)
@@ -432,7 +433,7 @@ class NCUtility: NSObject {
     @objc func createAvatar(fileNameSource: String, fileNameSourceAvatar: String) -> UIImage? {
         
         guard let imageSource = UIImage(contentsOfFile: fileNameSource) else { return nil }
-        let size = Int(k_avatar_size) ?? 128
+        let size = Int(k_avatar_size)
         
         UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, 0)
         imageSource.draw(in: CGRect(x: 0, y: 0, width: size, height: size))

+ 137 - 0
iOSClient/Viewer/NCViewerNextcloudText.swift

@@ -0,0 +1,137 @@
+//
+//  NCViewerNextcloudText.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 12/12/19.
+//  Copyright © 2019 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
+
+class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHandler {
+    
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    var detail: CCDetail!
+    @objc var metadata: tableMetadata!
+    var documentInteractionController: UIDocumentInteractionController!
+   
+    override init(frame: CGRect, configuration: WKWebViewConfiguration) {
+        super.init(frame: frame, configuration: configuration)
+
+        let contentController = configuration.userContentController
+        contentController.add(self, name: "DirectEditingMobileInterface")
+        
+        autoresizingMask = [.flexibleWidth, .flexibleHeight]
+        navigationDelegate = self
+    }
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+    }
+    
+    @objc func viewerAt(_ link: String, detail: CCDetail, metadata: tableMetadata) {
+        
+        self.detail = detail
+        self.metadata = metadata
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
+        
+        if (UIDevice.current.userInterfaceIdiom == .phone) {
+            detail.navigationController?.setNavigationBarHidden(true, animated: false)
+        }
+        
+        var request = URLRequest(url: URL(string: link)!)
+        request.addValue("true", forHTTPHeaderField: "OCS-APIRequest")
+        let language = NSLocale.preferredLanguages[0] as String
+        request.addValue(language, forHTTPHeaderField: "Accept-Language")
+        
+        let userAgent : String = CCUtility.getUserAgent()
+        customUserAgent = userAgent
+        load(request)        
+    }
+    
+    @objc func keyboardDidShow(notification: Notification) {
+        guard let info = notification.userInfo else { return }
+        guard let frameInfo = info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
+        let keyboardFrame = frameInfo.cgRectValue
+        //print("keyboardFrame: \(keyboardFrame)")
+        frame.size.height = detail.view.bounds.height - keyboardFrame.size.height
+    }
+    
+    @objc func keyboardWillHide(notification: Notification) {
+        frame = detail.view.bounds
+    }
+    
+    //MARK: -
+
+    public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
+        
+        if (message.name == "DirectEditingMobileInterface") {
+            
+            if message.body as? String == "close" {
+                
+                removeFromSuperview()
+                
+                detail.navigationController?.popViewController(animated: true)
+                detail.navigationController?.navigationBar.topItem?.title = ""
+                
+                appDelegate.activeMain.readFileReloadFolder()
+            }
+            
+            if message.body as? String == "share" {
+                NCMainCommon.sharedInstance.openShare(ViewController: detail, metadata: metadata, indexPage: 2)
+            }
+            
+            if message.body as? String == "loading" {
+                print("loading")
+            }
+            
+            if message.body as? String == "loaded" {
+                print("loaded")
+            }
+            
+            if message.body as? String == "paste" {
+                self.paste(self)
+            }
+        }
+    }
+        
+    
+    //MARK: -
+
+    public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
+        if let serverTrust = challenge.protectionSpace.serverTrust {
+            completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: serverTrust))
+        } else {
+            completionHandler(URLSession.AuthChallengeDisposition.useCredential, nil);
+        }
+    }
+    
+    public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
+        print("didStartProvisionalNavigation");
+    }
+    
+    public func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) {
+        print("didReceiveServerRedirectForProvisionalNavigation");
+    }
+    
+    public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
+        NCUtility.sharedInstance.stopActivityIndicator()
+    }
+}

+ 2 - 0
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -90,6 +90,8 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
                 
                 detail.navigationController?.popViewController(animated: true)
                 detail.navigationController?.navigationBar.topItem?.title = ""
+                
+                appDelegate.activeMain.readFileReloadFolder()
             }
             
             if message.body as? String == "insertGraphic" {