Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarinofaggiana <marino@marinofaggiana.com>2020-09-24 16:01:16 +0300
committermarinofaggiana <marino@marinofaggiana.com>2020-09-24 16:01:16 +0300
commit5acc3406f71fd14327391e834c93d09b2fdb054b (patch)
treedd062755bb9d454e87b13e437caaa741eb5db7de /iOSClient/Networking
parent55c2fcc236a2f5b4bad6478175370e2fcc07780a (diff)
coding
Diffstat (limited to 'iOSClient/Networking')
-rw-r--r--iOSClient/Networking/NCNetworkingNotificationCenter.swift32
1 files changed, 25 insertions, 7 deletions
diff --git a/iOSClient/Networking/NCNetworkingNotificationCenter.swift b/iOSClient/Networking/NCNetworkingNotificationCenter.swift
index 6360b88b0..928602696 100644
--- a/iOSClient/Networking/NCNetworkingNotificationCenter.swift
+++ b/iOSClient/Networking/NCNetworkingNotificationCenter.swift
@@ -23,12 +23,11 @@
import Foundation
-@objc class NCNetworkingNotificationCenter: NSObject {
+@objc class NCNetworkingNotificationCenter: NSObject, UIDocumentInteractionControllerDelegate {
@objc public static let shared: NCNetworkingNotificationCenter = {
let instance = NCNetworkingNotificationCenter()
NotificationCenter.default.addObserver(instance, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadedFile), object: nil)
-
NotificationCenter.default.addObserver(instance, selector: #selector(uploadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_uploadedFile), object: nil)
return instance
@@ -36,6 +35,7 @@ import Foundation
let appDelegate = UIApplication.shared.delegate as! AppDelegate
var viewerQuickLook: NCViewerQuickLook?
+ var docController: UIDocumentInteractionController?
//MARK: - Download
@@ -65,15 +65,15 @@ import Foundation
if metadata.contentType.contains("opendocument") && !NCUtility.shared.isRichDocument(metadata) {
- NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+ openIn(fileURL: fileURL, selector: selector)
} else if metadata.typeFile == k_metadataTypeFile_compress || metadata.typeFile == k_metadataTypeFile_unknown {
- NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+ openIn(fileURL: fileURL, selector: selector)
} else if metadata.typeFile == k_metadataTypeFile_imagemeter {
- NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+ openIn(fileURL: fileURL, selector: selector)
} else {
@@ -91,7 +91,7 @@ import Foundation
if UIApplication.shared.applicationState == UIApplication.State.active {
- NCMainCommon.shared.openIn(fileURL: fileURL, selector: selector)
+ openIn(fileURL: fileURL, selector: selector)
}
case selectorSaveAlbum:
@@ -141,6 +141,25 @@ import Foundation
}
}
+ func openIn(fileURL: URL, selector: String?) {
+
+ docController = UIDocumentInteractionController(url: fileURL)
+ docController?.delegate = self
+
+ if selector == selectorOpenInDetail {
+ guard let barButtonItem = appDelegate.activeDetail.navigationItem.rightBarButtonItem else { return }
+ guard let buttonItemView = barButtonItem.value(forKey: "view") as? UIView else { return }
+
+ docController?.presentOptionsMenu(from: buttonItemView.frame, in: buttonItemView, animated: true)
+
+ } else {
+ guard let splitViewController = appDelegate.window?.rootViewController as? UISplitViewController, let view = splitViewController.viewControllers.first?.view, let frame = splitViewController.viewControllers.first?.view.frame else {
+ return }
+
+ docController?.presentOptionsMenu(from: frame, in: view, animated: true)
+ }
+ }
+
//MARK: - Upload
@objc func uploadedFile(_ notification: NSNotification) {
@@ -158,6 +177,5 @@ import Foundation
}
}
}
-
}