Browse Source

Merge branch 'develop' into newdrawer

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

# Conflicts:
#	iOSClient/Main/CCMain.m
Philippe Weidmann 5 years ago
parent
commit
a7a6c38628

+ 1 - 1
Cartfile

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

+ 2 - 2
Cartfile.resolved

@@ -14,10 +14,10 @@ github "huri000/SwiftEntryKit" "1.2.3"
 github "jdg/MBProgressHUD" "1.1.0"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "krzyzanowskim/OpenSSL" "1.0.218"
-github "malcommac/SwiftRichString" "3.6.0"
+github "malcommac/SwiftRichString" "3.6.1"
 github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/FastScroll" "81967c2309d29bc2c330d422da612160a30bade8"
-github "nextcloud/ios-communication-library" "da0bdaee5e3b6b3a8ab0ed64dee83fe082a56cef"
+github "nextcloud/ios-communication-library" "v0.5"
 github "realm/realm-cocoa" "v4.1.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.1"

+ 20 - 16
Nextcloud.xcodeproj/project.pbxproj

@@ -396,6 +396,7 @@
 		F77B0F8C1D118A16002130FE /* CCCellMainTransfer.xib in Resources */ = {isa = PBXBuildFile; fileRef = F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */; };
 		F77D49A91DC238E500CDC568 /* loading.gif in Resources */ = {isa = PBXBuildFile; fileRef = F77D49A71DC238E500CDC568 /* loading.gif */; };
 		F77EB6281EC08036003F814F /* CCExifGeo.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A54C351C6267B500E2C8BF /* CCExifGeo.m */; };
+		F77F5D2D23D5F28100D2B7EB /* NCMainRefreshControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = F77F5D2C23D5F28100D2B7EB /* NCMainRefreshControl.swift */; };
 		F78071091EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */ = {isa = PBXBuildFile; fileRef = F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */; };
 		F780710A1EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */ = {isa = PBXBuildFile; fileRef = F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */; };
 		F781996922636BFA00EBDF6A /* HCFeatures.m in Sources */ = {isa = PBXBuildFile; fileRef = F781996822636BFA00EBDF6A /* HCFeatures.m */; };
@@ -403,7 +404,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 /* NCViewerRichWorkSpaceNextcloudText.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B523CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift */; };
+		F78A18B623CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78A18B523CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.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 */; };
@@ -1124,12 +1125,13 @@
 		F777F0301C29717F00CE81CB /* PHAsset+Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PHAsset+Utility.h"; sourceTree = "<group>"; };
 		F777F0311C29717F00CE81CB /* PHAsset+Utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PHAsset+Utility.m"; sourceTree = "<group>"; };
 		F77D49A71DC238E500CDC568 /* loading.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = loading.gif; sourceTree = "<group>"; };
+		F77F5D2C23D5F28100D2B7EB /* NCMainRefreshControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainRefreshControl.swift; sourceTree = "<group>"; };
 		F78071071EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+MainThread.h"; sourceTree = "<group>"; };
 		F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNotificationCenter+MainThread.m"; sourceTree = "<group>"; };
 		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 /* NCViewerRichWorkSpaceNextcloudText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkSpaceNextcloudText.swift; sourceTree = "<group>"; };
+		F78A18B523CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichWorkspaceWebView.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>"; };
@@ -1635,6 +1637,7 @@
 				F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
 				F7D6650620FF341600BFBA9E /* NCMainCommon.swift */,
 				F7682FDF23C36B0500983A04 /* NCMainTabBar.swift */,
+				F77F5D2C23D5F28100D2B7EB /* NCMainRefreshControl.swift */,
 				F77444F7222816D5000D5EB0 /* NCPhotosPickerViewController.swift */,
 			);
 			path = Main;
@@ -2543,9 +2546,9 @@
 				F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */,
 				F722814223C8C34500C41898 /* NCRichWorkspace.xib */,
 				F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */,
-				F78A18B523CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift */,
 				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
 				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
+				F78A18B523CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift */,
 			);
 			path = RichWorkspace;
 			sourceTree = "<group>";
@@ -3567,7 +3570,7 @@
 				F7B6ACD622FC2BD4008AB646 /* NCXMLCommentsParser.m in Sources */,
 				F738E8421F90FFD100F95C8E /* NCManageEndToEndEncryption.m in Sources */,
 				F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */,
-				F78A18B623CDD07D00F681F3 /* NCViewerRichWorkSpaceNextcloudText.swift in Sources */,
+				F78A18B623CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift in Sources */,
 				F75A9EE623796C6F0044CFCE /* NCNetworking.swift in Sources */,
 				F760F79D21F21F61006B1A73 /* CropRectView.swift in Sources */,
 				F73B4F091F470D9100BBEE4B /* nsEUCKRProber.cpp in Sources */,
@@ -3721,6 +3724,7 @@
 				F70022D41EC4C9100080073F /* NSDate+ISO8601.m in Sources */,
 				F762CB151EACB66200B38484 /* XLFormRowNavigationAccessoryView.m in Sources */,
 				F762CB0A1EACB66200B38484 /* XLFormDescriptor.m in Sources */,
+				F77F5D2D23D5F28100D2B7EB /* NCMainRefreshControl.swift in Sources */,
 				F7D4238C1F0596C6009C9782 /* UIXToolbarView.m in Sources */,
 				F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */,
 				F7F4B1D823C74B3E00D82A6E /* NCRichWorkspace.swift in Sources */,
@@ -3882,7 +3886,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -3901,7 +3905,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = it.twsweb.Nextcloud.Share;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -3926,7 +3930,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/Share.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -3945,7 +3949,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = it.twsweb.Nextcloud.Share;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -3976,7 +3980,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -3995,7 +3999,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.Nextcloud.File-Provider-Extension";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4026,7 +4030,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4045,7 +4049,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "\"Libraries external\"/**";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.Nextcloud.File-Provider-Extension";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4068,7 +4072,7 @@
 				CODE_SIGN_ENTITLEMENTS = iOSClient/Brand/iOSClient.entitlements;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4086,7 +4090,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				OTHER_SWIFT_FLAGS = "";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.$(PRODUCT_NAME:rfc1034identifier)";
@@ -4115,7 +4119,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 8;
+				CURRENT_PROJECT_VERSION = 0;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -4132,7 +4136,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
 				LIBRARY_SEARCH_PATHS = "";
-				MARKETING_VERSION = 2.25.4;
+				MARKETING_VERSION = 2.25.5;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "it.twsweb.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 13 - 1
iOSClient/Login/NCLoginWeb.swift

@@ -34,6 +34,14 @@ 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()
 
@@ -47,7 +55,7 @@ class NCLoginWeb: UIViewController {
         webView!.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
         
         // ADD k_flowEndpoint for Web Flow
-        if NCBrandOptions.sharedInstance.use_login_web_personalized == false && urlBase != NCBrandOptions.sharedInstance.linkloginPreferredProviders {
+        if urlBase != NCBrandOptions.sharedInstance.linkloginPreferredProviders {
             urlBase =  urlBase + k_flowEndpoint
         }
         
@@ -85,6 +93,10 @@ class NCLoginWeb: UIViewController {
         webView.load(request)
     }
     
+    @objc func closeView(sender: UIBarButtonItem) {
+        self.dismiss(animated: true, completion: nil)
+    }
+    
 }
 
 extension NCLoginWeb: WKNavigationDelegate {

+ 1 - 1
iOSClient/Main/CCMain.h

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

+ 77 - 89
iOSClient/Main/CCMain.m

@@ -49,7 +49,7 @@
     NSUInteger _failedAttempts;
     NSDate *_lockUntilDate;
 
-    UIRefreshControl *refreshControl;
+    NCMainRefreshControl *refreshControl;
 
     CCHud *_hud;
     
@@ -70,7 +70,10 @@
     
     // Folder
     BOOL _loadingFolder;
-    tableMetadata *_metadataFolder;    
+    tableMetadata *_metadataFolder;
+    
+    CGFloat heightRichWorkspace;
+    CGFloat heightSearchBar;
 }
 @end
 
@@ -125,13 +128,26 @@
     self.searchController.delegate = self;
     self.searchController.searchBar.delegate = self;
     
-    // Register cell
-    [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMain" bundle:nil] forCellReuseIdentifier:@"CellMain"];
-    [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMainTransfer" bundle:nil] forCellReuseIdentifier:@"CellMainTransfer"];
-    
-    // long press recognizer TableView
-    UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressTableView:)];
-    [self.tableView addGestureRecognizer:longPressRecognizer];
+    // Search
+    self.definesPresentationContext = YES;
+    self.searchController.searchResultsUpdater = self;
+    self.searchController.dimsBackgroundDuringPresentation = NO;
+    self.searchController.searchBar.translucent = NO;
+    [self.searchController.searchBar sizeToFit];
+    self.searchController.searchBar.delegate = self;
+    self.searchController.searchBar.barTintColor = NCBrandColor.sharedInstance.brand;
+    self.searchController.searchBar.backgroundColor = NCBrandColor.sharedInstance.brand;
+    self.searchController.searchBar.backgroundImage = [UIImage new];
+    UIButton *searchButton = self.searchController.searchBar.subviews.firstObject.subviews.lastObject;
+    if (searchButton && [searchButton isKindOfClass:[UIButton class]]) {
+        [searchButton setTitleColor:NCBrandColor.sharedInstance.brandText forState:UIControlStateNormal];
+    }
+    UITextField *searchTextView = [self.searchController.searchBar valueForKey:@"searchField"];
+    if (searchTextView && [searchTextView isKindOfClass:[UITextField class]]) {
+        searchTextView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
+        searchTextView.textColor = NCBrandColor.sharedInstance.textView;
+    }
+    heightSearchBar = self.searchController.searchBar.frame.size.height;
     
     // Load Rich Workspace
     self.viewRichWorkspace = [[[NSBundle mainBundle] loadNibNamed:@"NCRichWorkspace" owner:self options:nil] firstObject];
@@ -139,6 +155,21 @@
     viewRichWorkspaceTapped.numberOfTapsRequired = 1;
     viewRichWorkspaceTapped.delegate = self;
     [self.viewRichWorkspace addGestureRecognizer:viewRichWorkspaceTapped];
+    heightRichWorkspace = UIScreen.mainScreen.bounds.size.height/4 + heightSearchBar;
+    self.viewRichWorkspace.textViewTopConstraint.constant = heightSearchBar;
+    [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, heightRichWorkspace)];
+    
+    // Table Header View
+    [self.tableView setTableHeaderView:self.viewRichWorkspace];
+    [self.tableView.tableHeaderView addSubview:self.searchController.searchBar];
+    
+    // Register cell
+    [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMain" bundle:nil] forCellReuseIdentifier:@"CellMain"];
+    [self.tableView registerNib:[UINib nibWithNibName:@"CCCellMainTransfer" bundle:nil] forCellReuseIdentifier:@"CellMainTransfer"];
+    
+    // long press recognizer TableView
+    UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressTableView:)];
+    [self.tableView addGestureRecognizer:longPressRecognizer];
     
     // Pull-to-Refresh
     [self createRefreshControl];
@@ -182,20 +213,13 @@
     // If not editing mode remove _selectedocIds
     if (!self.tableView.editing)
         [_selectedocIdsMetadatas removeAllObjects];
-    
-    // Search Bar
-    if ([CCUtility isFolderEncrypted:self.serverUrl account:appDelegate.activeAccount]) {
-        [self searchEnabled:NO];
-    } else {
-        [self searchEnabled:YES];
-    }
-    
+
     // 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;
+    self.richWorkspaceText = directory.richWorkspace;
     
     // Query data source
     if (self.searchController.isActive == false) {
@@ -264,7 +288,6 @@
         }
         
         [self setTableViewHeader];
-        [self.tableView reloadData];
     }];
 }
 
@@ -301,7 +324,6 @@
     // 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]]) {
@@ -314,6 +336,9 @@
         searchTextView.textColor = NCBrandColor.sharedInstance.textView;
     }
     
+    // Rich Workspace
+    [self.viewRichWorkspace loadWithRichWorkspaceText:self.richWorkspaceText];
+    
     // Title
     [self setTitle];
     
@@ -517,7 +542,7 @@
 
 - (void)createRefreshControl
 {
-    refreshControl = [UIRefreshControl new];
+    refreshControl = [NCMainRefreshControl new];
     
     self.tableView.refreshControl = refreshControl;
     
@@ -1107,7 +1132,7 @@
     
     // RichWorkspace
     tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
-    self.richWorkspace = directory.richWorkspace;
+    self.richWorkspaceText = directory.richWorkspace;
     [self setTableViewHeader];
     
     // Load Datasource
@@ -1124,7 +1149,7 @@
             
             // Rich Workspace
             [[NCManageDatabase sharedInstance] setDirectoryWithOcId:metadataFolder.ocId serverUrl:self.serverUrl richWorkspace:metadataFolder.richWorkspace account:account];
-            self.richWorkspace = metadataFolder.richWorkspace;
+            self.richWorkspaceText = metadataFolder.richWorkspace;
             [self setTableViewHeader];
             
             tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, metadataFolder.serverUrl]];
@@ -1276,43 +1301,6 @@
 #pragma mark ===== Search =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)searchEnabled:(BOOL)enabled
-{
-    if (enabled) {
-    
-        if (self.tableView.tableHeaderView != nil)
-            return;
-        
-        self.definesPresentationContext = YES;
-        self.searchController.searchResultsUpdater = self;
-        self.searchController.dimsBackgroundDuringPresentation = NO;
-        self.searchController.searchBar.translucent = NO;
-        [self.searchController.searchBar sizeToFit];
-        self.searchController.searchBar.delegate = self;
-        self.searchController.searchBar.barTintColor = NCBrandColor.sharedInstance.brand;
-        self.searchController.searchBar.backgroundColor = NCBrandColor.sharedInstance.brand;
-        self.searchController.searchBar.backgroundImage = [UIImage new];
-        // color searchbbar button text (cancel)
-        UIButton *searchButton = self.searchController.searchBar.subviews.firstObject.subviews.lastObject;
-        if (searchButton && [searchButton isKindOfClass:[UIButton class]]) {
-            [searchButton setTitleColor:NCBrandColor.sharedInstance.brandText forState:UIControlStateNormal];
-        }
-        // color textview searchbbar
-        UITextField *searchTextView = [self.searchController.searchBar valueForKey:@"searchField"];
-        if (searchTextView && [searchTextView isKindOfClass:[UITextField class]]) {
-            searchTextView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm;
-            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)];
-        
-    } else {
-        
-        self.tableView.tableHeaderView = nil;
-    }
-}
-
 - (void)searchStartTimer
 {
     if (self.searchController.isActive == false) {
@@ -1419,7 +1407,9 @@
         [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
     }
     
-    //[self setNeedsStatusBarAppearanceUpdate];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+        [self setTableViewHeader];
+    });
 }
 
 #pragma mark -
@@ -1937,25 +1927,32 @@
 
 - (void)viewRichWorkspaceTapAction:(UITapGestureRecognizer *)tapGesture
 {
-    UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCViewerRichWorkspace" bundle:nil] instantiateInitialViewController];
-    NCViewerRichWorkspace *viewerRichWorkspace = (NCViewerRichWorkspace *)[navigationController topViewController];
-    viewerRichWorkspace.richWorkspace = self.richWorkspace;
-    viewerRichWorkspace.serverUrl = self.serverUrl;
-    
-    navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
-    
-    [self presentViewController:navigationController animated:NO completion:NULL];
+    [UIView animateWithDuration:0.5 animations:^{
+       
+        [self.tableView setContentOffset:CGPointMake(0, heightSearchBar)];
+        
+    } completion:^(BOOL finished) {
+        
+        UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCViewerRichWorkspace" bundle:nil] instantiateInitialViewController];
+        NCViewerRichWorkspace *viewerRichWorkspace = (NCViewerRichWorkspace *)[navigationController topViewController];
+        viewerRichWorkspace.richWorkspaceText = self.richWorkspaceText;
+        viewerRichWorkspace.serverUrl = self.serverUrl;
+        
+        navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
+        
+        [self presentViewController:navigationController animated:NO completion:NULL];
+    }];
 }
 
 - (void)createRichWorkspace
 {
-    NCRichWorkspaceTextCommon *richWorkspaceTextCommon = [NCRichWorkspaceTextCommon new];
+    NCRichWorkspaceCommon *richWorkspaceCommon = [NCRichWorkspaceCommon new];
     tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, self.serverUrl, k_fileNameRichWorkspace.lowercaseString]];
     
     if (metadata) {
-        [richWorkspaceTextCommon openViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
+        [richWorkspaceCommon openViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
     } else {
-        [richWorkspaceTextCommon createViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
+        [richWorkspaceCommon createViewerNextcloudTextWithServerUrl:self.serverUrl viewController:self];
     }
 }
 
@@ -3117,28 +3114,19 @@
 
 - (void)setTableViewHeader
 {
-    CGFloat height = UIScreen.mainScreen.bounds.size.height/5;
-    
-    // Nextcloud 18
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
-    if (capabilities.versionMajor < k_nextcloud_version_18_0) {
-        
-        [self.tableView setTableHeaderView:nil];
+  
+    if (capabilities.versionMajor < k_nextcloud_version_18_0 || self.richWorkspaceText.length == 0 || self.searchController.isActive) {
+                
+        [self.tableView.tableHeaderView setFrame:CGRectMake(self.tableView.tableHeaderView.frame.origin.x, self.tableView.tableHeaderView.frame.origin.y, self.tableView.frame.size.width, heightSearchBar)];
         
     } else {
-    
-        if (self.richWorkspace.length == 0) {
-            
-            [self.tableView setTableHeaderView:nil];
-            
-        } else {
-            
-            [self.viewRichWorkspace setRichWorkspaceText:self.richWorkspace gradient:true];
-            [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, height)];
-            [self.tableView setTableHeaderView:self.viewRichWorkspace];
-        }
+        
+        [self.viewRichWorkspace setFrame:CGRectMake(self.tableView.tableHeaderView.frame.origin.x, self.tableView.tableHeaderView.frame.origin.y, self.tableView.frame.size.width, heightRichWorkspace)];
     }
     
+    [self.viewRichWorkspace loadWithRichWorkspaceText:self.richWorkspaceText];
+    self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.tableView.frame.size.width, heightSearchBar);
     [self.tableView reloadData];
 }
 

+ 5 - 5
iOSClient/Main/Cell/CCCellMain.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -57,10 +57,10 @@
                         </constraints>
                     </imageView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="qhJ-el-R92" userLabel="Shared">
-                        <rect key="frame" x="513" y="18" width="24" height="24"/>
+                        <rect key="frame" x="510" y="15" width="30" height="30"/>
                         <constraints>
-                            <constraint firstAttribute="height" constant="24" id="3Kr-Hv-AdZ"/>
-                            <constraint firstAttribute="width" constant="24" id="Ijp-se-6KO"/>
+                            <constraint firstAttribute="height" constant="30" id="3Kr-Hv-AdZ"/>
+                            <constraint firstAttribute="width" constant="30" id="Ijp-se-6KO"/>
                         </constraints>
                     </imageView>
                     <view alpha="0.050000000000000003" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HRe-1g-6Q1" userLabel="ViewShared">

+ 58 - 0
iOSClient/Main/NCMainRefreshControl.swift

@@ -0,0 +1,58 @@
+//
+//  NCMainRefreshControl.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 20/01/2020.
+//  Copyright (c) 2017 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 NCMainRefreshControl: UIRefreshControl {
+    
+    override func layoutSubviews() {
+        super.layoutSubviews()
+        let originalFrame = frame
+        frame = originalFrame
+    }
+    
+    override var isHidden: Bool {
+        get {
+            return super.isHidden
+        }
+        set(hiding) {
+            if hiding {
+                guard frame.origin.y >= 0 else { return }
+                super.isHidden = hiding
+            } else {
+                guard frame.origin.y < 0 else { return }
+                super.isHidden = hiding
+            }
+        }
+    }
+
+    override var frame: CGRect {
+        didSet {
+            if frame.origin.y < 0 {
+                isHidden = false
+            } else {
+                isHidden = true
+            }
+        }
+    }
+}

+ 20 - 80
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -27,93 +27,33 @@ import SwiftRichString
 
 @objc class NCViewRichWorkspace: UIView {
     
-    @IBOutlet weak var textView: UITextView!
-    var richWorkspace: String = ""
-    var gradient: Bool = false
+    @objc @IBOutlet weak var textView: UITextView!
+    @objc @IBOutlet weak var textViewTopConstraint: NSLayoutConstraint!
+
     let gradientLayer: CAGradientLayer = CAGradientLayer()
 
     required init?(coder: NSCoder) {
         super.init(coder: coder)
-        
-        NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
-        self.backgroundColor = NCBrandColor.sharedInstance.backgroundView
     }
-    
-    @objc func changeTheming() {
-        self.backgroundColor = NCBrandColor.sharedInstance.backgroundView
-        setRichWorkspaceText(richWorkspace, gradient: gradient)
+
+    @objc func load(richWorkspaceText: String) {
+        let richWorkspaceCommon = NCRichWorkspaceCommon()
+        
+        richWorkspaceCommon.setRichWorkspaceText(richWorkspaceText, textView: textView)
+        setGradient()
     }
     
-    @objc func setRichWorkspaceText(_ richWorkspace: String, gradient: Bool) {
+    @objc func setGradient() {
         
-        self.richWorkspace = richWorkspace
-        self.gradient = gradient
-        
-        let h1 = Style {
-            $0.font = UIFont.systemFont(ofSize: 25, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let h2 = Style {
-            $0.font = UIFont.systemFont(ofSize: 23, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let h3 = Style {
-            $0.font = UIFont.systemFont(ofSize: 21, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let h4 = Style {
-            $0.font = UIFont.systemFont(ofSize: 19, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let h5 = Style {
-            $0.font = UIFont.systemFont(ofSize: 17, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let h6 = Style {
-            $0.font = UIFont.systemFont(ofSize: 15, weight: .bold)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-        let normal = Style {
-            $0.font = UIFont.systemFont(ofSize: 15)
-            $0.color = NCBrandColor.sharedInstance.textView
-        }
-       
-        var richWorkspaceStyling = ""
-        let richWorkspaceArray = richWorkspace.components(separatedBy: "\n")
-        for string in richWorkspaceArray {
-            if string.hasPrefix("# ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h1>" + string.replacingOccurrences(of: "# ", with: "") + "</h1>\r\n"
-            } else if string.hasPrefix("## ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h2>" + string.replacingOccurrences(of: "## ", with: "") + "</h2>\r\n"
-            } else if string.hasPrefix("### ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h3>" + string.replacingOccurrences(of: "### ", with: "") + "</h3>\r\n"
-            } else if string.hasPrefix("#### ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h4>" + string.replacingOccurrences(of: "#### ", with: "") + "</h4>\r\n"
-            } else if string.hasPrefix("##### ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h5>" + string.replacingOccurrences(of: "##### ", with: "") + "</h5>\r\n"
-            } else if string.hasPrefix("###### ") {
-                richWorkspaceStyling = richWorkspaceStyling + "<h6>" + string.replacingOccurrences(of: "###### ", with: "") + "</h6>\r\n"
-            } else {
-                richWorkspaceStyling = richWorkspaceStyling + string + "\r\n"
-            }
-        }
-        
-        textView.attributedText = richWorkspaceStyling.set(style: StyleGroup(base: normal, ["h1": h1, "h2": h2, "h3": h3, "h4": h4, "h5": h5, "h6": h6]))
-        textView.isUserInteractionEnabled = false
-        textView.sizeToFit()
-        
-        if gradient {
-            
-            gradientLayer.removeFromSuperlayer()
-            gradientLayer.frame = CGRect(x: 0.0, y: 0.0, width: self.frame.width, height: self.frame.height)
-            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)
-        }
+        gradientLayer.removeFromSuperlayer()
+        gradientLayer.frame = CGRect(x: 0.0, y: 0.0, width: textView.frame.width, height: textView.frame.height)
+        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)
     }
 }

+ 6 - 5
iOSClient/RichWorkspace/NCRichWorkspace.xib

@@ -14,24 +14,25 @@
             <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" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wri-16-tQY">
-                    <rect key="frame" x="15" y="5" width="295" height="470"/>
+                <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wri-16-tQY">
+                    <rect key="frame" x="15" y="50" width="295" height="420"/>
                     <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"/>
                     <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
                 </textView>
             </subviews>
-            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="wri-16-tQY" secondAttribute="bottom" constant="5" id="Ei6-vr-4dN"/>
-                <constraint firstItem="wri-16-tQY" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="5" id="O2Y-0W-v0n"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="wri-16-tQY" secondAttribute="bottom" constant="10" id="Ei6-vr-4dN"/>
+                <constraint firstItem="wri-16-tQY" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="50" id="O2Y-0W-v0n"/>
                 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="wri-16-tQY" secondAttribute="trailing" constant="10" id="Rg0-g6-cT4"/>
                 <constraint firstItem="wri-16-tQY" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="15" id="o8o-lo-wZd"/>
             </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <connections>
                 <outlet property="textView" destination="wri-16-tQY" id="pwA-gm-dfK"/>
+                <outlet property="textViewTopConstraint" destination="O2Y-0W-v0n" id="ggP-y2-Lft"/>
             </connections>
             <point key="canvasLocation" x="136.875" y="88.75"/>
         </view>

+ 70 - 15
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -23,8 +23,9 @@
 
 import Foundation
 import NCCommunication
+import SwiftRichString
 
-@objc class NCRichWorkspaceTextCommon: NSObject {
+@objc class NCRichWorkspaceCommon: NSObject {
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
@@ -45,12 +46,12 @@ import NCCommunication
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 
-                if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                if let viewerRichWorkspaceWebView = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkspaceWebView") as? NCViewerRichWorkspaceWebView {
                     
-                    viewerRichWorkSpaceText.url = url!
-                    viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                    viewerRichWorkspaceWebView.url = url!
+                    viewerRichWorkspaceWebView.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
                     
-                    viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                    viewController.present(viewerRichWorkspaceWebView, animated: true, completion: nil)
                 }
                 
             } else if errorCode != 0 {
@@ -80,13 +81,13 @@ import NCCommunication
                     
                     if errorCode == 0 && account == self.appDelegate.activeAccount {
                         
-                        if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                        if let viewerRichWorkspaceWebView = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkspaceWebView") as? NCViewerRichWorkspaceWebView {
                             
-                            viewerRichWorkSpaceText.url = url!
-                            viewerRichWorkSpaceText.metadata = metadata
-                            viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                            viewerRichWorkspaceWebView.url = url!
+                            viewerRichWorkspaceWebView.metadata = metadata
+                            viewerRichWorkspaceWebView.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
                             
-                            viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                            viewController.present(viewerRichWorkspaceWebView, animated: true, completion: nil)
                         }
                         
                     } else if errorCode != 0 {
@@ -96,15 +97,69 @@ import NCCommunication
                 
             } else {
                 
-                if let viewerRichWorkSpaceText = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkSpaceNextcloudText") as? NCViewerRichWorkSpaceNextcloudText {
+                if let viewerRichWorkspaceWebView = UIStoryboard.init(name: "NCViewerRichWorkspace", bundle: nil).instantiateViewController(withIdentifier: "NCViewerRichWorkspaceWebView") as? NCViewerRichWorkspaceWebView {
                     
-                    viewerRichWorkSpaceText.url = metadata.url
-                    viewerRichWorkSpaceText.metadata = metadata
-                    viewerRichWorkSpaceText.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
+                    viewerRichWorkspaceWebView.url = metadata.url
+                    viewerRichWorkspaceWebView.metadata = metadata
+                    viewerRichWorkspaceWebView.presentationController?.delegate = viewController as? UIAdaptivePresentationControllerDelegate
                     
-                    viewController.present(viewerRichWorkSpaceText, animated: true, completion: nil)
+                    viewController.present(viewerRichWorkspaceWebView, animated: true, completion: nil)
                 }
             }
         }
     }
+    
+    @objc func setRichWorkspaceText(_ richWorkspaceText: String, textView: UITextView) {
+           
+           let h1 = Style {
+               $0.font = UIFont.systemFont(ofSize: 25, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let h2 = Style {
+               $0.font = UIFont.systemFont(ofSize: 23, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let h3 = Style {
+               $0.font = UIFont.systemFont(ofSize: 21, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let h4 = Style {
+               $0.font = UIFont.systemFont(ofSize: 19, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let h5 = Style {
+               $0.font = UIFont.systemFont(ofSize: 17, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let h6 = Style {
+               $0.font = UIFont.systemFont(ofSize: 15, weight: .bold)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+           let normal = Style {
+               $0.font = UIFont.systemFont(ofSize: 15)
+               $0.color = NCBrandColor.sharedInstance.textView
+           }
+          
+           var richWorkspaceStyling = ""
+           let richWorkspaceArray = richWorkspaceText.components(separatedBy: "\n")
+           for string in richWorkspaceArray {
+               if string.hasPrefix("# ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h1>" + string.replacingOccurrences(of: "# ", with: "") + "</h1>\r\n"
+               } else if string.hasPrefix("## ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h2>" + string.replacingOccurrences(of: "## ", with: "") + "</h2>\r\n"
+               } else if string.hasPrefix("### ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h3>" + string.replacingOccurrences(of: "### ", with: "") + "</h3>\r\n"
+               } else if string.hasPrefix("#### ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h4>" + string.replacingOccurrences(of: "#### ", with: "") + "</h4>\r\n"
+               } else if string.hasPrefix("##### ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h5>" + string.replacingOccurrences(of: "##### ", with: "") + "</h5>\r\n"
+               } else if string.hasPrefix("###### ") {
+                   richWorkspaceStyling = richWorkspaceStyling + "<h6>" + string.replacingOccurrences(of: "###### ", with: "") + "</h6>\r\n"
+               } else {
+                   richWorkspaceStyling = richWorkspaceStyling + string + "\r\n"
+               }
+           }
+           
+           textView.attributedText = richWorkspaceStyling.set(style: StyleGroup(base: normal, ["h1": h1, "h2": h2, "h3": h3, "h4": h4, "h5": h5, "h6": h6]))
+       }
 }

+ 15 - 30
iOSClient/RichWorkspace/NCViewerRichWorkspace.storyboard

@@ -11,56 +11,41 @@
         <!--Viewer Rich Workspace-->
         <scene sceneID="5lu-RQ-5e2">
             <objects>
-                <viewController id="6oU-Ar-6R2" customClass="NCViewerRichWorkspace" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="NCViewerRichWorkspace" id="6oU-Ar-6R2" customClass="NCViewerRichWorkspace" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="Hcj-yo-mxA">
                         <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <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="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="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"/>
-                                        <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
-                                    </textView>
-                                </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"/>
-                                </constraints>
-                                <connections>
-                                    <outlet property="textView" destination="tWU-uH-OcN" id="kaU-Ye-UzC"/>
-                                </connections>
-                            </view>
+                            <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="tWU-uH-OcN">
+                                <rect key="frame" x="15" y="88" width="389" height="774"/>
+                                <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"/>
+                                <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                            </textView>
                         </subviews>
                         <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                         <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="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="tWU-uH-OcN" firstAttribute="leading" secondItem="Isy-ab-db7" secondAttribute="leading" constant="15" id="U5r-S4-VjQ"/>
+                            <constraint firstItem="tWU-uH-OcN" firstAttribute="top" secondItem="Isy-ab-db7" secondAttribute="top" id="UoK-d1-aHC"/>
+                            <constraint firstItem="Isy-ab-db7" firstAttribute="bottom" secondItem="tWU-uH-OcN" secondAttribute="bottom" id="hKD-qx-JT8"/>
+                            <constraint firstItem="Isy-ab-db7" firstAttribute="trailing" secondItem="tWU-uH-OcN" secondAttribute="trailing" constant="10" id="x1a-WA-AX7"/>
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="Isy-ab-db7"/>
                     </view>
                     <navigationItem key="navigationItem" id="YSS-NL-35O"/>
                     <connections>
-                        <outlet property="viewRichWorkspace" destination="ZTH-4c-how" id="Tj4-ng-4pc"/>
+                        <outlet property="textView" destination="tWU-uH-OcN" id="41C-KX-15c"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="hXn-we-pg4" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="1013.0434782608696" y="23.4375"/>
         </scene>
-        <!--Viewer Rich Work Space Nextcloud Text-->
+        <!--Viewer Rich Workspace Web View-->
         <scene sceneID="FAF-zB-yaq">
             <objects>
-                <viewController storyboardIdentifier="NCViewerRichWorkSpaceNextcloudText" id="Ces-GG-tAv" customClass="NCViewerRichWorkSpaceNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="NCViewerRichWorkspaceWebView" id="Ces-GG-tAv" customClass="NCViewerRichWorkspaceWebView" 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"/>

+ 9 - 8
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -26,10 +26,11 @@ import NCCommunication
 
 @objc class NCViewerRichWorkspace: UIViewController, UIAdaptivePresentationControllerDelegate {
 
-    @IBOutlet weak var viewRichWorkspace: NCViewRichWorkspace!
+    @IBOutlet weak var textView: UITextView!
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    @objc public var richWorkspace: String = ""
+    private let richWorkspaceCommon = NCRichWorkspaceCommon()
+    @objc public var richWorkspaceText: String = ""
     @objc public var serverUrl: String = ""
    
     override func viewDidLoad() {
@@ -43,7 +44,7 @@ import NCCommunication
         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)
+        richWorkspaceCommon.setRichWorkspaceText(richWorkspaceText, textView: textView)
         
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
         changeTheming()
@@ -59,9 +60,9 @@ import NCCommunication
                 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)
+                self.richWorkspaceText = metadataFolder.richWorkspace
+                self.appDelegate.activeMain.richWorkspaceText = self.richWorkspaceText
+                self.richWorkspaceCommon.setRichWorkspaceText(self.richWorkspaceText, textView: self.textView)
             }
         }
     }
@@ -72,6 +73,7 @@ import NCCommunication
     
     @objc func changeTheming() {
         appDelegate.changeTheming(self, tableView: nil, collectionView: nil, form: false)
+        richWorkspaceCommon.setRichWorkspaceText(richWorkspaceText, textView: textView)
     }
     
     @objc func closeItemTapped(_ sender: UIBarButtonItem) {
@@ -80,7 +82,6 @@ import NCCommunication
     
     @IBAction func editItemAction(_ sender: Any) {
         
-        let richWorkspaceTextCommon = NCRichWorkspaceTextCommon()
-        richWorkspaceTextCommon.openViewerNextcloudText(serverUrl: serverUrl, viewController: self)
+        richWorkspaceCommon.openViewerNextcloudText(serverUrl: serverUrl, viewController: self)
     }
 }

+ 2 - 2
iOSClient/RichWorkspace/NCViewerRichWorkSpaceNextcloudText.swift → iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift

@@ -1,5 +1,5 @@
 //
-//  NCViewerRichWorkSpaceNextcloudText.swift
+//  NCViewerRichWorkspaceWebView.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 12/12/19.
@@ -23,7 +23,7 @@
 
 import Foundation
 
-class NCViewerRichWorkSpaceNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
+class NCViewerRichWorkspaceWebView: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
     
     @IBOutlet weak var webView: WKWebView!
     @IBOutlet weak var webViewBottomConstraint: NSLayoutConstraint!

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


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


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


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


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


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


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


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