marinofaggiana 5 years ago
parent
commit
dec0232218
31 changed files with 802 additions and 1409 deletions
  1. 30 0
      Libraries external/Imagemeter/IMCreate.swift
  2. 20 36
      Nextcloud.xcodeproj/project.pbxproj
  3. 4 2
      iOSClient/AppDelegate.h
  4. 1 4
      iOSClient/AppDelegate.m
  5. 2 1
      iOSClient/BrowserWeb/NCBrowserWeb.swift
  6. 0 3
      iOSClient/Favorites/CCFavorites.h
  7. 8 15
      iOSClient/Favorites/CCFavorites.m
  8. 1 0
      iOSClient/Login/NCLoginWeb.swift
  9. 0 60
      iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift
  10. 0 51
      iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeaderView.xib
  11. 0 83
      iOSClient/Main/CCDetail.h
  12. 0 1045
      iOSClient/Main/CCDetail.m
  13. 0 2
      iOSClient/Main/CCMain.h
  14. 9 19
      iOSClient/Main/CCMain.m
  15. 1 0
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  16. 162 0
      iOSClient/Main/Create cloud/NCCreateMenuAdd.swift
  17. 9 8
      iOSClient/Main/Main.storyboard
  18. 118 0
      iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift
  19. 62 0
      iOSClient/Main/NCDetailNavigationController.swift
  20. 238 0
      iOSClient/Main/NCDetailViewController.swift
  21. 6 6
      iOSClient/Main/NCMainCommon.swift
  22. 2 7
      iOSClient/Media/NCMedia.swift
  23. 2 5
      iOSClient/Offline/NCOffline.swift
  24. 1 0
      iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift
  25. 10 1
      iOSClient/Text/NCText.swift
  26. 0 1
      iOSClient/Transfers/CCTransfers.m
  27. 4 3
      iOSClient/Viewer/NCViewerDocumentWeb.swift
  28. 6 17
      iOSClient/Viewer/NCViewerMedia.swift
  29. 14 20
      iOSClient/Viewer/NCViewerNextcloudText.swift
  30. 75 0
      iOSClient/Viewer/NCViewerPDF.swift
  31. 17 20
      iOSClient/Viewer/NCViewerRichdocument.swift

+ 30 - 0
Libraries external/Imagemeter/IMCreate.swift

@@ -0,0 +1,30 @@
+//
+//  IMCreate.swift
+//  HandwerkCloud
+//
+//  Created by Marino Faggiana on 17/11/2019.
+//  Copyright (c) 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 IMCreate: NSObject {
+    init(serverUrl: String) {
+        super.init()
+    }
+}

+ 20 - 36
Nextcloud.xcodeproj/project.pbxproj

@@ -90,6 +90,9 @@
 		F70CEF5823E9C7E50007035B /* UIColor+adjust.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+adjust.swift */; };
 		F70CEF5923E9C7E50007035B /* UIColor+adjust.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+adjust.swift */; };
 		F70F2BA5225F2D8900EBB73E /* ZIPFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F70F2BA4225F2D8900EBB73E /* ZIPFoundation.framework */; };
+		F710D1F52405770F00A6033D /* NCViewerPDF.swift in Sources */ = {isa = PBXBuildFile; fileRef = F710D1F42405770F00A6033D /* NCViewerPDF.swift */; };
+		F710D1F724057C9400A6033D /* NCDetailNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F710D1F624057C9400A6033D /* NCDetailNavigationController.swift */; };
+		F710D1F924057C9D00A6033D /* NCDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F710D1F824057C9D00A6033D /* NCDetailViewController.swift */; };
 		F710E8111EF95C9C00DC2427 /* ImagesIntro.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F710E80F1EF95C9C00DC2427 /* ImagesIntro.xcassets */; };
 		F71459B81D12E3B700CAFEEC /* CCError.m in Sources */ = {isa = PBXBuildFile; fileRef = F76C3B881C638A4C00DC4301 /* CCError.m */; };
 		F71459BA1D12E3B700CAFEEC /* NSString+TruncateToWidth.m in Sources */ = {isa = PBXBuildFile; fileRef = F73049B91CB567F000C7C320 /* NSString+TruncateToWidth.m */; };
@@ -118,8 +121,6 @@
 		F723B3DD22FC6D1D00301EFE /* NCShareCommentsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F723B3DC22FC6D1C00301EFE /* NCShareCommentsCell.xib */; };
 		F7267A82225DFCE100D6DB7D /* AFNetworking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7267A81225DFCE100D6DB7D /* AFNetworking.framework */; };
 		F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */ = {isa = PBXBuildFile; fileRef = F726EEEB1FED1C820030B9C8 /* NCEndToEndInitialize.swift */; };
-		F729B92B217A2E4E00FE2150 /* NCActionSheetHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */; };
-		F729B92D217A2F1B00FE2150 /* NCActionSheetHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */; };
 		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 */; };
@@ -359,7 +360,6 @@
 		F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454722E9F20D000A798A /* NCShareNetworking.swift */; };
 		F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCF1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
-		F76C6F8E21943C8C0063591B /* NCActionSheetHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76C6F8D21943C8C0063591B /* NCActionSheetHeader.swift */; };
 		F771E3D320E2392D00AFB62D /* FileProviderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F771E3D220E2392D00AFB62D /* FileProviderExtension.swift */; };
 		F771E3D520E2392D00AFB62D /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F771E3D420E2392D00AFB62D /* FileProviderItem.swift */; };
 		F771E3D720E2392D00AFB62D /* FileProviderEnumerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F771E3D620E2392D00AFB62D /* FileProviderEnumerator.swift */; };
@@ -386,7 +386,6 @@
 		F77B0E221D118A16002130FE /* CCManageLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = F7BFCCC11B68C21900548E76 /* CCManageLocation.m */; };
 		F77B0E301D118A16002130FE /* CCHud.m in Sources */ = {isa = PBXBuildFile; fileRef = F7514EDB1C7B1336008F3338 /* CCHud.m */; };
 		F77B0E311D118A16002130FE /* CCExifGeo.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A54C351C6267B500E2C8BF /* CCExifGeo.m */; };
-		F77B0E4C1D118A16002130FE /* CCDetail.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D0E65F1BC5042E008D989A /* CCDetail.m */; };
 		F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42F1BAC0268006C0017 /* CCManageAutoUpload.m */; };
 		F77B0E5F1D118A16002130FE /* CCSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE4311BAC0268006C0017 /* CCSettings.m */; };
 		F77B0E671D118A16002130FE /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = F70F05261C889184008DAB36 /* Reachability.m */; };
@@ -780,6 +779,9 @@
 		F70F05571C889184008DAB36 /* UIImage+animatedGIF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+animatedGIF.h"; sourceTree = "<group>"; };
 		F70F05581C889184008DAB36 /* UIImage+animatedGIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+animatedGIF.m"; sourceTree = "<group>"; };
 		F70F2BA4225F2D8900EBB73E /* ZIPFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ZIPFoundation.framework; path = Carthage/Build/iOS/ZIPFoundation.framework; sourceTree = "<group>"; };
+		F710D1F42405770F00A6033D /* NCViewerPDF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerPDF.swift; sourceTree = "<group>"; };
+		F710D1F624057C9400A6033D /* NCDetailNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCDetailNavigationController.swift; sourceTree = "<group>"; };
+		F710D1F824057C9D00A6033D /* NCDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCDetailViewController.swift; sourceTree = "<group>"; };
 		F710E80F1EF95C9C00DC2427 /* ImagesIntro.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ImagesIntro.xcassets; sourceTree = "<group>"; };
 		F7151A811D477A4B00E6AF45 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F7169A171EE590930086BD69 /* NCShares.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCShares.h; sourceTree = "<group>"; };
@@ -803,8 +805,6 @@
 		F728B2BB23E83AD200E12DA0 /* Notification_Service_Extension.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Notification_Service_Extension.plist; sourceTree = "<group>"; };
 		F728B2BC23E83AD200E12DA0 /* Notification_Service_Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Notification_Service_Extension.entitlements; sourceTree = "<group>"; };
 		F7296A661C8880ED001A7809 /* CCloadItemData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCloadItemData.swift; sourceTree = "<group>"; };
-		F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCActionSheetHeaderView.xib; sourceTree = "<group>"; };
-		F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCActionSheetHeaderView.swift; sourceTree = "<group>"; };
 		F72AAEC21E5C60C700BB17E1 /* AHKActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AHKActionSheet.h; sourceTree = "<group>"; };
 		F72AAEC31E5C60C700BB17E1 /* AHKActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AHKActionSheet.m; sourceTree = "<group>"; };
 		F72AAEC41E5C60C700BB17E1 /* AHKActionSheetViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AHKActionSheetViewController.h; sourceTree = "<group>"; };
@@ -1103,7 +1103,6 @@
 		F76C3B841C6388BC00DC4301 /* CCGraphics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCGraphics.m; sourceTree = "<group>"; };
 		F76C3B871C638A4C00DC4301 /* CCError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCError.h; sourceTree = "<group>"; };
 		F76C3B881C638A4C00DC4301 /* CCError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCError.m; sourceTree = "<group>"; };
-		F76C6F8D21943C8C0063591B /* NCActionSheetHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActionSheetHeader.swift; sourceTree = "<group>"; };
 		F76E71E42244DF6900690001 /* Zip.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Zip.framework; path = Carthage/Build/iOS/Zip.framework; sourceTree = "<group>"; };
 		F76F23321ED4600700C40023 /* Share-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Share-Bridging-Header.h"; sourceTree = "<group>"; };
 		F771E3D020E2392D00AFB62D /* File Provider Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "File Provider Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1144,7 +1143,6 @@
 		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>"; };
@@ -1275,8 +1273,6 @@
 		F7CC04E61F5AD50D00378CEF /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F7CE8AFA1DC1F8D8009CAE48 /* Nextcloud.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Nextcloud.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		F7CE8AFB1DC1F8D8009CAE48 /* Share.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Share.appex; sourceTree = BUILT_PRODUCTS_DIR; };
-		F7D0E65E1BC5042E008D989A /* CCDetail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CCDetail.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
-		F7D0E65F1BC5042E008D989A /* CCDetail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCDetail.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
 		F7D154271E2392A300202FD9 /* Nextcloud-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Nextcloud-Bridging-Header.h"; sourceTree = "<group>"; };
 		F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCViewerRichWorkspace.storyboard; sourceTree = "<group>"; };
 		F7D2D125230804DF00FD3ED7 /* NCXMLListParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCXMLListParser.h; sourceTree = "<group>"; };
@@ -1656,27 +1652,25 @@
 		F70211F31BAC56E9003FC03E /* Main */ = {
 			isa = PBXGroup;
 			children = (
-				F78ACD5921904E460088454D /* ActionSheetHeaderView */,
-				F78ACD3E21903BA20088454D /* Cell */,
-				F7DFB7E9219C5A0500680748 /* Create cloud */,
-				F78ACD4D219043E70088454D /* Layout */,
-				371B5A2F23D0B04B00FAFAE9 /* Menu */,
-				F78ACD50219046AC0088454D /* Section */,
-				F7D0E65E1BC5042E008D989A /* CCDetail.h */,
-				F7D0E65F1BC5042E008D989A /* CCDetail.m */,
 				F70211FA1BAC56E9003FC03E /* CCMain.h */,
 				F70211FB1BAC56E9003FC03E /* CCMain.m */,
 				F73F537E1E929C8500F8678D /* CCMore.swift */,
 				F78F6FAE1CC8CCB700F4EA25 /* CCSection.h */,
 				F78F6FAF1CC8CCB700F4EA25 /* CCSection.m */,
+				F78ACD3E21903BA20088454D /* Cell */,
+				F7DFB7E9219C5A0500680748 /* Create cloud */,
+				F78ACD4D219043E70088454D /* Layout */,
 				F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
-				F7E09CE223E3087F00FB3E9E /* NCMainRefreshControl.swift */,
-				F7E09CE623E308AD00FB3E9E /* NCMasterNavigationController.swift */,
-				F7E09CE423E3088A00FB3E9E /* NCSplitViewController.swift */,
+				371B5A2F23D0B04B00FAFAE9 /* Menu */,
+				F710D1F624057C9400A6033D /* NCDetailNavigationController.swift */,
+				F710D1F824057C9D00A6033D /* NCDetailViewController.swift */,
 				F7D6650620FF341600BFBA9E /* NCMainCommon.swift */,
+				F7E09CE223E3087F00FB3E9E /* NCMainRefreshControl.swift */,
 				F7682FDF23C36B0500983A04 /* NCMainTabBar.swift */,
-				F77F5D2C23D5F28100D2B7EB /* NCMainRefreshControl.swift */,
+				F7E09CE623E308AD00FB3E9E /* NCMasterNavigationController.swift */,
 				F77444F7222816D5000D5EB0 /* NCPhotosPickerViewController.swift */,
+				F7E09CE423E3088A00FB3E9E /* NCSplitViewController.swift */,
+				F78ACD50219046AC0088454D /* Section */,
 			);
 			path = Main;
 			sourceTree = "<group>";
@@ -2267,16 +2261,6 @@
 			path = Section;
 			sourceTree = "<group>";
 		};
-		F78ACD5921904E460088454D /* ActionSheetHeaderView */ = {
-			isa = PBXGroup;
-			children = (
-				F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */,
-				F76C6F8D21943C8C0063591B /* NCActionSheetHeader.swift */,
-				F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */,
-			);
-			path = ActionSheetHeaderView;
-			sourceTree = "<group>";
-		};
 		F78F74322163753B00C2ADAD /* Trash */ = {
 			isa = PBXGroup;
 			children = (
@@ -2292,6 +2276,7 @@
 			isa = PBXGroup;
 			children = (
 				F72D404823D2082500A97FD0 /* NCViewerNextcloudText.swift */,
+				F710D1F42405770F00A6033D /* NCViewerPDF.swift */,
 				F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */,
 				F7FB1D3D215E191D00D669EA /* NCViewerDocumentWeb.swift */,
 				F79630ED215527D40015EEA5 /* NCViewerMedia.swift */,
@@ -3255,7 +3240,6 @@
 				F7632FBF21832F8700721B71 /* NCTrashSectionHeaderMenu.xib in Resources */,
 				F7D423431F0596AC009C9782 /* Reader-Export@3x.png in Resources */,
 				F7D4233C1F0596AC009C9782 /* Reader-Button-N@2x.png in Resources */,
-				F729B92B217A2E4E00FE2150 /* NCActionSheetHeaderView.xib in Resources */,
 				F7D423411F0596AC009C9782 /* Reader-Export.png in Resources */,
 				F739513A221B127F00D986C8 /* NCSectionMediaHeader.xib in Resources */,
 				F77B0F481D118A16002130FE /* synchronized.gif in Resources */,
@@ -3637,13 +3621,13 @@
 				F760F79421F21F61006B1A73 /* ResizeControl.swift in Sources */,
 				F7DFB7F2219C5C0000680748 /* NCCreateFormUploadFileText.swift in Sources */,
 				371B5A2E23D0B04500FAFAE9 /* NCMainMenuTableViewController.swift in Sources */,
-				F76C6F8E21943C8C0063591B /* NCActionSheetHeader.swift in Sources */,
 				F760F79121F21F61006B1A73 /* EmojiCollectionViewCell.swift in Sources */,
 				F750374F1DBFA91A008FB480 /* NSArray+PureLayout.m in Sources */,
 				F77444F8222816D5000D5EB0 /* NCPhotosPickerViewController.swift in Sources */,
 				F77B0E141D118A16002130FE /* CCError.m in Sources */,
 				F7E09CE523E3088C00FB3E9E /* NCSplitViewController.swift in Sources */,
 				F73B4F131F470D9100BBEE4B /* nsUniversalDetector.cpp in Sources */,
+				F710D1F724057C9400A6033D /* NCDetailNavigationController.swift in Sources */,
 				F769454622E9F1B0000A798A /* NCShareCommon.swift in Sources */,
 				F7B0C1751EE839A30033AC24 /* NCAutoUpload.m in Sources */,
 				F77B0E161D118A16002130FE /* AFViewShaker.m in Sources */,
@@ -3706,7 +3690,6 @@
 				F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */,
 				F73CC0781E813DFF006E3047 /* BKShiftingView.m in Sources */,
 				F7A3218C1E9E42B30069AD1B /* CCMenuAccount.m in Sources */,
-				F77B0E4C1D118A16002130FE /* CCDetail.m in Sources */,
 				F762CB191EACB66200B38484 /* XLFormValidator.m in Sources */,
 				F760F78C21F21F61006B1A73 /* StickersViewController.swift in Sources */,
 				F762CB0D1EACB66200B38484 /* NSArray+XLFormAdditions.m in Sources */,
@@ -3717,7 +3700,6 @@
 				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 */,
 				F73CC0691E813DFF006E3047 /* BKPasscodeDummyViewController.m in Sources */,
 				F762CB1A1EACB66200B38484 /* XLForm.m in Sources */,
@@ -3749,6 +3731,7 @@
 				F73B4F051F470D9100BBEE4B /* nsCharSetProber.cpp in Sources */,
 				F77B0E671D118A16002130FE /* Reachability.m in Sources */,
 				F762CB121EACB66200B38484 /* UIView+XLFormAdditions.m in Sources */,
+				F710D1F52405770F00A6033D /* NCViewerPDF.swift in Sources */,
 				F7501C332212E57500FB1415 /* NCMedia.swift in Sources */,
 				F70BFC7420E0FA7D00C67599 /* NCUtility.swift in Sources */,
 				F73CC06F1E813DFF006E3047 /* BKPasscodeInputView.m in Sources */,
@@ -3812,6 +3795,7 @@
 				F7E0E1DC22327885006B0911 /* NCAudioRecorderViewController.swift in Sources */,
 				F70CAE3A1F8CF31A008125FD /* NCEndToEndEncryption.m in Sources */,
 				3781B9B423DB2BC9006B4B1D /* CCFavorites+Menu.swift in Sources */,
+				F710D1F924057C9D00A6033D /* NCDetailViewController.swift in Sources */,
 				F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */,
 				F73B4F0C1F470D9100BBEE4B /* nsHebrewProber.cpp in Sources */,
 				F762CAFB1EACB66200B38484 /* XLFormDatePickerCell.m in Sources */,

+ 4 - 2
iOSClient/AppDelegate.h

@@ -24,12 +24,12 @@
 #import <Foundation/Foundation.h>
 #import <UserNotifications/UserNotifications.h>
 #import <PushKit/PushKit.h>
+#import <AVKit/AVKit.h>
 
 #import "BKPasscodeLockScreenManager.h"
 #import "Reachability.h"
 #import "CCBKPasscode.h"
 #import "CCUtility.h"
-#import "CCDetail.h"
 #import "CCMain.h"
 #import "CCSettings.h"
 #import "CCFavorites.h"
@@ -40,6 +40,7 @@
 @class NCOffline;
 @class NCAppConfigView;
 @class IMImagemeterViewer;
+@class NCDetailViewController;
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate, BKPasscodeLockScreenManagerDelegate, BKPasscodeViewControllerDelegate, CCNetworkingDelegate, UNUserNotificationCenterDelegate>
 
@@ -78,6 +79,7 @@
 // Audio Video
 @property (nonatomic, strong) AVPlayer *player;
 @property (nonatomic, strong) AVPlayerViewController *playerController;
+@property BOOL isMediaObserver;
 
 // Push Norification Token
 @property (nonatomic, strong) NSString *pushKitToken;
@@ -90,7 +92,7 @@
 @property (nonatomic, strong) CCMain *homeMain;
 @property (nonatomic, strong) CCFavorites *activeFavorites;
 @property (nonatomic, strong) NCMedia *activeMedia;
-@property (nonatomic, retain) CCDetail *activeDetail;
+@property (nonatomic, retain) NCDetailViewController *activeDetail;
 @property (nonatomic, retain) CCTransfers *activeTransfers;
 @property (nonatomic, retain) CCLogin *activeLogin;
 @property (nonatomic, retain) NCLoginWeb *activeLoginWeb;

+ 1 - 4
iOSClient/AppDelegate.m

@@ -26,7 +26,6 @@
 #import "CCGraphics.h"
 #import "CCSynchronize.h"
 #import "CCMain.h"
-#import "CCDetail.h"
 #import <Fabric/Fabric.h>
 #import <Crashlytics/Crashlytics.h>
 #import "NCBridgeSwift.h"
@@ -214,9 +213,7 @@
     [self pushNotification];
     
     NSLog(@"[LOG] RichDocument");
-    if (self.activeDetail.richDocument) {
-        [self.activeDetail.richDocument grabFocus];
-    }
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"ViewerRichdocumentGrabFocus" object:nil];
 }
 
 //

+ 2 - 1
iOSClient/BrowserWeb/NCBrowserWeb.swift

@@ -7,6 +7,7 @@
 //
 
 import Foundation
+import WebKit
 
 @objc protocol NCBrowserWebDelegate: class {
     @objc optional func browserWebDismiss()
@@ -51,7 +52,7 @@ class NCBrowserWeb: UIViewController {
         var request = URLRequest(url: url)
         
         request.addValue("true", forHTTPHeaderField: "OCS-APIRequest")
-        request.addValue(language, forHTTPHeaderField: "Accept-Language")        
+        request.addValue(language, forHTTPHeaderField: "Accept-Language")
         webView.customUserAgent = CCUtility.getUserAgent()
 
         webView.load(request)

+ 0 - 3
iOSClient/Favorites/CCFavorites.h

@@ -24,7 +24,6 @@
 #import <UIKit/UIKit.h>
 #import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
 
-#import "CCDetail.h"
 #import "AHKActionSheet.h"
 #import "CCCellMain.h"
 #import "CCCellMainTransfer.h"
@@ -44,8 +43,6 @@
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleViewControl;
 
-@property (nonatomic, weak) CCDetail *detailViewController;
-
 - (void)shouldPerformSegue:(tableMetadata *)metadata selector:(NSString *)selector;
 - (void)reloadDatasource:(NSString *)ocId action:(NSInteger)action;
 - (void)listingFavorites;

+ 8 - 15
iOSClient/Favorites/CCFavorites.m

@@ -674,8 +674,9 @@
         return;
     
     // Collapsed but i am in detail -> exit
-    if (self.splitViewController.isCollapsed)
-        if (self.detailViewController.isViewLoaded && self.detailViewController.view.window) return;
+    if (self.splitViewController.isCollapsed) {
+        if (appDelegate.activeDetail.isViewLoaded && appDelegate.activeDetail.view.window) return;
+    }
     
     // Metadata for push detail
     self.metadataForPushDetail = metadata;
@@ -686,14 +687,8 @@
 
 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
-    id viewController = segue.destinationViewController;
-    
-    if ([viewController isKindOfClass:[UINavigationController class]]) {
-        UINavigationController *nav = viewController;
-        _detailViewController = (CCDetail *)nav.topViewController;
-    } else {
-        _detailViewController = segue.destinationViewController;
-    }
+    UINavigationController *navigationController = segue.destinationViewController;
+    NCDetailViewController *detailViewController = (NCDetailViewController *)navigationController.topViewController;
     
     NSMutableArray *photoDataSource = [NSMutableArray new];
     
@@ -703,12 +698,10 @@
             [photoDataSource addObject:metadata];
     }
     
-    _detailViewController.metadataDetail = self.metadataForPushDetail;
-    _detailViewController.selectorDetail = self.selectorForPushDetail;
-    _detailViewController.dateFilterQuery = nil;
-    _detailViewController.photoDataSource = photoDataSource;
+    detailViewController.metadata = self.metadataForPushDetail;
+    detailViewController.selector = self.selectorForPushDetail;
     
-    [_detailViewController setTitle:self.metadata.fileNameView];
+    [detailViewController setTitle:self.metadata.fileNameView];
 }
 
 @end

+ 1 - 0
iOSClient/Login/NCLoginWeb.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import WebKit
 
 class NCLoginWeb: UIViewController {
     

+ 0 - 60
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift

@@ -1,60 +0,0 @@
-//
-//  NCActionSheetHeader.swift
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 08/11/2018.
-//  Copyright © 2018 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 NCActionSheetHeader: NSObject {
-    
-    @objc static let sharedInstance: NCActionSheetHeader = {
-        let instance = NCActionSheetHeader()
-        return instance
-    }()
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
-    func actionSheetHeader(isDirectory: Bool, iconName: String, ocId: String, fileNameView: String, text: String) -> UIView? {
-        
-        var image: UIImage?
-        
-        // Header
-        if isDirectory {
-            image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
-        } else if iconName.count > 0 {
-            image = UIImage.init(named: iconName)
-        } else {
-            image = UIImage.init(named: "file")
-        }
-        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(ocId, fileNameView: fileNameView)) {
-            image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(ocId, fileNameView: fileNameView))
-        }
-        
-        let headerView = UINib(nibName: "NCActionSheetHeaderView", bundle: nil).instantiate(withOwner: self, options: nil).first as! NCActionSheetHeaderView
-        
-        headerView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
-        headerView.imageItem.image = image
-        headerView.label.text = text
-        headerView.label.textColor = NCBrandColor.sharedInstance.icon
-        
-        return headerView
-    }
-}

+ 0 - 51
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeaderView.xib

@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina5_5" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
-        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <view contentMode="scaleToFill" id="I6b-nN-xlb" customClass="NCActionSheetHeaderView" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="414" height="50"/>
-            <autoresizingMask key="autoresizingMask"/>
-            <subviews>
-                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lfq-lr-NgS" userLabel="ImageItem">
-                    <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="50" id="LyU-cM-aSJ"/>
-                        <constraint firstAttribute="width" constant="50" id="dY1-pJ-pdP"/>
-                    </constraints>
-                </imageView>
-                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yAB-e1-3vF">
-                    <rect key="frame" x="55" y="0.0" width="354" height="50"/>
-                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                    <nil key="textColor"/>
-                    <nil key="highlightedColor"/>
-                </label>
-            </subviews>
-            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-            <constraints>
-                <constraint firstItem="yAB-e1-3vF" firstAttribute="leading" secondItem="lfq-lr-NgS" secondAttribute="trailing" constant="5" id="0ZQ-29-0WG"/>
-                <constraint firstItem="2A6-rU-2Mc" firstAttribute="bottom" secondItem="yAB-e1-3vF" secondAttribute="bottom" id="BjK-gV-vSx"/>
-                <constraint firstItem="lfq-lr-NgS" firstAttribute="leading" secondItem="2A6-rU-2Mc" secondAttribute="leading" id="cMS-FO-o0J"/>
-                <constraint firstItem="yAB-e1-3vF" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="gFc-7X-Z4w"/>
-                <constraint firstItem="lfq-lr-NgS" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="nlU-7A-uMz"/>
-                <constraint firstItem="2A6-rU-2Mc" firstAttribute="trailing" secondItem="yAB-e1-3vF" secondAttribute="trailing" constant="5" id="zl1-OY-Erp"/>
-            </constraints>
-            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
-            <viewLayoutGuide key="safeArea" id="2A6-rU-2Mc"/>
-            <connections>
-                <outlet property="imageItem" destination="lfq-lr-NgS" id="jW9-9z-oNq"/>
-                <outlet property="label" destination="yAB-e1-3vF" id="SiI-G5-9og"/>
-            </connections>
-            <point key="canvasLocation" x="-479.71014492753625" y="196.46739130434784"/>
-        </view>
-    </objects>
-</document>

+ 0 - 83
iOSClient/Main/CCDetail.h

@@ -1,83 +0,0 @@
-//
-//  CCDetail.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 16/01/15.
-//  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 <UIKit/UIKit.h>
-#import <Foundation/Foundation.h>
-#import <WebKit/WebKit.h>
-
-#import "UIImage+animatedGIF.h"
-#import "MWPhotoBrowser.h"
-#import "ReaderViewController.h"
-#import "CCGraphics.h"
-
-@class tableMetadata;
-@class NCViewerImagemeter;
-@class NCViewerRichdocument;
-@class NCViewerNextcloudText;
-
-@interface CCDetail : UIViewController <MWPhotoBrowserDelegate, ReaderViewControllerDelegate>
-
-@property(nonatomic, weak) IBOutlet UIImageView *viewBackground;
-
-@property (nonatomic, strong) tableMetadata *metadataDetail;
-@property (nonatomic, strong) NSString *selectorDetail;
-@property (nonatomic, strong) NSDate *dateFilterQuery;
-
-- (void)viewFile;
-
-// Toolbar
-@property (nonatomic, strong) UIToolbar *toolbar;
-
-// Document
-@property (nonatomic, strong) WKWebView *webView;
-
-// Media
-@property (nonatomic, strong) UIBarButtonItem *buttonAction;
-@property BOOL isMediaObserver;
-
-// Photo
-@property (nonatomic, strong) NSMutableArray *photoDataSource;
-@property (nonatomic, strong) MWPhotoBrowser *photoBrowser;
-@property (nonatomic, strong) NSMutableArray *photos;
-
-// PDF
-@property (nonatomic, strong) ReaderViewController *readerPDFViewController;
-@property (nonatomic, strong) NSString *passwordPDF;
-
-// RichDocument
-@property (nonatomic, strong) NCViewerRichdocument *richDocument;
-
-// NextcloudText
-@property (nonatomic, strong) NCViewerNextcloudText *nextcloudText;
-
-// IM
-@property (nonatomic, strong) NCViewerImagemeter *imagemeter;
-
-
-- (void)changeToDisplayMode;
-- (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode;
-
-@end
-
-
-

+ 0 - 1045
iOSClient/Main/CCDetail.m

@@ -1,1045 +0,0 @@
-//
-//  CCDetail.m
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 16/01/15.
-//  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 "CCDetail.h"
-#import "AppDelegate.h"
-#import "CCMain.h"
-#import "NCUchardet.h"
-#import "NCBridgeSwift.h"
-
-#import "NCBridgeSwift.h"
-
-#define alertRequestPasswordPDF 1
-
-@interface CCDetail () <NCTextDelegate, UIDocumentInteractionControllerDelegate>
-{
-    AppDelegate *appDelegate;
-    
-    UIDocumentInteractionController *docController;
-    
-    UIBarButtonItem *buttonModifyFile;
-    UIBarButtonItem *buttonShare;
-    UIBarButtonItem *buttonDelete;
-    
-    NSInteger indexNowVisible;
-    NSString *ocIdNowVisible;
-    
-    NSString *fileNameExtension;
-}
-@end
-
-@implementation CCDetail
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== init =====
-#pragma --------------------------------------------------------------------------------------------
-
--  (id)initWithCoder:(NSCoder *)aDecoder
-{
-    if (self = [super initWithCoder:aDecoder])  {
-        
-        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
-
-        self.metadataDetail = [[tableMetadata alloc] init];
-        self.photos = [[NSMutableArray alloc] init];
-        self.photoDataSource = [NSMutableArray new];
-        indexNowVisible = -1;
-        ocIdNowVisible = nil;
-
-        appDelegate.activeDetail = self;
-    }
-    return self;
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== View =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)viewDidLoad
-{
-    [super viewDidLoad];
-    
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insertGeocoderLocation:) name:@"insertGeocoderLocation" object:nil];
-        
-    [self changeTheming];
-    
-    // Open View
-    if ([self.metadataDetail.fileNameView length] > 0 || [self.metadataDetail.serverUrl length] > 0 || [self.metadataDetail.ocId length] > 0) {        
-        [self viewFile];
-    }
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
-    [super viewWillAppear:animated];
-    
-    self.tabBarController.tabBar.hidden = YES;
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
-    [super viewWillDisappear:animated];
-
-    self.navigationController.navigationBarHidden = NO;
-    self.tabBarController.tabBar.hidden = NO;
-}
-
-- (void)viewDidDisappear:(BOOL)animated
-{
-    [super viewDidDisappear:animated];
-    
-    // If AVPlayer in play -> Stop
-    if (appDelegate.player != nil && appDelegate.player.rate != 0) {
-        [appDelegate.player pause];
-    }
-    
-    // remove Observer AVPlayer
-    if (self.isMediaObserver) {
-        self.isMediaObserver = NO;
-        @try{
-            [[NCViewerMedia sharedInstance] removeObserver];
-        }@catch(id anException) { }
-    }
-}
-
-- (void)changeTheming
-{
-    [appDelegate changeTheming:self tableView:nil collectionView:nil form:false];
-    
-    if (self.toolbar) {
-        self.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;
-        self.toolbar.tintColor = NCBrandColor.sharedInstance.brandElement;
-    }
-    
-    // Logo
-    self.viewBackground.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"logo"] multiplier:2 color:[NCBrandColor.sharedInstance.brand colorWithAlphaComponent:0.4]];
-
-    // reload image
-    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image]) {
-        
-        self.edgesForExtendedLayout = UIRectEdgeAll;
-        [self viewImage];
-    }
-}
-
-- (void)changeToDisplayMode
-{
-    if (_readerPDFViewController) {
-        [self.readerPDFViewController updateContentViews];
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== View File  =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)viewFile
-{
-    // Remove all subview except ..
-    //for (UIView *view in self.view.superview.subviews) {
-    //    NSInteger tag = view.tag;
-    //}
-    
-    // Title
-    self.navigationController.navigationBar.topItem.title = _metadataDetail.fileNameView;
-    if (!self.splitViewController.isCollapsed) {
-        self.navigationController.topViewController.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
-    }
-    
-    // verifico se esiste l'icona e se la posso creare
-    if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconOcId:self.metadataDetail.ocId fileNameView:self.metadataDetail.fileNameView]] == NO) {
-        [CCGraphics createNewImageFrom:self.metadataDetail.fileNameView ocId:self.metadataDetail.ocId extension:[self.metadataDetail.fileNameView pathExtension] filterGrayScale:NO typeFile:self.metadataDetail.typeFile writeImage:YES];
-    }
-    
-    // remove Observer AVPlayer
-    if (self.isMediaObserver) {
-        self.isMediaObserver = NO;
-        [[NCViewerMedia sharedInstance] removeObserver];
-    }
-    
-    // IMAGE
-    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image]) {
-        
-        self.edgesForExtendedLayout = UIRectEdgeAll;
-        [self viewImage];
-    }
-    
-    // AUDIO VIDEO
-    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_audio]) {
-        
-        self.edgesForExtendedLayout = UIRectEdgeAll;
-        [self createToolbar];
-        [[NCViewerMedia sharedInstance] viewMedia:self.metadataDetail detail:self];
-    }
-    
-    // DOCUMENT - INTERNAL VIEWER
-    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document] && [self.selectorDetail isEqualToString:selectorLoadFileInternalView]) {
-        
-        self.edgesForExtendedLayout = UIRectEdgeBottom;
-        [self createToolbar];
-        [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
-        
-        return;
-    }
-    
-    // DOCUMENT
-    if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document]) {
-                
-        fileNameExtension = [[self.metadataDetail.fileNameView pathExtension] uppercaseString];
-        
-        if ([fileNameExtension isEqualToString:@"PDF"]) {
-            
-            self.edgesForExtendedLayout = UIRectEdgeBottom;
-            [self createToolbar];
-            [self viewPDF:@""];
-            
-            return;
-        }
-        
-        // DirectEditinf: Nextcloud Text - OnlyOffice
-        if ([[NCUtility sharedInstance] isDirectEditing:self.metadataDetail] != nil && appDelegate.reachability.isReachable) {
-            
-            NSString *editor = [[NCUtility sharedInstance] isDirectEditing:self.metadataDetail];
-            if ([editor isEqualToString:k_editor_text] || [editor isEqualToString:k_editor_onlyoffice]) {
-            
-                if([self.metadataDetail.url isEqualToString:@""]) {
-                    
-                    [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view bottom:0];
-                    
-                    NSString *customUserAgent = nil;
-                    NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:self.metadataDetail.fileName serverUrl:self.metadataDetail.serverUrl activeUrl:appDelegate.activeUrl];
-
-                    if ([editor isEqualToString:k_editor_onlyoffice]) {
-                        customUserAgent = [[NCUtility sharedInstance] getCustomUserAgentOnlyOffice];
-                    }
-                    
-                    [[NCCommunication sharedInstance] NCTextOpenFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor:editor customUserAgent:customUserAgent account:self.metadataDetail.account completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
-                        
-                        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-                            
-                            self.nextcloudText = [[NCViewerNextcloudText alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
-                            [self.view addSubview:self.nextcloudText];
-                            [self.nextcloudText viewerAt:url detail:self metadata:self.metadataDetail editor:editor];
-                            
-                        } 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.");
-                            }
-                            
-                            [self.navigationController popViewControllerAnimated:YES];
-                        }
-                    }];
-                    
-                } else {
-                    
-                    self.nextcloudText = [[NCViewerNextcloudText alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
-                    [self.view addSubview:self.nextcloudText];
-                    [self.nextcloudText viewerAt:self.metadataDetail.url detail:self metadata:self.metadataDetail editor:editor];
-                }
-            }
-            
-            return;
-        }        
-        
-        // RichDocument
-        if ([[NCUtility sharedInstance] isRichDocument:self.metadataDetail] && appDelegate.reachability.isReachable) {
-            
-            [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view bottom:0];
-            
-            if ([self.metadataDetail.url isEqualToString:@""]) {
-                [[OCNetworking sharedManager] createLinkRichdocumentsWithAccount:appDelegate.activeAccount fileId:self.metadataDetail.fileId completion:^(NSString *account, NSString *link, NSString *message, NSInteger errorCode) {
-                    
-                    if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-                        
-                        self.richDocument = [[NCViewerRichdocument alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
-                        [self.view addSubview:self.richDocument];
-                        [self.richDocument viewRichDocumentAt:link detail:self metadata:self.metadataDetail];
-
-                    } else {
-                        
-                        [[NCUtility sharedInstance] stopActivityIndicator];
-                        
-                        if (errorCode != 0) {
-                            [[NCContentPresenter shared] messageNotification:@"_error_" description:message delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-                        } else {
-                            NSLog(@"[LOG] It has been changed user during networking process, error.");
-                        }
-                        
-                        [self.navigationController popViewControllerAnimated:YES];
-                    }
-                }];
-                
-            } else {
-                
-                self.richDocument = [[NCViewerRichdocument alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
-                [self.view addSubview:self.richDocument];
-                [self.richDocument viewRichDocumentAt:self.metadataDetail.url detail:self metadata:self.metadataDetail];
-            }
-            
-            return;
-        }
-        
-        self.edgesForExtendedLayout = UIRectEdgeBottom;
-        [self createToolbar];
-        [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Toolbar  =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)createToolbar
-{
-    CGFloat masterToolBarHeight = appDelegate.activeMain.tabBarController.tabBar.bounds.size.height;
-    self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - masterToolBarHeight, self.view.bounds.size.width, masterToolBarHeight)];
-    
-    UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
-    UIBarButtonItem *fixedSpaceMini = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
-    fixedSpaceMini.width = 25;
-    
-    buttonModifyFile = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"actionSheetModify"] style:UIBarButtonItemStylePlain target:self action:@selector(modifyFileButtonPressed:)];
-    if (![NCBrandOptions sharedInstance].disable_openin_file) {
-        self.buttonAction = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"openFile"] style:UIBarButtonItemStylePlain target:self action:@selector(actionButtonPressed:)];
-    }
-    buttonShare  = [[UIBarButtonItem alloc] initWithImage:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] style:UIBarButtonItemStylePlain target:self action:@selector(shareButtonPressed:)];
-    buttonDelete = [[UIBarButtonItem alloc] initWithImage:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"trash"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] style:UIBarButtonItemStylePlain target:self action:@selector(deleteButtonPressed:)];
-    
-    if ([CCUtility isDocumentModifiableExtension:fileNameExtension]) {
-        if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
-            [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyFile, flexible, buttonDelete, fixedSpaceMini, self.buttonAction,  nil]];
-        else
-            [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyFile, flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction,  nil]];
-    } else {
-        if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
-            [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, self.buttonAction,  nil]];
-        else
-            [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction,  nil]];
-    }
-    
-    [self.toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
-    
-    self.toolbar.barTintColor = NCBrandColor.sharedInstance.tabBar;
-    self.toolbar.tintColor = NCBrandColor.sharedInstance.brandElement;
-
-    [self.view addSubview:self.toolbar];
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== View Image =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)viewImage
-{
-    self.photoBrowser = [[MWPhotoBrowser alloc] initWithDelegate:self];
-    indexNowVisible = -1;
-    ocIdNowVisible = nil;
-    
-    [self.photos removeAllObjects];
-    
-    // if not images, exit
-    if ([self.photoDataSource count] == 0)
-        return;
-
-    NSUInteger index = 0;
-    for (tableMetadata *metadata in self.photoDataSource) {
-        
-        // start from here ?
-        if (self.metadataDetail.ocId && [metadata.ocId isEqualToString:self.metadataDetail.ocId])
-            [self.photoBrowser setCurrentPhotoIndex:index];
-        
-        [self.photos addObject:[MWPhoto photoWithImage:nil]];
-        
-        // add directory
-        index++;
-    }
-    
-    // PhotoBrowser
-    if ([NCBrandOptions sharedInstance].disable_openin_file) {
-        self.photoBrowser.displayActionButton = NO;
-    } else {
-        self.photoBrowser.displayActionButton = YES;
-    }
-    self.photoBrowser.displayDeleteButton = YES;
-    if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
-        self.photoBrowser.displayShareButton = NO;
-    else
-        self.photoBrowser.displayShareButton = YES;
-    self.photoBrowser.displayNavArrows = YES;
-    self.photoBrowser.displaySelectionButtons = NO;
-    self.photoBrowser.alwaysShowControls = NO;
-    self.photoBrowser.zoomPhotosToFill = NO;
-    self.photoBrowser.autoPlayOnAppear = NO;
-    self.photoBrowser.delayToHideElements = 15;
-    
-    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
-        self.photoBrowser.enableSwipeToDismiss = NO;
-    
-    if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
-        
-        [self addChildViewController:self.photoBrowser];
-        [self.view addSubview:self.photoBrowser.view];
-        [self.photoBrowser didMoveToParentViewController:self];
-        
-    } else {
-        
-        [self.navigationController pushViewController:self.photoBrowser animated:NO];
-    }
-    
-    self.navigationController.navigationBar.topItem.title = _metadataDetail.fileNameView;
-}
-
-- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser
-{
-    return [self.photoDataSource count];
-}
-
-- (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index
-{
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    
-    NSString *titleDir = metadata.fileNameView;
-    self.title = titleDir;
-    
-    return titleDir;
-}
-
-- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index
-{
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    
-    indexNowVisible = index;
-    ocIdNowVisible = metadata.ocId;
-    
-    photoBrowser.toolbar.hidden = NO;
-    
-    // Download image ?
-    if (metadata) {
-        
-        NSInteger status;
-        tableMetadata *metadataDB = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", metadata.ocId]];
-        if (metadataDB) {
-            status = metadataDB.status;
-        } else {
-            status = k_metadataStatusNormal;
-        }
-        
-        if ([CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView] == NO && status == k_metadataStatusNormal) {
-            
-            if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId fileNameView:metadata.fileNameView]] == NO && metadata.hasPreview) {
-                
-                [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:NCBrandColor.sharedInstance.brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:NCBrandColor.sharedInstance.brandText] imageRight:NO navigationItem:self.navigationItem];
-                
-                CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
-                CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
-
-                [[OCNetworking sharedManager] downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, UIImage *image, NSString *message, NSInteger errorCode) {
-
-                    self.navigationItem.titleView = nil;
-                    self.title = metadata.fileNameView;
-                    
-                    if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-                        [self.photoBrowser reloadData];
-                    }
-                }];
-            } else {
-                [self downloadPhotoBrowser:metadata];
-            }
-        }
-    }
-    
-    // Title
-    if (metadata)
-        self.title = metadata.fileNameView;
-}
-
-- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
-{
-    UIImage *image;
-
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    
-    if (index < self.photos.count) {
-        
-        if (metadata.ocId) {
-            
-            UIImage *imagePreview = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId fileNameView:metadata.fileNameView]];
-//            if (!imagePreview) imagePreview = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"file_photo"] multiplier:3 color:[NCBrandColor.sharedInstance icon]];
-            
-            if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image]) {
-                
-                NSString *fileImage = [CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView];
-                NSString *ext = [CCUtility getExtension:metadata.fileNameView];
-                
-                if ([ext isEqualToString:@"GIF"]) image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL fileURLWithPath:fileImage]];
-                else image = [UIImage imageWithContentsOfFile:fileImage];
-                
-                if (image) {
-                    
-                    MWPhoto *photo = [MWPhoto photoWithImage:image];
-                    
-                    // Location ??
-                    [self setLocationCaptionPhoto:photo ocId:metadata.ocId];
-                    
-                    [self.photos replaceObjectAtIndex:index withObject:photo];
-                    
-                } else {
-                    
-                    if (metadata.status == k_metadataStatusDownloadError) {
-                        
-                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
-                        
-                    } else {
-                        
-                        if (imagePreview)
-                            [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
-                    }
-                }
-            }
-            
-            if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video]) {
-                
-                if ([CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView]) {
-                    
-                    NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]];
-                    
-                    MWPhoto *video = [MWPhoto photoWithImage:[CCGraphics thumbnailImageForVideo:url atTime:1.0]];
-                    video.videoURL = url;
-                    
-                    [self.photos replaceObjectAtIndex:index withObject:video];
-                    
-                } else {
-                    
-                    if (metadata.status == k_metadataStatusDownloadError) {
-                        
-                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
-                        
-                    } else {
-                        
-                        if (imagePreview)
-                            [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
-                    }
-                }
-            }
-            
-            if ([metadata.typeFile isEqualToString: k_metadataTypeFile_audio]) {
-                
-                if ([CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView]) {
-                    
-                    MWPhoto *audio;
-                    UIImage *audioImage;
-                    
-                    NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]];
-                    
-                    if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId fileNameView:metadata.fileNameView]]) {
-                        audioImage = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId fileNameView:metadata.fileNameView]];
-                    } else {
-                        audioImage = [UIImage imageNamed:@"notaMusic"]; //[CCGraphics scaleImage:[UIImage imageNamed:@"notaMusic"] toSize:CGSizeMake(200, 200) isAspectRation:YES];
-                    }
-                    
-                    audio = [MWPhoto photoWithImage:audioImage];
-                    audio.videoURL = url;
-                    [self.photos replaceObjectAtIndex:index withObject:audio];
-                    
-                } else {
-                    
-                    if (metadata.status == k_metadataStatusDownloadError) {
-                        
-                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
-                        
-                    } else {
-                        
-                        if (imagePreview)
-                            [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
-                    }
-                }
-            }
-        }
-        
-        // energy saving memory
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            int iPrev = (int)index - 2;
-            if (iPrev >= 0) {
-                if ([self.photos objectAtIndex:iPrev] != nil)
-                    [self.photos replaceObjectAtIndex:iPrev withObject:[MWPhoto photoWithImage:nil]];
-            }
-        
-            int iNext = (int)index + 2;
-            if (iNext < _photos.count) {
-                if ([self.photos objectAtIndex:iNext] != nil)
-                    [self.photos replaceObjectAtIndex:iNext withObject:[MWPhoto photoWithImage:nil]];
-            }
-        });
-        
-        return [self.photos objectAtIndex:index];
-    }
-    
-    return nil;
-}
-
-- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index
-{
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    if (metadata == nil) return;
-
-    docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]]];
-    
-    docController.delegate = self;
-    
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
-        [docController presentOptionsMenuFromRect:photoBrowser.view.frame inView:photoBrowser.view animated:YES];
-    
-    [docController presentOptionsMenuFromBarButtonItem:photoBrowser.actionButton animated:YES];
-}
-
-- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
-{
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:2];
-}
-
-- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
-{
-    tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    if (metadata == nil || [CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView] == NO) {        
-        [[NCContentPresenter shared] messageNotification:@"_info_" description:@"_file_not_found_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:0];
-        return;
-    }
-    
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-    
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
-                                                         style:UIAlertActionStyleDestructive
-                                                       handler:^(UIAlertAction *action) {
-                                                           [self deleteFile:metadata];
-                                                       }]];
-
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
-                                                         style:UIAlertActionStyleCancel
-                                                       handler:^(UIAlertAction *action) {
-                                                       }]];
-    
-    alertController.popoverPresentationController.barButtonItem = deleteButton;
-    
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-        [alertController.view layoutIfNeeded];
-    
-    [self.parentViewController presentViewController:alertController animated:YES completion:NULL];
-}
-
-- (void)photoBrowserDidFinishPresentation:(MWPhotoBrowser *)photoBrowser
-{
-    [self.navigationController popViewControllerAnimated:YES];
-}
-
-- (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode
-{
-    // if a message for a directory of these
-    if (![metadata.ocId isEqualToString:ocIdNowVisible])
-        return;
- 
-    // Title
-    self.navigationItem.titleView = nil;
-    self.title = metadata.fileNameView;
-    
-    if (errorCode == 0) {
-        
-        // verifico se esiste l'icona e se la posso creare
-        if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId fileNameView:metadata.fileNameView]] == NO) {
-            [CCGraphics createNewImageFrom:metadata.fileNameView ocId:metadata.ocId extension:[metadata.fileNameView pathExtension] filterGrayScale:NO typeFile:metadata.typeFile writeImage:YES];
-        }
-        
-        [self.photoBrowser reloadData];
-
-    } else {
-        [[NCContentPresenter shared] messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-        
-        [self.navigationController popViewControllerAnimated:YES];
-    }
-}
-
-- (void)downloadPhotoBrowser:(tableMetadata *)metadata
-{
-    tableMetadata *metadataForDownload = [[NCManageDatabase sharedInstance] initNewMetadata:metadata];
-    
-    metadataForDownload.session = k_download_session;
-    metadataForDownload.sessionError = @"";
-    metadataForDownload.sessionSelector = selectorLoadViewImage;
-    metadataForDownload.status = k_metadataStatusWaitDownload;
-        
-    // Add Metadata for Download
-    (void)[[NCManageDatabase sharedInstance] addMetadata:metadataForDownload];
-    [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl ocId:metadataForDownload.ocId action:k_action_MOD];
-    
-    [appDelegate startLoadAutoDownloadUpload];
-
-    [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:NCBrandColor.sharedInstance.brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:NCBrandColor.sharedInstance.brandText] imageRight:NO navigationItem:self.navigationItem];
-}
-
-- (void)insertGeocoderLocation:(NSNotification *)notification
-{
-    if (notification.userInfo.count == 0)
-        return;
-    
-    NSString *ocId = [[notification.userInfo allKeys] objectAtIndex:0];
-    //NSDate *date = [[notification.userInfo allValues] objectAtIndex:0];
- 
-    // test [Chrash V 1.14,15]
-    if (indexNowVisible >= [self.photos count])
-        return;
-    
-    if ([ocId isEqualToString:ocIdNowVisible]) {
-            
-        MWPhoto *photo = [self.photos objectAtIndex:indexNowVisible];
-            
-        [self setLocationCaptionPhoto:photo ocId:ocId];
-        
-        [self.photoBrowser reloadData];
-    }
-}
-
-- (void)setLocationCaptionPhoto:(MWPhoto *)photo ocId:(NSString *)ocId
-{
-    tableLocalFile *localFile;
-
-    // read Geocoder
-    localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", ocId]];
-    
-    if ([localFile.exifLatitude doubleValue] != 0 || [localFile.exifLongitude doubleValue] != 0) {
-        
-        // Fix BUG Geo latitude & longitude
-        if ([localFile.exifLatitude doubleValue] == 9999 || [localFile.exifLongitude doubleValue] == 9999) {
-            
-            tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", ocId]];
-            if (metadata) {
-                [[CCExifGeo sharedInstance] setExifLocalTableEtag:metadata];
-            }
-        }
-        
-        [[CCExifGeo sharedInstance] setGeocoderEtag:ocId exifDate:localFile.exifDate latitude:localFile.exifLatitude longitude:localFile.exifLongitude];
-        
-        localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", ocId]];
-        
-        if ([localFile.exifLatitude floatValue] != 0 || [localFile.exifLongitude floatValue] != 0) {
-                        
-            NSString *location = [[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:localFile.exifLatitude longitude:localFile.exifLongitude];
-            
-            if ([localFile.exifDate isEqualToDate:[NSDate distantPast]] == NO && location) {
-                
-                NSString *localizedDateTime = [NSDateFormatter localizedStringFromDate:localFile.exifDate dateStyle:NSDateFormatterFullStyle timeStyle:NSDateFormatterMediumStyle];
-                
-                photo.caption = [NSString stringWithFormat:NSLocalizedString(@"%@\n%@", nil), localizedDateTime, location];
-            }
-        }
-    }
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark =====  View PDF =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
-    
-    [[alertView textFieldAtIndex:0] resignFirstResponder];
-    
-    if (alertView.tag == alertRequestPasswordPDF) [self performSelector:@selector(viewPDF:) withObject:[alertView textFieldAtIndex:0].text afterDelay:0.3];
-}
-
-- (void)viewPDF:(NSString *)password
-{
-    // remove cache PDF
-    NSString *filePlistReader = [NSString stringWithFormat:@"%@/%@.plist", [CCUtility getDirectoryReaderMetadata], self.metadataDetail.fileNameView.stringByDeletingPathExtension];
-    [CCUtility removeFileAtPath:filePlistReader];
-    
-    NSString *fileNamePath = [CCUtility getDirectoryProviderStorageOcId:self.metadataDetail.ocId fileNameView:self.metadataDetail.fileNameView];
-    
-    if ([CCUtility fileProviderStorageExists:self.metadataDetail.ocId fileNameView:self.metadataDetail.fileNameView] == NO) {
-        
-        // read file error
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
-        
-        [alertController addAction:okAction];
-        [self presentViewController:alertController animated:YES completion:nil];
-    }
-    
-    CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:fileNamePath]);
-    
-    if (pdf) {
-        
-        // Encrypted
-        if (CGPDFDocumentIsEncrypted(pdf) == YES) {
-            
-            // Try a blank password first, per Apple's Quartz PDF example
-            if (CGPDFDocumentUnlockWithPassword(pdf, "") == YES) {
-                
-                // blank password
-                [self readerPDF:fileNamePath password:@""];
-                
-            } else {
-                
-                if ([password length] == 0) {
-                    
-                    // password request
-                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_insert_password_pfd_",nil) message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-                    [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
-                    alertView.tag = alertRequestPasswordPDF;
-                    [alertView show];
-                    
-                } else {
-                    
-                    const char *key = [password UTF8String];
-                    
-                    // failure
-                    if (CGPDFDocumentUnlockWithPassword(pdf, key) == NO) {
-                        
-                        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_password_pdf_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
-                        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
-                        
-                        [alertController addAction:okAction];
-                        [self presentViewController:alertController animated:YES completion:nil];
-                        
-                    } else {
-                        
-                        // pdf with password
-                        [self readerPDF:fileNamePath password:password];
-                    }
-                }
-            }
-            
-        } else{
-            
-            // No password
-            [self readerPDF:fileNamePath password:@""];
-        }
-        
-    } else {
-        
-        // read file error
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
-        
-        [alertController addAction:okAction];
-        [self presentViewController:alertController animated:YES completion:nil];
-    }
-}
-
-- (void)readerPDF:(NSString *)fileName password:(NSString *)password
-{
-    ReaderDocument *documentPDF = [ReaderDocument withDocumentFilePath:fileName password:password];
-    CGFloat masterToolBarHeight = appDelegate.activeMain.tabBarController.tabBar.bounds.size.height;
-    
-    if (documentPDF != nil) {
-        
-        self.readerPDFViewController = [[ReaderViewController alloc] initWithReaderDocument:documentPDF];
-        self.readerPDFViewController.delegate = self;
-        self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - masterToolBarHeight);
-        [self.readerPDFViewController updateContentViews];
-
-        [self addChildViewController:self.readerPDFViewController];
-        [self.view addSubview:self.readerPDFViewController.view];
-        [self.readerPDFViewController didMoveToParentViewController:self];
-        
-    } else {
-
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
-        
-        [alertController addAction:okAction];
-        [self presentViewController:alertController animated:YES completion:nil];
-    }
-}
-
-- (void)handleSingleTapReader
-{
-    UILayoutGuide *layoutGuide;
-    CGFloat safeAreaTop = 0;
-    CGFloat safeAreaBottom = 0;
-    CGFloat masterToolBarHeight = appDelegate.activeMain.tabBarController.tabBar.bounds.size.height;
-    
-    if (@available(iOS 11, *)) {
-        layoutGuide = [UIApplication sharedApplication].delegate.window.safeAreaLayoutGuide;
-        safeAreaTop = [UIApplication sharedApplication].delegate.window.safeAreaInsets.top;
-        safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
-    }
-    
-    self.navigationController.navigationBarHidden = !self.navigationController.navigationBarHidden;
-    self.toolbar.hidden = !self.toolbar.isHidden;
-    
-    if (self.toolbar.isHidden) {
-        self.readerPDFViewController.view.frame = CGRectMake(0, safeAreaTop, self.view.bounds.size.width, self.view.bounds.size.height - safeAreaTop - safeAreaBottom);
-    } else {
-        self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - masterToolBarHeight);
-    }
-    [self.readerPDFViewController updateContentViews];
-}
-
-- (void)handleSwipeUpDown
-{
-    // REMOVE IT'S UNUSABLE
-    /*
-    self.navigationController.navigationBarHidden = false;  // iOS App is unusable after swipe up or down with PDF in fullscreen #526
-
-    [self removeAllView];
-    [self.navigationController popViewControllerAnimated:YES];
-    */
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Delete =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)deleteFile:(tableMetadata *)metadata
-{
-    tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND e2eEncrypted == 1 AND serverUrl == %@", appDelegate.activeAccount, metadata.serverUrl]];
-    
-    [[NCMainCommon sharedInstance ] deleteFileWithMetadatas:[[NSArray alloc] initWithObjects:metadata, nil] e2ee:tableDirectory.e2eEncrypted serverUrl:tableDirectory.serverUrl folderocId:tableDirectory.ocId completion:^(NSInteger errorCode, NSString *message) {
-        
-        if (errorCode == 0) {
-            
-            // reload data source
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:tableDirectory.serverUrl ocId:metadata.ocId action:k_action_DEL];
-            
-            // Not image
-            if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image] == NO) {
-            
-                // exit
-                [self.navigationController popViewControllerAnimated:YES];
-            
-            } else {
-                
-                for (NSUInteger index=0; index < [self.photoDataSource count] && _photoBrowser; index++ ) {
-                    
-                    tableMetadata *metadataTemp = [self.photoDataSource objectAtIndex:index];
-                    
-                    if ([metadata isInvalidated] || [metadataTemp.ocId isEqualToString:metadata.ocId]) {
-                        
-                        [self.photoDataSource removeObjectAtIndex:index];
-                        [self.photos removeObjectAtIndex:index];
-                        [self.photoBrowser reloadData];
-                        
-                        // exit
-                        if ([self.photoDataSource count] == 0) {
-                            [self.navigationController popViewControllerAnimated:YES];
-                        }
-                    }
-                }
-            }
-        } else {
-            NSLog(@"[LOG] DeleteFileOrFolder failure error %d, %@", (int)errorCode, message);
-        }
-    }];
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== ButtonPressed =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)dismissTextView
-{
-    if (self.webView) {
-        
-        NSString *fileNamePath = [NSTemporaryDirectory() stringByAppendingString:self.metadataDetail.fileNameView];
-        
-        [[NSFileManager defaultManager] removeItemAtPath:fileNamePath error:nil];
-        [[NSFileManager defaultManager] linkItemAtPath:[CCUtility getDirectoryProviderStorageOcId:self.metadataDetail.ocId fileNameView:self.metadataDetail.fileNameView] toPath:fileNamePath error:nil];
-        
-        [self.webView reload];
-    }
-}
-
-- (void)modifyFileButtonPressed:(UIBarButtonItem *)sender
-{
-    tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"ocId == %@", self.metadataDetail.ocId]];
-    
-    if (metadata) {
-        
-        UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCText" bundle:nil] instantiateViewControllerWithIdentifier:@"NCText"];
-        
-        NCText *viewController = (NCText *)navigationController.topViewController;
-        
-        viewController.metadata = metadata;
-        viewController.delegate = self;
-        
-        navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
-        navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
-        
-        [self presentViewController:navigationController animated:YES completion:nil];
-    }
-}
-
-- (void)actionButtonPressed:(UIBarButtonItem *)sender
-{
-    if ([self.metadataDetail.fileNameView length] == 0) return;
-    
-    NSString *filePath = [CCUtility getDirectoryProviderStorageOcId:self.metadataDetail.ocId fileNameView:self.metadataDetail.fileNameView];
-
-    docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
-
-    docController.delegate = self;
-    
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
-        [docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
-    else
-        [docController presentOptionsMenuFromBarButtonItem:sender animated:YES];
-}
-
-- (void)shareButtonPressed:(UIBarButtonItem *)sender
-{
-    [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:self.metadataDetail indexPage:2];
-}
-
-- (void)deleteButtonPressed:(UIBarButtonItem *)sender
-{
-    if ([self.metadataDetail.fileNameView length] == 0) return;
-    
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-    
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
-                                                         style:UIAlertActionStyleDestructive
-                                                       handler:^(UIAlertAction *action) {
-                                                           [self deleteFile:self.metadataDetail];
-                                                       }]];
-    
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
-                                                         style:UIAlertActionStyleCancel
-                                                       handler:^(UIAlertAction *action) {
-                                                           [alertController dismissViewControllerAnimated:YES completion:nil];
-                                                       }]];
-    
-    alertController.popoverPresentationController.barButtonItem = buttonDelete;
-    
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-        [alertController.view layoutIfNeeded];
-
-    [self presentViewController:alertController animated:YES completion:NULL];
-}
-
-@end

+ 0 - 2
iOSClient/Main/CCMain.h

@@ -33,7 +33,6 @@
 #import "CCLogin.h"
 #import "CCCellMain.h"
 #import "CCCellMainTransfer.h"
-#import "CCDetail.h"
 #import "CCGraphics.h"
 #import "CCSection.h"
 #import "CCUtility.h"
@@ -57,7 +56,6 @@
 @property (nonatomic, strong) NSString *serverUrl;
 @property (nonatomic, strong) NSString *titleMain;
 @property (nonatomic, strong) NSString *richWorkspaceText;
-@property (nonatomic, weak) CCDetail *detailViewController;
 @property (nonatomic, strong) UISearchController *searchController;
 @property (nonatomic, strong) UITapGestureRecognizer *singleFingerTap;
 @property (nonatomic, strong) NSString *blinkFileNamePath;

+ 9 - 19
iOSClient/Main/CCMain.m

@@ -3329,8 +3329,9 @@
         return;
     
     // Collapsed ma siamo già in detail esci
-    if (self.splitViewController.isCollapsed)
-        if (_detailViewController.isViewLoaded && _detailViewController.view.window) return;
+    if (self.splitViewController.isCollapsed) {
+        if (appDelegate.activeDetail.isViewLoaded && appDelegate.activeDetail.view.window) return;
+    }
     
     // Metadata for push detail
     self.metadataForPushDetail = metadata;
@@ -3341,20 +3342,11 @@
 
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
-    id viewController = segue.destinationViewController;
     tableMetadata *metadata;
-    
-    if ([viewController isKindOfClass:[UINavigationController class]]) {
-        
-        UINavigationController *nav = viewController;
-        _detailViewController = (CCDetail *)nav.topViewController;
-        
-    } else {
-        
-        _detailViewController = segue.destinationViewController;
-    }
-    
     NSMutableArray *photoDataSource = [NSMutableArray new];
+
+    UINavigationController *navigationController = segue.destinationViewController;
+    NCDetailViewController *detailViewController = (NCDetailViewController *)navigationController.topViewController;
     
     if ([sender isKindOfClass:[tableMetadata class]]) {
     
@@ -3372,12 +3364,10 @@
         }
     }
     
-    _detailViewController.metadataDetail = metadata;
-    _detailViewController.selectorDetail = self.selectorForPushDetail;
-    _detailViewController.photoDataSource = photoDataSource;
-    _detailViewController.dateFilterQuery = nil;
+    detailViewController.metadata = metadata;
+    detailViewController.selector = self.selectorForPushDetail;
     
-    [_detailViewController setTitle:metadata.fileNameView];
+    [detailViewController setTitle:metadata.fileNameView];
 }
 
 // can i go to next viewcontroller

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

@@ -293,6 +293,7 @@ class NCCreateFormUploadDocuments: XLFormViewController, NCSelectDelegate, UICol
                         self.dismiss(animated: true, completion: {
                             let metadata = CCUtility.createMetadata(withAccount: self.appDelegate.activeAccount, date: Date(), directory: false, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, fileName: (fileNameForm as! NSString).deletingPathExtension + "." + self.fileNameExtension, etag: "", size: 0, status: Double(k_metadataStatusNormal), url:url, contentType: contentType)
                             
+                            self.appDelegate.activeMain.readFileReloadFolder()
                             self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
                         })
                     }

+ 162 - 0
iOSClient/Main/Create cloud/NCCreateMenuAdd.swift

@@ -0,0 +1,162 @@
+//
+//  NCCreateMenuAdd.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 14/11/2018.
+//  Copyright © 2018 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 Sheeeeeeeeet
+
+class NCCreateMenuAdd: NSObject {
+    
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    var isNextcloudTextAvailable = false
+    
+    @objc init(viewController: UIViewController, view : UIView) {
+        super.init()
+
+        if self.appDelegate.reachability.isReachable() && NCBrandBeta.shared.directEditing && NCManageDatabase.sharedInstance.getDirectEditingCreators(account: self.appDelegate.activeAccount) != nil {
+            isNextcloudTextAvailable = true
+        }
+        
+        var items = [MenuItem]()
+
+        ActionSheetTableView.appearance().backgroundColor = NCBrandColor.sharedInstance.backgroundForm
+        ActionSheetTableView.appearance().separatorColor = NCBrandColor.sharedInstance.separator
+        ActionSheetItemCell.appearance().backgroundColor = NCBrandColor.sharedInstance.backgroundForm
+        ActionSheetItemCell.appearance().titleColor = NCBrandColor.sharedInstance.textView
+        
+        items.append(MenuItem(title: NSLocalizedString("_upload_photos_videos_", comment: ""), value: 10, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_photo"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+        
+        items.append(MenuItem(title: NSLocalizedString("_upload_file_", comment: ""), value: 20, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "file"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+        
+        if NCBrandOptions.sharedInstance.use_imi_viewer {
+            items.append(MenuItem(title: NSLocalizedString("_im_create_new_file", tableName: "IMLocalizable", bundle: Bundle.main, value: "", comment: ""), value: 21, image: CCGraphics.scale(UIImage.init(named: "imagemeter"), to: CGSize(width: 25, height: 25), isAspectRation: true)))
+        }
+        
+        if isNextcloudTextAvailable {
+            items.append(MenuItem(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), value: 31, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+        } else {
+            items.append(MenuItem(title: NSLocalizedString("_upload_file_text_", comment: ""), value: 30, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "file_txt"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+        }
+        
+#if !targetEnvironment(simulator)
+        if #available(iOS 11.0, *) {
+            items.append(MenuItem(title: NSLocalizedString("_scans_document_", comment: ""), value: 40, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "scan"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+        }
+#endif
+        
+        items.append(MenuItem(title: NSLocalizedString("_create_voice_memo_", comment: ""), value: 50, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "microphone"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon)))
+
+        items.append(MenuItem(title: NSLocalizedString("_create_folder_", comment: ""), value: 60, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement)))
+        
+        if let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes(account: appDelegate.activeAccount) {
+            if richdocumentsMimetypes.count > 0 {
+                items.append(MenuItem(title: NSLocalizedString("_create_new_document_", comment: ""), value: 70, image: UIImage.init(named: "create_file_document")))
+                items.append(MenuItem(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), value: 80, image: UIImage(named: "create_file_xls")))
+                items.append(MenuItem(title: NSLocalizedString("_create_new_presentation_", comment: ""), value: 90, image: UIImage(named: "create_file_ppt")))
+            }
+        }
+        
+        items.append(CancelButton(title: NSLocalizedString("_cancel_", comment: "")))
+        
+        let actionSheet = ActionSheet(menu: Menu(items: items), action: { (shhet, item) in
+
+            if item.value as? Int == 10 { self.appDelegate.activeMain.openAssetsPickerController() }
+            if item.value as? Int == 20 { self.appDelegate.activeMain.openImportDocumentPicker() }
+            if item.value as? Int == 21 {
+                _ = IMCreate.init(serverUrl: self.appDelegate.activeMain.serverUrl)
+            }
+            if item.value as? Int == 30 {
+                let storyboard = UIStoryboard(name: "NCText", bundle: nil)
+                let controller = storyboard.instantiateViewController(withIdentifier: "NCText")
+                controller.modalPresentationStyle = UIModalPresentationStyle.pageSheet
+                self.appDelegate.activeMain.present(controller, animated: true, completion: nil)
+            }
+            if item.value as? Int == 31 {
+                guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                    return
+                }
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+                
+                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                viewController.typeTemplate = k_template_document
+                viewController.serverUrl = self.appDelegate.activeMain.serverUrl
+                viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
+                
+                self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+            }
+            if item.value as? Int == 40 {
+                if #available(iOS 11.0, *) {
+                    NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: self.appDelegate.activeMain)
+                }
+            }
+            
+            if item.value as? Int == 50 { NCMainCommon.sharedInstance.startAudioRecorder() }
+            
+            if item.value as? Int == 60 { self.appDelegate.activeMain.createFolder() }
+            
+            if item.value as? Int == 70 {
+                guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                    return
+                }
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+                
+                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                viewController.typeTemplate = k_template_document
+                viewController.serverUrl = self.appDelegate.activeMain.serverUrl
+                viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
+                
+                self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+            }
+            if item.value as? Int == 80 {
+                guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                    return
+                }
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+                
+                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                viewController.typeTemplate = k_template_spreadsheet
+                viewController.serverUrl = self.appDelegate.activeMain.serverUrl
+                viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
+                
+                self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+            }
+            if item.value as? Int == 90 {
+                guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() else {
+                    return
+                }
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
+                
+                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                viewController.typeTemplate = k_template_presentation
+                viewController.serverUrl = self.appDelegate.activeMain.serverUrl
+                viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
+                
+                self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
+            }
+            
+            if item is CancelButton { print("Cancel buttons has the value `true`") }
+        })
+                
+        actionSheet.present(in: viewController, from: view)
+        
+    }
+}

+ 9 - 8
iOSClient/Main/Main.storyboard

@@ -153,16 +153,16 @@
             </objects>
             <point key="canvasLocation" x="7073" y="-709"/>
         </scene>
-        <!--Detail-->
+        <!--Detail View Controller-->
         <scene sceneID="zJM-E9-jgK">
             <objects>
-                <viewController storyboardIdentifier="CCDetailVC" extendedLayoutIncludesOpaqueBars="YES" id="zg6-hy-EbU" customClass="CCDetail" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="CCDetailVC" id="zg6-hy-EbU" customClass="NCDetailViewController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" tag="900" contentMode="scaleToFill" id="cUA-lB-tGG">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="808"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <imageView userInteractionEnabled="NO" tag="999" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
-                                <rect key="frame" x="0.0" y="88" width="414" height="774"/>
+                            <imageView tag="999" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
+                                <rect key="frame" x="0.0" y="0.0" width="414" height="774"/>
                             </imageView>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -174,19 +174,20 @@
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="3ph-Od-2hO"/>
                     </view>
+                    <extendedEdge key="edgesForExtendedLayout"/>
                     <navigationItem key="navigationItem" id="cJm-UN-Dvj" userLabel="Detail"/>
                     <connections>
-                        <outlet property="viewBackground" destination="zlU-MP-ZVs" id="J4v-73-vGf"/>
+                        <outlet property="backgroundView" destination="zlU-MP-ZVs" id="yVd-Vz-gsJ"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="IJ0-oL-QKv" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="5750" y="2407"/>
         </scene>
-        <!--Navigation Controller-->
+        <!--Detail Navigation Controller-->
         <scene sceneID="Xur-XN-mjy">
             <objects>
-                <navigationController storyboardIdentifier="CCDetailNC" extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="mtc-lf-PRo" sceneMemberID="viewController">
+                <navigationController storyboardIdentifier="CCDetailNC" extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="mtc-lf-PRo" customClass="NCDetailNavigationController" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <toolbarItems/>
                     <navigationBar key="navigationBar" contentMode="scaleToFill" id="vxw-dW-rgx">
                         <rect key="frame" x="0.0" y="44" width="414" height="44"/>

+ 118 - 0
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -0,0 +1,118 @@
+//
+//  NCDetailNavigationController+Menu.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 07/02/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 FloatingPanel
+import NCCommunication
+
+extension NCDetailNavigationController {
+
+    private func initMoreMenu(viewController: UIViewController, metadata: tableMetadata) -> [NCMenuAction] {
+        var actions = [NCMenuAction]()
+        let fileNameExtension = (metadata.fileNameView as NSString).pathExtension.uppercased()
+        let directEditingCreators = NCManageDatabase.sharedInstance.getDirectEditingCreators(account: appDelegate.activeAccount)
+
+        actions.append(
+            NCMenuAction(title: NSLocalizedString("_open_in_", comment: ""),
+                icon: CCGraphics.changeThemingColorImage(UIImage(named: "openFile"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                action: { menuAction in
+                    NCMainCommon.sharedInstance.downloadOpen(metadata: metadata, selector: selectorOpenIn)
+                }
+            )
+        )
+
+        actions.append(
+            NCMenuAction(title: NSLocalizedString("_share_", comment: ""),
+                icon: CCGraphics.changeThemingColorImage(UIImage(named: "share"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                action: { menuAction in
+                    NCMainCommon.sharedInstance.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+                }
+            )
+        )
+        
+        actions.append(
+            NCMenuAction(title: NSLocalizedString("_delete_", comment: ""),
+                icon: CCGraphics.changeThemingColorImage(UIImage(named: "trash"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                action: { menuAction in
+                    
+                    let alertController = UIAlertController(title: "", message: NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert)
+                    
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (action:UIAlertAction) in
+                        
+                        if let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
+                            
+                            NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: directory.e2eEncrypted, serverUrl: metadata.serverUrl, folderocId: directory.ocId) { (errorCode, errorMessage) in
+                                
+                                if errorCode == 0 {
+                                    NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: metadata.serverUrl, ocId: metadata.ocId, action: k_action_DEL)
+                                    self.appDelegate.activeDetail.viewUnload()
+                                } else {
+                                    NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                                }
+                            }
+                        }
+                    })
+                    
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in })
+                                        
+                    self.present(alertController, animated: true, completion:nil)
+                }
+            )
+        )
+        
+        if CCUtility.isDocumentModifiableExtension(fileNameExtension) && (directEditingCreators == nil || !appDelegate.reachability.isReachable()) {
+            actions.append(
+                NCMenuAction(title: NSLocalizedString("_internal_modify_", comment: ""),
+                    icon: CCGraphics.changeThemingColorImage(UIImage(named: "pencil"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                    action: { menuAction in
+                        if let navigationController = UIStoryboard(name: "NCText", bundle: nil).instantiateViewController(withIdentifier: "NCText") as? UINavigationController {
+                            navigationController.modalPresentationStyle = .pageSheet
+                            navigationController.modalTransitionStyle = .crossDissolve
+                            if let textViewController = navigationController.topViewController as? NCText {
+                                textViewController.metadata = metadata;
+                                viewController.present(navigationController, animated: true, completion: nil)
+                            }
+                        }
+                    }
+                )
+            )
+        }
+        
+        return actions
+    }
+
+    @objc func toggleMoreMenu(viewController: UIViewController, metadata: tableMetadata) {
+        if appDelegate.activeDetail.subViewActive() != nil {
+            let mainMenuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateViewController(withIdentifier: "NCMainMenuTableViewController") as! NCMainMenuTableViewController
+            mainMenuViewController.actions = self.initMoreMenu(viewController: viewController, metadata: metadata)
+
+            let menuPanelController = NCMenuPanelController()
+            menuPanelController.parentPresenter = viewController
+            menuPanelController.delegate = mainMenuViewController
+            menuPanelController.set(contentViewController: mainMenuViewController)
+            menuPanelController.track(scrollView: mainMenuViewController.tableView)
+
+            viewController.present(menuPanelController, animated: true, completion: nil)
+        }
+    }
+}
+

+ 62 - 0
iOSClient/Main/NCDetailNavigationController.swift

@@ -0,0 +1,62 @@
+//
+//  NCDetailNavigationController.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 07/02/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
+
+class NCDetailNavigationController: UINavigationController {
+    
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
+        changeTheming()
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        let buttonMore = UIBarButtonItem.init(image: UIImage(named: "more"), style: .plain, target: self, action: #selector(self.openMenuMore))
+        topViewController?.navigationItem.rightBarButtonItem = buttonMore
+               
+        topViewController?.navigationItem.leftBarButtonItem = nil
+        if let splitViewController = self.splitViewController {
+            if !splitViewController.isCollapsed {
+                topViewController?.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
+            }
+        }
+    }
+    
+    @objc func changeTheming() {
+        navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
+        navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
+        navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.sharedInstance.brandText]
+    }
+    
+    @objc func openMenuMore() {
+        if let metadata = appDelegate.activeDetail?.metadata {
+            self.toggleMoreMenu(viewController: self, metadata: metadata)
+        }
+    }
+}

+ 238 - 0
iOSClient/Main/NCDetailViewController.swift

@@ -0,0 +1,238 @@
+//
+//  NCDetailViewController.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 07/02/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 WebKit
+import NCCommunication
+
+class NCDetailViewController: UIViewController {
+    
+    @IBOutlet weak var backgroundView: UIImageView!
+    
+    @objc var metadata: tableMetadata?
+    @objc var selector: String?
+
+    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+        
+        appDelegate.activeDetail = self
+    }
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
+        changeTheming()
+        
+        if metadata != nil  {
+            viewFile(metadata: metadata!, selector: selector)
+        }
+    }
+    
+    override func viewDidDisappear(_ animated: Bool) {
+        super.viewDidDisappear(animated)
+        
+        if appDelegate.player != nil && appDelegate.player.rate != 0 {
+            appDelegate.player.pause()
+        }
+        
+        if appDelegate.isMediaObserver {
+            appDelegate.isMediaObserver = false
+            NCViewerMedia.sharedInstance.removeObserver()
+        }
+    }
+    
+    func viewUnload() {
+        if let splitViewController = self.splitViewController as? NCSplitViewController {
+            if splitViewController.isCollapsed {
+                if let navigationController = splitViewController.viewControllers.last as? UINavigationController {
+                    navigationController.popToRootViewController(animated: true)
+                }
+            } else {
+                for view in backgroundView.subviews {
+                    view.removeFromSuperview()
+                }
+                self.navigationController?.navigationBar.topItem?.title = ""
+            }
+        }
+    }
+    
+    @objc func changeTheming() {
+        backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
+        view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
+    }
+    
+    func subViewActive() -> UIView? {
+        return backgroundView.subviews.first
+    }
+    
+    @objc func viewFile(metadata: tableMetadata, selector: String?) {
+                
+        self.metadata = metadata
+        self.selector = selector
+        
+        self.navigationController?.navigationBar.topItem?.title = metadata.fileNameView
+        
+        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)) == false {
+            CCGraphics.createNewImage(from: metadata.fileNameView, ocId: metadata.ocId, extension: (metadata.fileNameView as NSString).pathExtension, filterGrayScale: false, typeFile: metadata.typeFile, writeImage: true)
+        }
+        
+        if appDelegate.isMediaObserver {
+            appDelegate.isMediaObserver = false
+            NCViewerMedia.sharedInstance.removeObserver()
+        }
+        
+        // IMAGE
+        if metadata.typeFile == k_metadataTypeFile_image {
+            return
+        }
+        
+        // AUDIO VIDEO
+        if metadata.typeFile == k_metadataTypeFile_audio || metadata.typeFile == k_metadataTypeFile_video {
+            NCViewerMedia.sharedInstance.viewMedia(metadata, view: backgroundView)
+            return
+        }
+        
+        // DOCUMENT - INTERNAL VIEWER
+        if metadata.typeFile == k_metadataTypeFile_document && selector != nil && selector == selectorLoadFileInternalView {
+            NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: backgroundView)
+            return
+        }
+        
+        // DOCUMENT
+        if metadata.typeFile == k_metadataTypeFile_document {
+            
+            // PDF
+            if metadata.contentType == "application/pdf" {
+                if #available(iOS 11.0, *) {
+                    let viewerPDF = NCViewerPDF.init(frame: backgroundView.frame)
+                    
+                    let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+                    if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) == false {
+                        return
+                    }
+                    
+                    viewerPDF.setupPdfView(filePath: URL(fileURLWithPath: filePath), view: backgroundView)
+                }
+                
+                return
+            }
+            
+            // DirectEditinf: Nextcloud Text - OnlyOffice
+            if NCUtility.sharedInstance.isDirectEditing(metadata) != nil && appDelegate.reachability.isReachable() {
+                
+                let editor = NCUtility.sharedInstance.isDirectEditing(metadata)!
+                if editor == k_editor_text || editor == k_editor_onlyoffice {
+                    
+                    NCUtility.sharedInstance.startActivityIndicator(view: backgroundView, bottom: 0)
+
+                    if metadata.url == "" {
+                        
+                        var customUserAgent: String?
+                        let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: appDelegate.activeUrl)!
+                        
+                        if editor == k_editor_onlyoffice {
+                            customUserAgent = NCUtility.sharedInstance.getCustomUserAgentOnlyOffice()
+                        }
+                        
+                        NCCommunication.sharedInstance.NCTextOpenFile(urlString: appDelegate.activeUrl, fileNamePath: fileNamePath, editor: editor, customUserAgent: customUserAgent, account: appDelegate.activeAccount) { (account, url, errorCode, errorMessage) in
+                            
+                            if errorCode == 0 && account == self.appDelegate.activeAccount && url != nil {
+                                
+                                let nextcloudText = NCViewerNextcloudText.init(frame: self.backgroundView.frame, configuration: WKWebViewConfiguration())
+                                nextcloudText.viewerAt(url!, metadata: metadata, editor: editor, view: self.backgroundView, viewController: self)
+                                if editor == k_editor_text && self.splitViewController!.isCollapsed {
+                                    self.navigationController?.navigationItem.hidesBackButton = true
+                                }
+                                
+                            } else if errorCode != 0 {
+                                
+                                NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                                self.navigationController?.popViewController(animated: true)
+                                
+                            } else {
+                                
+                                self.navigationController?.popViewController(animated: true)
+                            }
+                        }
+                        
+                    } else {
+                        
+                        let nextcloudText = NCViewerNextcloudText.init(frame: backgroundView.frame, configuration: WKWebViewConfiguration())
+                        nextcloudText.viewerAt(metadata.url, metadata: metadata, editor: editor, view: backgroundView, viewController: self)
+                        if editor == k_editor_text && self.splitViewController!.isCollapsed {
+                            self.navigationController?.navigationItem.hidesBackButton = true
+                        }
+                    }
+                }
+                
+                return
+            }
+            
+            // RichDocument: Collabora
+            if NCUtility.sharedInstance.isRichDocument(metadata) && appDelegate.reachability.isReachable() {
+                
+                NCUtility.sharedInstance.startActivityIndicator(view: backgroundView, bottom: 0)
+                
+                if metadata.url == "" {
+                    
+                    OCNetworking.sharedManager()?.createLinkRichdocuments(withAccount: appDelegate.activeAccount, fileId: metadata.fileId, completion: { (account, url, errorMessage, errorCode) in
+                        
+                        if errorCode == 0 && account == self.appDelegate.activeAccount && url != nil {
+                            
+                            let richDocument = NCViewerRichdocument.init(frame: self.backgroundView.frame, configuration: WKWebViewConfiguration())
+                            richDocument.viewRichDocumentAt(url!, metadata: metadata, view: self.backgroundView, viewController: self)
+                            if self.splitViewController != nil && self.splitViewController!.isCollapsed {
+                                self.navigationController?.navigationItem.hidesBackButton = true
+                            }
+                            
+                        } else if errorCode != 0 {
+                            
+                            NCContentPresenter.shared.messageNotification("_error_", description: errorMessage, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                            self.navigationController?.popViewController(animated: true)
+                            
+                        } else {
+                            
+                            self.navigationController?.popViewController(animated: true)
+                        }
+                        
+                    })
+                    
+                } else {
+                    
+                    let richDocument = NCViewerRichdocument.init(frame: backgroundView.frame, configuration: WKWebViewConfiguration())
+                    richDocument.viewRichDocumentAt(metadata.url, metadata: metadata, view: backgroundView, viewController: self)
+                    if self.splitViewController != nil && self.splitViewController!.isCollapsed {
+                        self.navigationController?.navigationItem.hidesBackButton = true
+                    }
+                }
+            }
+        }
+        
+        // OTHER
+        NCViewerDocumentWeb.sharedInstance.viewDocumentWebAt(metadata, view: backgroundView)
+    }
+
+}

+ 6 - 6
iOSClient/Main/NCMainCommon.swift

@@ -1387,9 +1387,9 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate, IMImagemeterViewerDelega
             //selectorLoadViewImage
             if selector == selectorLoadViewImage {
                 
-                if appDelegate.activeDetail != nil {
-                    appDelegate.activeDetail.downloadPhotoBrowserSuccessFailure(metadata, selector: selector, errorCode: errorCode)
-                }
+//                if appDelegate.activeDetail != nil {
+//                    appDelegate.activeDetail.downloadPhotoBrowserSuccessFailure(metadata, selector: selector, errorCode: errorCode)
+//                }
             }
             
             appDelegate.startLoadAutoDownloadUpload()
@@ -1411,9 +1411,9 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate, IMImagemeterViewerDelega
             
             if selector == selectorLoadViewImage {
                 
-                if appDelegate.activeDetail.view.window != nil {
-                    appDelegate.activeDetail.downloadPhotoBrowserSuccessFailure(metadata, selector: selector, errorCode: errorCode)
-                }
+//                if appDelegate.activeDetail.view.window != nil {
+//                    appDelegate.activeDetail.downloadPhotoBrowserSuccessFailure(metadata, selector: selector, errorCode: errorCode)
+//                }
                 
                 NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: serverUrl, ocId: ocId, action: Int32(k_action_MOD))
             }

+ 2 - 7
iOSClient/Media/NCMedia.swift

@@ -334,12 +334,9 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         }
         
         if let segueNavigationController = segue.destination as? UINavigationController {
-            if let segueViewController = segueNavigationController.topViewController as? CCDetail {
+            if let segueViewController = segueNavigationController.topViewController as? NCDetailViewController {
             
-                segueViewController.metadataDetail = metadataPush
-                segueViewController.dateFilterQuery = nil
-                segueViewController.photoDataSource = photoDataSource
-                segueViewController.title = metadataPush!.fileNameView
+                segueViewController.metadata = metadataPush
             }
         }
     }
@@ -621,8 +618,6 @@ extension NCMedia {
                 
             }  else {
                 
-                NCContentPresenter.shared.messageNotification("_error_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                
                 self.loadingSearch = false
                 
                 self.reloadDataSource(loadNetworkDatasource: false)

+ 2 - 5
iOSClient/Offline/NCOffline.swift

@@ -460,12 +460,9 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
         }
         
         if let segueNavigationController = segue.destination as? UINavigationController {
-            if let segueViewController = segueNavigationController.topViewController as? CCDetail {
+            if let segueViewController = segueNavigationController.topViewController as? NCDetailViewController {
             
-                segueViewController.metadataDetail = metadataPush
-                segueViewController.dateFilterQuery = nil
-                segueViewController.photoDataSource = photoDataSource
-                segueViewController.title = metadataPush!.fileNameView
+                segueViewController.metadata = metadataPush
             }
         }
     }

+ 1 - 0
iOSClient/RichWorkspace/NCViewerRichWorkspaceWebView.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import WebKit
 
 class NCViewerRichWorkspaceWebView: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
     

+ 10 - 1
iOSClient/Text/NCText.swift

@@ -23,6 +23,7 @@
 
 
 import Foundation
+import WebKit
 
 @objc protocol NCTextDelegate {
     func dismissTextView()
@@ -107,7 +108,15 @@ class NCText: UIViewController, UITextViewDelegate {
     }
     
     override func viewDidDisappear(_ animated: Bool) {
-        appDelegate.activeDetail?.viewFile()
+        super.viewDidDisappear(animated)
+        
+        if appDelegate.activeDetail != nil {
+            if let view = appDelegate.activeDetail.subViewActive() {
+                if view is WKWebView {
+                    appDelegate.activeDetail.viewFile(metadata: metadata!, selector: nil)
+                }
+            }
+        }
     }
     
     @objc func keyboardWillHideHandle() {

+ 0 - 1
iOSClient/Transfers/CCTransfers.m

@@ -24,7 +24,6 @@
 #import "CCTransfers.h"
 #import "AppDelegate.h"
 #import "CCMain.h"
-#import "CCDetail.h"
 #import "CCSection.h"
 #import "CCCellMainTransfer.h"
 #import "NCBridgeSwift.h"

+ 4 - 3
iOSClient/Viewer/NCViewerDocumentWeb.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import WebKit
 
 class NCViewerDocumentWeb: NSObject {
     
@@ -34,7 +35,7 @@ class NCViewerDocumentWeb: NSObject {
         return instance
     }()
     
-    @objc func viewDocumentWebAt(_ metadata: tableMetadata, detail: CCDetail) {
+    @objc func viewDocumentWebAt(_ metadata: tableMetadata, view: UIView) {
         
         if !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) { return }
         
@@ -67,7 +68,7 @@ class NCViewerDocumentWeb: NSObject {
         
         configuration.preferences = preferences
         
-        let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: Int(detail.view.bounds.size.width), height: Int(detail.view.bounds.size.height) - Int(k_detail_Toolbar_Height) - safeAreaBottom - 1), configuration: configuration)
+        let webView = WKWebView(frame: view.frame)
         webView.navigationDelegate = self
         webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
         webView.backgroundColor = .white
@@ -121,7 +122,7 @@ class NCViewerDocumentWeb: NSObject {
             webView.load(URLRequest(url: url))
         }
         
-        detail.view.addSubview(webView)
+        view.addSubview(webView)
     }
 }
 

+ 6 - 17
iOSClient/Viewer/NCViewerMedia.swift

@@ -26,7 +26,6 @@ import KTVHTTPCache
 
 class NCViewerMedia: NSObject {
 
-    var detail: CCDetail!
     var metadata: tableMetadata!
     var videoURL: URL!
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -38,11 +37,10 @@ class NCViewerMedia: NSObject {
         return viewMedia
     }()
 
-    @objc func viewMedia(_ metadata: tableMetadata, detail: CCDetail) {
+    @objc func viewMedia(_ metadata: tableMetadata, view: UIView) {
         
         var videoURLProxy: URL!
 
-        self.detail = detail
         self.metadata = metadata
         
         guard let rootView = UIApplication.shared.keyWindow else {
@@ -73,20 +71,16 @@ class NCViewerMedia: NSObject {
             
             let authValue = "Basic " + authData.base64EncodedString(options: [])
             KTVHTTPCache.downloadSetAdditionalHeaders(["Authorization":authValue, "User-Agent":CCUtility.getUserAgent()])
-            
-            // Disable Button Action (the file is in download via Proxy Server)
-            detail.buttonAction.isEnabled = false
         }
         
         appDelegate.player = AVPlayer(url: videoURLProxy)
         appDelegate.playerController = AVPlayerViewController()
         
         appDelegate.playerController.player = appDelegate.player
-        appDelegate.playerController.view.frame = CGRect(x: 0, y: 0, width: Int(rootView.bounds.size.width), height: Int(rootView.bounds.size.height) - Int(k_detail_Toolbar_Height) - safeAreaBottom - 1)
+        appDelegate.playerController.view.frame = view.frame
         appDelegate.playerController.allowsPictureInPicturePlayback = false
-        detail.addChild(appDelegate.playerController)
-        detail.view.addSubview(appDelegate.playerController.view)
-        appDelegate.playerController.didMove(toParent: detail)
+        
+        view.addSubview(appDelegate.playerController.view)
         
         NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: nil, queue: nil) { (notification) in
             let player = notification.object as! AVPlayerItem
@@ -94,9 +88,7 @@ class NCViewerMedia: NSObject {
         }
         
         appDelegate.player.addObserver(self, forKeyPath: "rate", options: [], context: nil)
-        
-        detail.isMediaObserver = true
-        
+        appDelegate.isMediaObserver = true
         appDelegate.player.play()
     }
     
@@ -118,14 +110,11 @@ class NCViewerMedia: NSObject {
                 }
                 
                 CCUtility.copyFile(atPath: url.path, toPath: CCUtility.getDirectoryProviderStorageOcId(self.metadata.ocId, fileNameView: self.metadata.fileNameView))
-                _ = NCManageDatabase.sharedInstance.addLocalFile(metadata: self.metadata)
+                NCManageDatabase.sharedInstance.addLocalFile(metadata: self.metadata)
                 KTVHTTPCache.cacheDelete(with: self.videoURL)
                 
                 // reload Data Source
                 NCMainCommon.sharedInstance.reloadDatasource(ServerUrl:self.metadata.serverUrl, ocId: self.metadata.ocId, action: k_action_MOD)
-                
-                // Enabled Button Action (the file is in local)
-                self.detail.buttonAction.isEnabled = true
             }
         }
     }

+ 14 - 20
iOSClient/Viewer/NCViewerNextcloudText.swift

@@ -22,13 +22,15 @@
 //
 
 import Foundation
+import WebKit
 
 class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHandler {
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var detail: CCDetail!
     var editor: String!
     var metadata: tableMetadata!
+    var view: UIView!
+    var viewController: UIViewController!
     var documentInteractionController: UIDocumentInteractionController!
    
     override init(frame: CGRect, configuration: WKWebViewConfiguration) {
@@ -45,12 +47,13 @@ class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHan
         super.init(coder: coder)
     }
     
-    @objc func viewerAt(_ link: String, detail: CCDetail, metadata: tableMetadata, editor: String) {
-        
-        self.detail = detail
+    @objc func viewerAt(_ link: String, metadata: tableMetadata, editor: String, view: UIView, viewController: UIViewController) {
+                
         self.metadata = metadata
         self.editor = editor
-        
+        self.view = view
+        self.viewController = viewController
+
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
         
@@ -66,18 +69,19 @@ class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHan
         }
         
         load(request)
+        
+        self.view.addSubview(self)
     }
     
     @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
+        frame.size.height = view.frame.height - keyboardFrame.size.height
     }
     
     @objc func keyboardWillHide(notification: Notification) {
-        frame = detail.view.bounds
+        frame = view.frame
     }
     
     //MARK: -
@@ -87,23 +91,13 @@ class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHan
         if (message.name == "DirectEditingMobileInterface") {
             
             if message.body as? String == "close" {
-                
-                removeFromSuperview()
-                
-                detail.navigationController?.popViewController(animated: true)
-                detail.navigationController?.navigationBar.topItem?.title = ""
-                
-                let splitViewController = appDelegate.window.rootViewController as! UISplitViewController
-                if splitViewController.isCollapsed {
-                    let masterNavigationController = splitViewController.viewControllers.first as! UINavigationController
-                    masterNavigationController.popViewController(animated: true)
-                }
                                 
+                appDelegate.activeDetail.viewUnload()
                 appDelegate.activeMain.readFileReloadFolder()
             }
             
             if message.body as? String == "share" {
-                NCMainCommon.sharedInstance.openShare(ViewController: detail, metadata: metadata, indexPage: 2)
+                NCMainCommon.sharedInstance.openShare(ViewController: viewController, metadata: metadata, indexPage: 2)
             }
             
             if message.body as? String == "loading" {

+ 75 - 0
iOSClient/Viewer/NCViewerPDF.swift

@@ -0,0 +1,75 @@
+//
+//  NCViewerPDF.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 06/02/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 PDFKit
+
+@available(iOS 11, *)
+
+@objc class NCViewerPDF: PDFView {
+    
+    private var thumbnailViewHeight: CGFloat = 48
+
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+    }
+    
+    override init(frame: CGRect) {
+        super.init(frame: CGRect(x: 0, y: 0, width: frame.width, height: frame.height - thumbnailViewHeight))
+        NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
+    }
+    
+    @objc func changeTheming() {
+        backgroundColor = NCBrandColor.sharedInstance.backgroundView
+    }
+    
+    @objc func setupPdfView(filePath: URL, view: UIView) {
+        
+        guard let pdfDocument = PDFDocument(url: filePath) else {return}
+        
+        document = pdfDocument
+        backgroundColor = NCBrandColor.sharedInstance.backgroundView
+        displayMode = .singlePageContinuous
+        autoScales = true
+        displayDirection = .horizontal
+        autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleBottomMargin]
+        usePageViewController(true, withViewOptions: nil)
+        
+        view.addSubview(self)
+        
+        let pdfThumbnailView = PDFThumbnailView()
+        pdfThumbnailView.translatesAutoresizingMaskIntoConstraints = false
+        pdfThumbnailView.pdfView = self
+        pdfThumbnailView.layoutMode = .horizontal
+        pdfThumbnailView.thumbnailSize = CGSize(width: 40, height: thumbnailViewHeight - 2)
+        //pdfThumbnailView.layer.shadowOffset.height = -5
+        //pdfThumbnailView.layer.shadowOpacity = 0.25
+        
+        view.addSubview(pdfThumbnailView)
+        
+        pdfThumbnailView.heightAnchor.constraint(equalToConstant: thumbnailViewHeight).isActive = true
+        pdfThumbnailView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
+        pdfThumbnailView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
+        pdfThumbnailView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
+    }
+}

+ 17 - 20
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -22,13 +22,15 @@
 //
 
 import Foundation
+import WebKit
 
 class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHandler, NCSelectDelegate {
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var detail: CCDetail!
     @objc var metadata: tableMetadata!
     var documentInteractionController: UIDocumentInteractionController!
+    var view: UIView!
+    var viewController: UIViewController!
    
     override init(frame: CGRect, configuration: WKWebViewConfiguration) {
         super.init(frame: frame, configuration: configuration)
@@ -38,16 +40,19 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
         
         autoresizingMask = [.flexibleWidth, .flexibleHeight]
         navigationDelegate = self
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(self.grabFocus), name: NSNotification.Name(rawValue: "ViewerRichdocumentGrabFocus"), object: nil)
     }
     
     required init?(coder: NSCoder) {
         super.init(coder: coder)
     }
     
-    @objc func viewRichDocumentAt(_ link: String, detail: CCDetail, metadata: tableMetadata) {
+    @objc func viewRichDocumentAt(_ link: String, metadata: tableMetadata, view: UIView, viewController: UIViewController) {
         
-        self.detail = detail
         self.metadata = metadata
+        self.view = view
+        self.viewController = viewController
         
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
@@ -59,7 +64,10 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
         
         let userAgent : String = CCUtility.getUserAgent()
         customUserAgent = userAgent
-        load(request)        
+        
+        load(request)
+        
+        self.view.addSubview(self)
     }
     
     @objc func keyboardDidShow(notification: Notification) {
@@ -67,11 +75,11 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
         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
+        frame.size.height = view.frame.height - keyboardFrame.size.height
     }
     
     @objc func keyboardWillHide(notification: Notification) {
-        frame = detail.view.bounds
+        frame = view.frame
     }
     
     //MARK: -
@@ -82,17 +90,7 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
             
             if message.body as? String == "close" {
                 
-                removeFromSuperview()
-                
-                detail.navigationController?.popViewController(animated: true)
-                detail.navigationController?.navigationBar.topItem?.title = ""
-                
-                let splitViewController = appDelegate.window.rootViewController as! UISplitViewController
-                if splitViewController.isCollapsed {
-                    let masterNavigationController = splitViewController.viewControllers.first as! UINavigationController
-                    masterNavigationController.popViewController(animated: true)
-                }
-                                
+                appDelegate.activeDetail.viewUnload()                                
                 appDelegate.activeMain.readFileReloadFolder()
             }
             
@@ -111,11 +109,11 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
                 viewController.layoutViewSelect = k_layout_view_richdocument
                 
                 navigationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
-                self.detail.present(navigationController, animated: true, completion: nil)
+                viewController.present(navigationController, animated: true, completion: nil)
             }
             
             if message.body as? String == "share" {
-                NCMainCommon.sharedInstance.openShare(ViewController: detail, metadata: metadata, indexPage: 2)
+                NCMainCommon.sharedInstance.openShare(ViewController: viewController, metadata: metadata, indexPage: 2)
             }
             
             if let param = message.body as? Dictionary<AnyHashable,Any> {
@@ -228,7 +226,6 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
         })
     }
     
-    
     //MARK: -
 
     public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {