From 351d83c357093ac0ec6d3768355df9ee1b224d02 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Sun, 29 Oct 2017 10:15:44 +0100 Subject: iOS background handling When the app moves to background (hipernate) LOkit needs to be stopped, and when it reenters foreground started again. In order to keep AppDelegate slim as recommended, calls to DocumentController are added. Change-Id: I7e4c8c5ae7fe29235381e3e7217abfd1911e39ad --- .../LibreOfficeLight/AppDelegate.swift | 10 +++-- .../LibreOfficeLight/DocumentController.swift | 25 ++++++++++-- .../LibreOfficeLight/en.lproj/Main.storyboard | 44 ++++++++++++++++------ 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift index 12e596bc030d..9bdc1fefa48e 100644 --- a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift @@ -39,14 +39,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate let appInfo = Bundle.main.infoDictionary! as Dictionary let applicationVersion = (appInfo["CFBundleShortVersionString"] as! String) + "." + (appInfo["CFBundleVersion"] as! String) + + // Add version string to setting let defaults = UserDefaults.standard defaults.set(applicationVersion, forKey: "application_version") defaults.synchronize() // start LibreOfficeKit //FIX BridgeLOkit_Init(Bundle.main.bundlePath) - //FIX BridgeLOkit_open("jan"); - //FIX BridgeLOkit_ClientCommand("jan"); return true } @@ -72,7 +72,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate // this method is called instead of applicationWillTerminate: when the user quits. func applicationDidEnterBackground(_ application: UIApplication) { - // Jan to do done (scale down LO) + let document = window?.rootViewController?.childViewControllers[0] as! DocumentController + document.Hipernate() } @@ -81,7 +82,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate // Restart timers, tasks as well as graphic rendering func applicationWillEnterForeground(_ application: UIApplication) { - // Jan to be done (reactivate LO) + let document = window?.rootViewController?.childViewControllers[0] as! DocumentController + document.LeaveHipernate() } diff --git a/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift b/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift index 1ef7d80c792f..0190ad946666 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift @@ -53,6 +53,14 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentBrowserViewC + public func Hipernate() -> Void + { + } + + public func LeaveHipernate() -> Void + { + } + // var currentDocumentName : String? @@ -67,6 +75,9 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentBrowserViewC toDestinationURL destinationURL: URL) { // Tells the delegate that a document has been successfully imported. + //FIX BridgeLOkit_open("jan"); + //FIX BridgeLOkit_ClientCommand("jan"); + } internal func documentBrowser(_ controller: UIDocumentBrowserViewController, @@ -80,6 +91,8 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentBrowserViewC didPickDocumentURLs documentURLs: [URL]) { // Tells the delegate that the user has selected one or more documents. + //FIX BridgeLOkit_open("jan"); + //FIX BridgeLOkit_ClientCommand("jan"); } @IBOutlet weak var janTest: UILabel! @@ -112,16 +125,19 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentBrowserViewC self.present(openMenu, animated: true, completion: nil) print("menu Open... to be done") - case 2: // Save + case 2: // Properties + print("menu Properties to be done") + + case 3: // Save print("menu Save to be done") - case 3: // Save as... + case 4: // Save as... print("menu Save as... to be done") - case 4: // Save as PDF... + case 5: // Save as PDF... print("menu Save as PDF... to be done") - case 5: // Print... + case 6: // Print... print("menu Print... to be done") default: // should not happen @@ -172,6 +188,7 @@ class DocumentActions: UITableViewController delegate?.actionMenuSelected(sender.tag) } + @IBOutlet weak var buttonProperties: UIButton! @IBOutlet weak var buttonNew: UIButton! @IBOutlet weak var buttonOpen: UIButton! @IBOutlet weak var buttonSave: UIButton! diff --git a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard index 25d77018d279..81a2b4b5376c 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard +++ b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard @@ -286,7 +286,7 @@ - + @@ -320,7 +320,28 @@ - + + + + + + + + + + + - + -