From cfcdad938b2ca0fb9a4059530180bc1c7d1424bd Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sat, 28 Oct 2017 19:55:54 +0200 Subject: iOS, use UIDocumentPickerViewController UIDocumentPickerViewController is new in iOS 11.0 and provides much more flexibility. Change-Id: Idd44ab57e8ddbf707327e8a66c5dae2a05ee172c --- .../LibreOfficeLight/AppDelegate.swift | 6 - .../LibreOfficeLight/DocumentController.swift | 76 +++--- .../LibreOfficeLight/en.lproj/Main.storyboard | 291 +++++---------------- 3 files changed, 100 insertions(+), 273 deletions(-) diff --git a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift index bb44f98d1ec3..dd6ee4183a80 100644 --- a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift @@ -9,8 +9,6 @@ import UIKit import Foundation -var isCloudEnabled : Bool = false - @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate @@ -74,16 +72,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate func applicationWillEnterForeground(_ application: UIApplication) { - // test if iCloud is still enabled - isCloudEnabled = (FileManager.default.ubiquityIdentityToken != nil) } func applicationDidBecomeActive(_ application: UIApplication) { - // test if iCloud is still enabled - isCloudEnabled = (FileManager.default.ubiquityIdentityToken != nil) } diff --git a/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift b/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift index 82b3613cc789..c8c374ade570 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift @@ -7,29 +7,13 @@ // import UIKit - - -class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelegate +class DocumentController: UIViewController, MenuDelegate, UIDocumentBrowserViewControllerDelegate { var currentDocumentName : String? var currentCloudUrl : URL? var currentStorageLocal : Bool = true - public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) - { - currentCloudUrl = url - currentDocumentName = url.lastPathComponent - } - - func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) - { - currentCloudUrl = nil - currentDocumentName = nil - } - - - @IBOutlet weak var janTest: UILabel! // Show sidemenu (part of documentcontroller) @@ -60,7 +44,6 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega addChildViewController(sidebar) sidebar.view.layoutIfNeeded() - sidebar.view.frame=CGRect(x: 0 - UIScreen.main.bounds.size.width, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height); UIView.animate(withDuration: 0.3, animations: { () -> Void in @@ -70,18 +53,33 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega } - @IBOutlet weak var buttonSelectStorage: UIBarButtonItem! + internal func documentBrowser(_ controller: UIDocumentBrowserViewController, + didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) + { + // Asks the delegate to create a new document. + } + + internal func documentBrowser(_ controller: UIDocumentBrowserViewController, + didImportDocumentAt sourceURL: URL, + toDestinationURL destinationURL: URL) + { + // Tells the delegate that a document has been successfully imported. + } + internal func documentBrowser(_ controller: UIDocumentBrowserViewController, + failedToImportDocumentAt documentURL: URL, + error: Error?) + { + // Tells the delegate that the document browser failed to import the specified document. + } - @IBAction func doSelectStorage(_ sender: UIBarButtonItem) + internal func documentBrowser(_ controller: UIDocumentBrowserViewController, + didPickDocumentURLs documentURLs: [URL]) { - if isCloudEnabled { - currentStorageLocal = !currentStorageLocal - sender.image = currentStorageLocal ? #imageLiteral(resourceName: "iCloudDrive") : #imageLiteral(resourceName: "iPhone") - } - self.presentedViewController?.dismiss(animated: true, completion: nil) + // Tells the delegate that the user has selected one or more documents. } + @IBOutlet weak var janTest: UILabel! // Last stop before displaying popover override func prepare(for segue: UIStoryboardSegue, sender: Any?) @@ -108,19 +106,20 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega { switch tag { - case 1: // New - print("menu New to be done") - - case 2: // Open... - let openMenu = UIDocumentPickerViewController(documentTypes: ["public.content"], in: .open) + case 1: // Open... + // let openMenu = UIDocumentPickerViewController(documentTypes: ["public.data"], in: .open) + let openMenu = UIDocumentBrowserViewController() + //penMenu.allowsDocumentCreation = true + // UIDocumentBrowserViewController.ImportMode = UIDocumentBrowserViewController.ImportMode.none // copy, move + //openMenu.InterfaceStyle = UIDocumentPickerViewController.dark openMenu.delegate = self self.present(openMenu, animated: true, completion: nil) print("menu Open... to be done") - case 3: // Save + case 2: // Save print("menu Save to be done") - case 4: // Save as... + case 3: // Save as... let vc = storyboard?.instantiateViewController(withIdentifier: "setNameAction") as! setNameAction vc.modalPresentationStyle = .popover vc.delegate = self @@ -132,21 +131,12 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega present(vc, animated: true, completion: nil) print("menu Save as... to be done") - case 5: // Save as PDF... + case 4: // Save as PDF... print("menu Save as PDF... to be done") - case 6: // Print... + case 5: // Print... print("menu Print... to be done") - case 7: // Copy... - print("menu Copy... to be done") - - case 8: // Move... - print("menu Move... to be done") - - case 9: // Delete... - print("menu Delete... to be done") - default: // should not happen print("unknown menu" + String(tag)) } diff --git a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard index aa0295e021c5..51bf66cbbb53 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard +++ b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard @@ -4,10 +4,8 @@ - - @@ -35,18 +33,11 @@ - - - - - - - - - - - - + + + + + @@ -57,7 +48,6 @@ - @@ -65,62 +55,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -195,114 +129,112 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -354,41 +286,20 @@ - + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -558,17 +406,13 @@ - + - + - - - - @@ -583,7 +427,6 @@ - -- cgit v1.2.3