Browse Source

align 4.0.5

marinofaggiana 3 years ago
parent
commit
7672607589

+ 5 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -259,6 +259,7 @@
 		F78F74342163757000C2ADAD /* NCTrash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F78F74332163757000C2ADAD /* NCTrash.storyboard */; };
 		F78F74362163781100C2ADAD /* NCTrash.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78F74352163781100C2ADAD /* NCTrash.swift */; };
 		F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */; };
+		F792FD672693A27200DD3A4E /* NCBrowserWeb+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F792FD662693A27200DD3A4E /* NCBrowserWeb+Menu.swift */; };
 		F79728D422F96F2E003CACA7 /* NCShareLinkFolderMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F79728D322F96F2D003CACA7 /* NCShareLinkFolderMenuView.xib */; };
 		F79728D622F9A0B1003CACA7 /* NCShareUserFolderMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F79728D522F9A0B0003CACA7 /* NCShareUserFolderMenuView.xib */; };
 		F798F0E225880608000DAFFD /* UIColor+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70CEF5523E9C7E50007035B /* UIColor+Extensions.swift */; };
@@ -663,6 +664,7 @@
 		F78F74352163781100C2ADAD /* NCTrash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTrash.swift; sourceTree = "<group>"; };
 		F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerRichdocument.swift; sourceTree = "<group>"; };
 		F79018A424092EF4007C9B6D /* ATGMediaBrowser.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ATGMediaBrowser.framework; path = Carthage/Build/iOS/ATGMediaBrowser.framework; sourceTree = "<group>"; };
+		F792FD662693A27200DD3A4E /* NCBrowserWeb+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCBrowserWeb+Menu.swift"; sourceTree = "<group>"; };
 		F79728D322F96F2D003CACA7 /* NCShareLinkFolderMenuView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareLinkFolderMenuView.xib; sourceTree = "<group>"; };
 		F79728D522F9A0B0003CACA7 /* NCShareUserFolderMenuView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareUserFolderMenuView.xib; sourceTree = "<group>"; };
 		F79918A021997F9000C2E308 /* UICKeyChainStore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UICKeyChainStore.framework; path = Carthage/Build/iOS/UICKeyChainStore.framework; sourceTree = "<group>"; };
@@ -846,6 +848,7 @@
 				3781B9AF23DB2B7E006B4B1D /* AppDelegate+Menu.swift */,
 				F77A697C250A0FBC00FF1708 /* NCCollectionViewCommon+Menu.swift */,
 				F7581D1925EFDA60004DC699 /* NCLoginWeb+Menu.swift */,
+				F792FD662693A27200DD3A4E /* NCBrowserWeb+Menu.swift */,
 				F7581D2325EFDDDF004DC699 /* NCMedia+Menu.swift */,
 				F7581D2925EFDF43004DC699 /* NCShareComments+Menu.swift */,
 				F7CBC31B24F78E79004D3812 /* NCSortMenu.swift */,
@@ -2161,6 +2164,7 @@
 				F7F878AE1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */,
 				F7DBC37C23325E02001A85BA /* NCAppConfigView.swift in Sources */,
 				3781B9B023DB2B7E006B4B1D /* AppDelegate+Menu.swift in Sources */,
+				F792FD672693A27200DD3A4E /* NCBrowserWeb+Menu.swift in Sources */,
 				F73D5E47246DE09200DF6467 /* NCElementsJSON.swift in Sources */,
 				F710D1F52405770F00A6033D /* NCViewerPDF.swift in Sources */,
 				F7501C332212E57500FB1415 /* NCMedia.swift in Sources */,
@@ -2913,7 +2917,7 @@
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
 				kind = revision;
-				revision = 59409a7218007ce092aa7f3d1170ffaddad7041a;
+				revision = 41334d111bd052e926514868e31c75768d7886cc;
 			};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

+ 1 - 1
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -105,7 +105,7 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "59409a7218007ce092aa7f3d1170ffaddad7041a",
+          "revision": "41334d111bd052e926514868e31c75768d7886cc",
           "version": null
         }
       },

+ 12 - 0
iOSClient/BrowserWeb/NCBrowserWeb.swift

@@ -33,6 +33,7 @@ class NCBrowserWeb: UIViewController {
     var webView: WKWebView?
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
+    @objc var metadata: tableMetadata?
     @objc var urlBase = ""
     @objc var isHiddenButtonExit = false
     @objc var titleBrowser: String? = nil
@@ -69,6 +70,9 @@ class NCBrowserWeb: UIViewController {
             let url = URL(fileURLWithPath: urlBase)
             loadWebPage(webView: webView!, url: url)
         }
+        
+        //
+        navigationItem.rightBarButtonItem = UIBarButtonItem.init(image: UIImage(named: "more")!.image(color: NCBrandColor.shared.label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore))
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -96,6 +100,14 @@ class NCBrowserWeb: UIViewController {
             self.delegate?.browserWebDismiss?()
         }
     }
+    
+    @objc func openMenuMore() {
+        
+        if let metadata = metadata {
+            let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+            NCViewer.shared.toggleMenu(viewController: self, metadata: metadata, webView: false, imageIcon: imageIcon)
+        }
+    }
 }
 
 extension NCBrowserWeb: WKNavigationDelegate {

+ 1 - 0
iOSClient/Data/NCDatabase.swift

@@ -326,6 +326,7 @@ class tableMetadata: Object {
     
     @objc dynamic var account = ""
     @objc dynamic var assetLocalIdentifier = ""
+    @objc dynamic var checksums = ""
     @objc dynamic var chunk: Bool = false
     @objc dynamic var commentsUnread: Bool = false
     @objc dynamic var contentType = ""

+ 1 - 0
iOSClient/Data/NCManageDatabase.swift

@@ -1808,6 +1808,7 @@ class NCManageDatabase: NSObject {
         let metadata = tableMetadata()
         
         metadata.account = account
+        metadata.checksums = file.checksums
         metadata.commentsUnread = file.commentsUnread
         metadata.contentType = file.contentType
         if let date = file.creationDate {

+ 292 - 0
iOSClient/Menu/NCBrowserWeb+Menu.swift

@@ -0,0 +1,292 @@
+//
+//  NCViewer.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 UIKit
+import FloatingPanel
+import NCCommunication
+
+extension NCBrowserWeb {
+
+    func toggleMenu(viewController: UIViewController, metadata: tableMetadata, webView: Bool, imageIcon: UIImage?) {
+        
+        let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
+        var actions = [NCMenuAction]()
+        
+        var titleFavorite = NSLocalizedString("_add_favorites_", comment: "")
+        if metadata.favorite { titleFavorite = NSLocalizedString("_remove_favorites_", comment: "") }
+        let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
+        
+        var titleOffline = ""
+        if (localFile == nil || localFile!.offline == false) {
+            titleOffline = NSLocalizedString("_set_available_offline_", comment: "")
+        } else {
+            titleOffline = NSLocalizedString("_remove_available_offline_", comment: "")
+        }
+        
+        var titleDelete = NSLocalizedString("_delete_", comment: "")
+        if NCManageDatabase.shared.isMetadataShareOrMounted(metadata: metadata, metadataFolder: nil) {
+            titleDelete = NSLocalizedString("_leave_share_", comment: "")
+        } else if metadata.directory {
+            titleDelete = NSLocalizedString("_delete_folder_", comment: "")
+        } else {
+            titleDelete = NSLocalizedString("_delete_file_", comment: "")
+        }
+        
+        let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase)
+        
+        //
+        // FAVORITE
+        //
+        actions.append(
+            NCMenuAction(
+                title: titleFavorite,
+                icon: NCUtility.shared.loadImage(named: "star.fill", color: NCBrandColor.shared.yellowFavorite),
+                action: { menuAction in
+                    NCNetworking.shared.favoriteMetadata(metadata, urlBase: self.appDelegate.urlBase) { (errorCode, errorDescription) in
+                        if errorCode != 0 {
+                            NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                        }
+                    }
+                }
+            )
+        )
+        
+        //
+        // DETAIL
+        //
+        if !appDelegate.disableSharesView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_details_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "info"),
+                    action: { menuAction in
+                        NCFunctionCenter.shared.openShare(ViewController: viewController, metadata: metadata, indexPage: 0)
+                    }
+                )
+            )
+        }
+        
+        //
+        // OFFLINE
+        //
+        if metadata.session == "" && !webView {
+            actions.append(
+                NCMenuAction(
+                    title: titleOffline,
+                    icon: NCUtility.shared.loadImage(named: "tray.and.arrow.down"),
+                    action: { menuAction in
+                        if ((localFile == nil || !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView)) && metadata.session == "") {
+                            
+                            NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadOffline) { (_) in }
+                        } else {
+                            NCManageDatabase.shared.setLocalFile(ocId: metadata.ocId, offline: !localFile!.offline)
+                        }
+                    }
+                )
+            )
+        }
+        
+        //
+        // OPEN IN
+        //
+        if metadata.session == "" && !webView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_open_in_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "square.and.arrow.up"),
+                    action: { menuAction in
+                        NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorOpenIn)
+                    }
+                )
+            )
+        }
+        
+        //
+        // RENAME
+        //
+        if !webView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_rename_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "pencil"),
+                    action: { menuAction in
+                        
+                        if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+                            
+                            vcRename.metadata = metadata
+                            vcRename.disableChangeExt = true
+                            vcRename.imagePreview = imageIcon
+                            
+                            let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
+                            
+                            viewController.present(popup, animated: true)
+                        }
+                    }
+                )
+            )
+        }
+        
+        //
+        // COPY - MOVE
+        //
+        if !webView {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_move_or_copy_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "arrow.up.right.square"),
+                    action: { menuAction in
+                        
+                        let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
+                        let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
+                        let viewController = navigationController.topViewController as! NCSelect
+                        
+                        viewController.delegate = NCViewer.shared
+                        viewController.typeOfCommandView = .copyMove
+                        viewController.items = [metadata]
+                        
+                        self.appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                    }
+                )
+            )
+        }
+        
+        //
+        // COPY
+        //
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_copy_file_", comment: ""),
+                icon: NCUtility.shared.loadImage(named: "doc.on.doc"),
+                action: { menuAction in
+                    self.appDelegate.pasteboardOcIds = [metadata.ocId];
+                    NCFunctionCenter.shared.copyPasteboard()
+                }
+            )
+        )
+        
+        //
+        // VIEW IN FOLDER
+        //
+        if !webView {
+            if appDelegate.activeFileViewInFolder == nil {
+                actions.append(
+                    NCMenuAction(
+                        title: NSLocalizedString("_view_in_folder_", comment: ""),
+                        icon: NCUtility.shared.loadImage(named: "arrow.forward.square"),
+                        action: { menuAction in
+                            NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName)
+                        }
+                    )
+                )
+            }
+        }
+        
+        //
+        // DOWNLOAD IMAGE MAX RESOLUTION
+        //
+        if metadata.session == "" {
+            if metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) && metadata.session == "" {
+                actions.append(
+                    NCMenuAction(
+                        title: NSLocalizedString("_download_image_max_", comment: ""),
+                        icon: NCUtility.shared.loadImage(named: "square.and.arrow.down"),
+                        action: { menuAction in
+                            NCNetworking.shared.download(metadata: metadata, selector: "") { (_) in }
+                        }
+                    )
+                )
+            }
+        }
+        
+        //
+        // PDF
+        //
+        if metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" {
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_search_", comment: ""),
+                    icon: UIImage(named: "search")!.image(color: NCBrandColor.shared.gray, size: 50),
+                    action: { menuAction in
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuSearchTextPDF)
+                    }
+                )
+            )
+        }
+        
+        //
+        // MODIFY
+        //
+        if #available(iOS 13.0, *) {
+            if !isFolderEncrypted && metadata.contentType != "image/gif" && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.typeFile == NCGlobal.shared.metadataTypeFileImage) {
+                actions.append(
+                    NCMenuAction(
+                        title: NSLocalizedString("_modify_", comment: ""),
+                        icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
+                        action: { menuAction in
+                            NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook)
+                        }
+                    )
+                )
+            }
+        }
+        
+        //
+        // DELETE
+        //
+        if !webView {
+            actions.append(
+                NCMenuAction(
+                    title: titleDelete,
+                    icon: NCUtility.shared.loadImage(named: "trash"),
+                    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
+                            
+                            NCNetworking.shared.deleteMetadata(metadata, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, onlyLocal: false) { (errorCode, errorDescription) in
+                                if errorCode != 0 {
+                                    NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                                }
+                            }
+                        })
+                        
+                        alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in })
+                                            
+                        viewController.present(alertController, animated: true, completion:nil)
+                    }
+                )
+            )
+        }
+        
+        menuViewController.actions = actions
+        
+        let menuPanelController = NCMenuPanelController()
+        menuPanelController.parentPresenter = viewController
+        menuPanelController.delegate = menuViewController
+        menuPanelController.set(contentViewController: menuViewController)
+        menuPanelController.track(scrollView: menuViewController.tableView)
+
+        viewController.present(menuPanelController, animated: true, completion: nil)
+    }
+}

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -79,7 +79,7 @@ class NCGlobal: NSObject {
     // Database Realm
     //
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 180
+    let databaseSchemaVersion: UInt64               = 181
     
     // Intro selector
     //

+ 4 - 0
iOSClient/Viewer/NCViewer.swift

@@ -192,9 +192,13 @@ class NCViewer: NSObject {
                 
                 if let navigationController = viewController.navigationController {
                     
+                    navigationController.navigationBar.prefersLargeTitles = false
+                    
                     let viewController = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
                     viewController.urlBase = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
                     viewController.isHiddenButtonExit = true
+                    viewController.titleBrowser = metadata.fileNameView
+                    viewController.metadata = metadata
 
                     navigationController.pushViewController(viewController, animated: true)
                 }