marinofaggiana 5 years ago
parent
commit
cb91cc4bcc

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -548,7 +548,7 @@
 		F7E0E1DE22327DBA006B0911 /* NCAudioRecorderViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7E0E1DD22327DBA006B0911 /* NCAudioRecorderViewController.storyboard */; };
 		F7E4D9C422ED929B003675FD /* NCShareComments.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E4D9C322ED929B003675FD /* NCShareComments.swift */; };
 		F7E9C41B20F4CA870040CF18 /* CCTransfers.m in Sources */ = {isa = PBXBuildFile; fileRef = F7E9C41820F4CA870040CF18 /* CCTransfers.m */; };
-		F7F4B1D823C74B3E00D82A6E /* NCMainChangeHeightWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F4B1D723C74B3E00D82A6E /* NCMainChangeHeightWebView.swift */; };
+		F7F4B1D823C74B3E00D82A6E /* NCMainViewHeightRichWorkspace.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F4B1D723C74B3E00D82A6E /* NCMainViewHeightRichWorkspace.swift */; };
 		F7F54CE51E5B14C700E19C62 /* ImageError.png in Resources */ = {isa = PBXBuildFile; fileRef = F7F54CAF1E5B14C700E19C62 /* ImageError.png */; };
 		F7F54CE61E5B14C700E19C62 /* ImageError@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F7F54CB01E5B14C700E19C62 /* ImageError@2x.png */; };
 		F7F54CE71E5B14C700E19C62 /* ImageError@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F7F54CB11E5B14C700E19C62 /* ImageError@3x.png */; };
@@ -1346,7 +1346,7 @@
 		F7E9C41520F4CA870040CF18 /* CCTransfers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransfers.h; sourceTree = "<group>"; };
 		F7E9C41820F4CA870040CF18 /* CCTransfers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTransfers.m; sourceTree = "<group>"; };
 		F7F0617A1BAACDD300846525 /* CryptoCloud.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoCloud.pch; sourceTree = "<group>"; };
-		F7F4B1D723C74B3E00D82A6E /* NCMainChangeHeightWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainChangeHeightWebView.swift; sourceTree = "<group>"; };
+		F7F4B1D723C74B3E00D82A6E /* NCMainViewHeightRichWorkspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMainViewHeightRichWorkspace.swift; sourceTree = "<group>"; };
 		F7F54CAF1E5B14C700E19C62 /* ImageError.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ImageError.png; sourceTree = "<group>"; };
 		F7F54CB01E5B14C700E19C62 /* ImageError@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ImageError@2x.png"; sourceTree = "<group>"; };
 		F7F54CB11E5B14C700E19C62 /* ImageError@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ImageError@3x.png"; sourceTree = "<group>"; };
@@ -1592,7 +1592,7 @@
 				F792A77C1BC7C45400C9388E /* CCSplit.m */,
 				F7682FDF23C36B0500983A04 /* NCMainTabBar.swift */,
 				F7D6650620FF341600BFBA9E /* NCMainCommon.swift */,
-				F7F4B1D723C74B3E00D82A6E /* NCMainChangeHeightWebView.swift */,
+				F7F4B1D723C74B3E00D82A6E /* NCMainViewHeightRichWorkspace.swift */,
 				F73F537E1E929C8500F8678D /* CCMore.swift */,
 				F77444F7222816D5000D5EB0 /* NCPhotosPickerViewController.swift */,
 			);
@@ -3655,7 +3655,7 @@
 				F7D4238C1F0596C6009C9782 /* UIXToolbarView.m in Sources */,
 				F7233CEE23A24F990011D898 /* NCViewerNextcloudText.swift in Sources */,
 				F7020FCE2233D7F700B7297D /* NCCreateFormUploadVoiceNote.swift in Sources */,
-				F7F4B1D823C74B3E00D82A6E /* NCMainChangeHeightWebView.swift in Sources */,
+				F7F4B1D823C74B3E00D82A6E /* NCMainViewHeightRichWorkspace.swift in Sources */,
 				F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */,
 				F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */,
 				F7E0E1DC22327885006B0911 /* NCAudioRecorderViewController.swift in Sources */,

+ 5 - 5
iOSClient/Main/CCMain.h

@@ -43,15 +43,15 @@
 #import <MGSwipeTableCell/MGSwipeTableCell.h>
 
 @class tableMetadata;
-@class NCMainChangeHeightWebView;
+@class NCMainViewHeightRichWorkspace;
 
 @interface CCMain : UIViewController <UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate, UIGestureRecognizerDelegate, UIViewControllerPreviewingDelegate, BKPasscodeViewControllerDelegate, UISplitViewControllerDelegate, UIPopoverControllerDelegate, UIDocumentMenuDelegate, UIDocumentPickerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, UIScrollViewDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
 
 @property (nonatomic, weak) IBOutlet UITableView *tableView;
-@property (nonatomic, weak) IBOutlet NSLayoutConstraint *viewSectionWebViewHeight;
-@property (nonatomic, weak) IBOutlet UIView *viewSectionWebView;
-@property (nonatomic, weak) IBOutlet WKWebView *webView;
-@property (nonatomic, weak) IBOutlet NCMainChangeHeightWebView *mainChangeHeightWebView;
+@property (nonatomic, weak) IBOutlet NSLayoutConstraint *constraintHeightRichWorkspace;
+@property (nonatomic, weak) IBOutlet UIView *viewSectionRichWorkspace;
+@property (nonatomic, weak) IBOutlet WKWebView *webViewRichWorkspace;
+@property (nonatomic, weak) IBOutlet NCMainViewHeightRichWorkspace *mainViewHeightRichWorkspace;
 
 @property (nonatomic, strong) tableMetadata *metadata;
 @property (nonatomic, strong) tableMetadata *metadataForPushDetail;

+ 18 - 21
iOSClient/Main/CCMain.m

@@ -137,7 +137,7 @@
     UITapGestureRecognizer *webViewTapped = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(webViewTapAction:)];
     webViewTapped.numberOfTapsRequired = 1;
     webViewTapped.delegate = self;
-    [self.webView addGestureRecognizer:webViewTapped];
+    [self.webViewRichWorkspace addGestureRecognizer:webViewTapped];
     
     // Pull-to-Refresh
     [self createRefreshControl];
@@ -196,9 +196,6 @@
     if (self.searchController.isActive == false) {
         [self queryDatasourceWithReloadData:YES serverUrl:self.serverUrl];
     }
-    
-    // Rich Workspace
-    [self settingsRichWorkspace];
 }
 
 - (void)viewDidAppear:(BOOL)animated
@@ -291,7 +288,7 @@
     [[NCMainCommon sharedInstance] createImagesThemingColor];
     
     // viewSectionWebView
-    self.viewSectionWebView.backgroundColor = NCBrandColor.sharedInstance.brand;
+    self.viewSectionRichWorkspace.backgroundColor = NCBrandColor.sharedInstance.brand;
     
     // Refresh control
     refreshControl.tintColor = NCBrandColor.sharedInstance.brandText;
@@ -319,26 +316,25 @@
     [self tableViewReloadData];
 }
 
-- (void)settingsRichWorkspace
+- (void)settingsRichWorkspace:(NSString *)richWorkspace
 {
     // Nextcloud 18
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
-    tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
     
     if (capabilities.versionMajor >= k_nextcloud_version_18_0) {
-        if (directory.richWorkspace.length > 0) {
-            NSString *htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #000000;\">%@</span></h2>", directory.richWorkspace];
-            [self.webView loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
-            self.viewSectionWebViewHeight.constant = CCUtility.getViewSectionWebViewHeight;
+        NSString *htmlString;
+        
+        if (richWorkspace != nil && richWorkspace.length > 0) {
+            htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #000000;\">%@</span></h2>", richWorkspace];
         } else {
-            NSString *htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #999999;\">%@</span></h2>", NSLocalizedString(@"_add_notes_readme_md_", nil)];
-            [self.webView loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
-            self.viewSectionWebViewHeight.constant = CCUtility.getViewSectionWebViewHeight;
+            htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #999999;\">%@</span></h2>", NSLocalizedString(@"_add_notes_readme_md_", nil)];
         }
-        [self.mainChangeHeightWebView setHidden:false];
+        [self.webViewRichWorkspace loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
+        self.constraintHeightRichWorkspace.constant = CCUtility.getRichWorkspaceHeight;
+        [self.mainViewHeightRichWorkspace setHidden:false];
     } else {
-        self.viewSectionWebViewHeight.constant = 0;
-        [self.mainChangeHeightWebView setHidden:true];
+        self.constraintHeightRichWorkspace.constant = 0;
+        [self.mainViewHeightRichWorkspace setHidden:true];
     }
 }
 
@@ -381,9 +377,6 @@
         // Setting Theming
         [appDelegate settingThemingColorBrand];
         
-        // Section Rich Workspace
-        [self settingsRichWorkspace];
-        
         // Detail
         // If AVPlayer in play -> Stop
         if (appDelegate.player != nil && appDelegate.player.rate != 0) {
@@ -1152,7 +1145,7 @@
             // Rich Workspace
             if (metadataFolder != nil) {
                 [[NCManageDatabase sharedInstance] setDirectoryWithOcId:metadataFolder.ocId serverUrl:self.serverUrl richWorkspace:metadataFolder.richWorkspace account:account];
-                [self settingsRichWorkspace];
+                [self settingsRichWorkspace:metadataFolder.richWorkspace];
             }
             
             tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, metadataFolder.serverUrl]];
@@ -1164,6 +1157,10 @@
             
         } else if (errorCode != 0) {
             [[NCContentPresenter shared] messageNotification:@"_error_" description:errorMessage delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
+            
+            // Rich Workspace
+            tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
+            [self settingsRichWorkspace:directory.richWorkspace];
         } else {
             NSLog(@"[LOG] It has been changed user during networking process, error.");
         }

+ 5 - 5
iOSClient/Main/Main.storyboard

@@ -442,7 +442,7 @@
                                             <wkPreferences key="preferences"/>
                                         </wkWebViewConfiguration>
                                     </wkWebView>
-                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ucy-1e-ZKf" customClass="NCMainChangeHeightWebView" customModule="Nextcloud" customModuleProvider="target">
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ucy-1e-ZKf" customClass="NCMainViewHeightRichWorkspace" customModule="Nextcloud" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="90" width="414" height="10"/>
                                         <subviews>
                                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="dragHorizontal" translatesAutoresizingMaskIntoConstraints="NO" id="6qg-mV-HhN">
@@ -491,11 +491,11 @@
                     </view>
                     <navigationItem key="navigationItem" id="2BC-Vb-dXh"/>
                     <connections>
-                        <outlet property="mainChangeHeightWebView" destination="ucy-1e-ZKf" id="PbN-bX-rQa"/>
+                        <outlet property="constraintHeightRichWorkspace" destination="H0o-EG-cxN" id="bIE-De-8W7"/>
+                        <outlet property="mainViewHeightRichWorkspace" destination="ucy-1e-ZKf" id="qjc-0b-oTD"/>
                         <outlet property="tableView" destination="dC6-NQ-0Td" id="hew-Gn-bWh"/>
-                        <outlet property="viewSectionWebView" destination="xus-GQ-KT4" id="TMC-zb-IA9"/>
-                        <outlet property="viewSectionWebViewHeight" destination="H0o-EG-cxN" id="M8o-g3-Agn"/>
-                        <outlet property="webView" destination="5wM-L2-281" id="7dJ-Fc-Ltm"/>
+                        <outlet property="viewSectionRichWorkspace" destination="xus-GQ-KT4" id="DVt-Rt-OnV"/>
+                        <outlet property="webViewRichWorkspace" destination="5wM-L2-281" id="pYS-iQ-e7M"/>
                         <segue destination="mtc-lf-PRo" kind="showDetail" identifier="segueDetail" id="2Qm-A6-CfB"/>
                     </connections>
                 </viewController>

+ 8 - 8
iOSClient/Main/NCMainChangeHeightWebView.swift → iOSClient/Main/NCMainViewHeightRichWorkspace.swift

@@ -1,5 +1,5 @@
 //
-//  NCMainChangeHeightWebView.swift
+//  NCMainViewHeightRichWorkspace.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 09/01/2020.
@@ -8,7 +8,7 @@
 
 import Foundation
 
-class NCMainChangeHeightWebView: UIView {
+class NCMainViewHeightRichWorkspace: UIView {
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var startPosition: CGPoint?
@@ -38,21 +38,21 @@ class NCMainChangeHeightWebView: UIView {
         let touch = touches.first
         let endPosition = touch?.location(in: self)
         let difference = endPosition!.y - startPosition!.y
-        let differenceSectionWebViewHeight = appDelegate.activeMain.viewSectionWebViewHeight.constant + difference
+        let differenceSectionWebViewHeight = appDelegate.activeMain.constraintHeightRichWorkspace.constant + difference
         
         if differenceSectionWebViewHeight <= minHeight {
-            appDelegate.activeMain.viewSectionWebViewHeight.constant = minHeight
+            appDelegate.activeMain.constraintHeightRichWorkspace.constant = minHeight
         }
         else if differenceSectionWebViewHeight >= maxHeight {
-            appDelegate.activeMain.viewSectionWebViewHeight.constant = maxHeight
+            appDelegate.activeMain.constraintHeightRichWorkspace.constant = maxHeight
         }
         else {
-            appDelegate.activeMain.viewSectionWebViewHeight.constant = differenceSectionWebViewHeight
+            appDelegate.activeMain.constraintHeightRichWorkspace.constant = differenceSectionWebViewHeight
         }
         
         // save position
-        let currentviewSectionWebViewHeight = Int(appDelegate.activeMain.viewSectionWebViewHeight.constant)
-        CCUtility.setViewSectionWebViewHeight(currentviewSectionWebViewHeight)
+        let currentviewSectionWebViewHeight = Int(appDelegate.activeMain.constraintHeightRichWorkspace.constant)
+        CCUtility.setRichWorkspaceHeight(currentviewSectionWebViewHeight)
     }
 
     

+ 2 - 2
iOSClient/Utility/CCUtility.h

@@ -174,8 +174,8 @@
 + (BOOL)getDarkModeDetect;
 + (void)setDarkModeDetect:(BOOL)disable;
 
-+ (NSInteger)getViewSectionWebViewHeight;
-+ (void)setViewSectionWebViewHeight:(NSInteger)height;
++ (NSInteger)getRichWorkspaceHeight;
++ (void)setRichWorkspaceHeight:(NSInteger)height;
 
 // ===== Varius =====
 

+ 5 - 5
iOSClient/Utility/CCUtility.m

@@ -692,21 +692,21 @@
     [UICKeyChainStore setString:sDisable forKey:@"darkModeDetect" service:k_serviceShareKeyChain];
 }
 
-+ (NSInteger)getViewSectionWebViewHeight
++ (NSInteger)getRichWorkspaceHeight
 {
-    NSString *height = [UICKeyChainStore stringForKey:@"viewSectionWebViewHeight" service:k_serviceShareKeyChain];
+    NSString *height = [UICKeyChainStore stringForKey:@"richWorkspaceHeight" service:k_serviceShareKeyChain];
     
     if (height == nil) {
-        return UIScreen.mainScreen.bounds.size.height/4;
+        return UIScreen.mainScreen.bounds.size.height/5;
     } else {
         return [height integerValue];
     }
 }
 
-+ (void)setViewSectionWebViewHeight:(NSInteger)height
++ (void)setRichWorkspaceHeight:(NSInteger)height
 {
     NSString *heightString = [@(height) stringValue];
-    [UICKeyChainStore setString:heightString forKey:@"viewSectionWebViewHeight" service:k_serviceShareKeyChain];
+    [UICKeyChainStore setString:heightString forKey:@"richWorkspaceHeight" service:k_serviceShareKeyChain];
 }
 
 #pragma --------------------------------------------------------------------------------------------