Uses UIAlertController instead of UIDocumentMenuViewController for Cydia Impactor builds
This commit is contained in:
parent
f81830230f
commit
e5f232b7b2
@ -1029,6 +1029,7 @@
|
||||
INFOPLIST_FILE = "Delta/Supporting Files/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -DIMPACTOR";
|
||||
PROVISIONING_PROFILE = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Delta/Supporting Files/Delta-Bridging-Header.h";
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MobileCoreServices
|
||||
import ObjectiveC
|
||||
|
||||
import DeltaCore
|
||||
|
||||
import MobileCoreServices
|
||||
import Roxas
|
||||
|
||||
protocol ImportControllerDelegate
|
||||
{
|
||||
@ -49,6 +50,23 @@ class ImportController: NSObject
|
||||
{
|
||||
self.presentingViewController = presentingViewController
|
||||
|
||||
#if IMPACTOR
|
||||
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
alertController.addAction(UIAlertAction.cancel)
|
||||
|
||||
if let importOptions = self.importOptions
|
||||
{
|
||||
for importOption in importOptions
|
||||
{
|
||||
alertController.add(importOption, completionHandler: finish(with:))
|
||||
}
|
||||
}
|
||||
|
||||
self.presentingViewController?.present(alertController, animated: true, completion: nil)
|
||||
|
||||
#else
|
||||
|
||||
let documentMenuController = UIDocumentMenuViewController(documentTypes: Array(self.documentTypes), in: .import)
|
||||
documentMenuController.delegate = self
|
||||
|
||||
@ -56,22 +74,27 @@ class ImportController: NSObject
|
||||
{
|
||||
for importOption in reversedImportOptions
|
||||
{
|
||||
documentMenuController.add(importOption, order: UIDocumentMenuOrder.first) { (urls) in
|
||||
if let urls = urls
|
||||
{
|
||||
self.delegate?.importController(self, didImportItemsAt: urls)
|
||||
}
|
||||
else
|
||||
{
|
||||
self.delegate?.importControllerDidCancel(self)
|
||||
}
|
||||
|
||||
self.presentingViewController?.importController = nil
|
||||
}
|
||||
documentMenuController.add(importOption, order: .first, completionHandler: finish(with:))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.presentingViewController?.present(documentMenuController, animated: true, completion: nil)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
fileprivate func finish(with urls: Set<URL>?)
|
||||
{
|
||||
if let urls = urls
|
||||
{
|
||||
self.delegate?.importController(self, didImportItemsAt: urls)
|
||||
}
|
||||
else
|
||||
{
|
||||
self.delegate?.importControllerDidCancel(self)
|
||||
}
|
||||
|
||||
self.presentingViewController?.importController = nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,9 +109,7 @@ extension ImportController: UIDocumentMenuDelegate
|
||||
|
||||
func documentMenuWasCancelled(_ documentMenu: UIDocumentMenuViewController)
|
||||
{
|
||||
self.delegate?.importControllerDidCancel(self)
|
||||
|
||||
self.presentingViewController?.importController = nil
|
||||
self.finish(with: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,16 +117,12 @@ extension ImportController: UIDocumentPickerDelegate
|
||||
{
|
||||
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL)
|
||||
{
|
||||
self.delegate?.importController(self, didImportItemsAt: [url])
|
||||
|
||||
self.presentingViewController?.importController = nil
|
||||
self.finish(with: [url])
|
||||
}
|
||||
|
||||
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController)
|
||||
{
|
||||
self.delegate?.importControllerDidCancel(self)
|
||||
|
||||
self.presentingViewController?.importController = nil
|
||||
self.finish(with: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,17 @@ extension UIDocumentMenuViewController
|
||||
}
|
||||
}
|
||||
|
||||
extension UIAlertController
|
||||
{
|
||||
func add(_ importOption: ImportOption, completionHandler: @escaping (Set<URL>?) -> Void)
|
||||
{
|
||||
let action = UIAlertAction(title: importOption.title, style: .default, handler: { action in
|
||||
importOption.import(withCompletionHandler: completionHandler)
|
||||
})
|
||||
self.addAction(action)
|
||||
}
|
||||
}
|
||||
|
||||
protocol ImportOption
|
||||
{
|
||||
var title: String { get }
|
||||
|
||||
2
External/Roxas
vendored
2
External/Roxas
vendored
@ -1 +1 @@
|
||||
Subproject commit 9143d01afa25f07da8f1cdb5390b49f4efb1a75f
|
||||
Subproject commit 356ea5d714ee48ddf4a976b89a9579bb7d05b938
|
||||
Loading…
Reference in New Issue
Block a user