From 77663321f096d60dc6ff34b2e2ab209db99cda72 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Fri, 27 Oct 2017 19:37:53 +0200 Subject: iOS online check for iCloud Added check for active iCloud during startup as well as when returning from background. Change-Id: I4481a4cc7814540da98c4c432fe04543316fa7aa --- ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift | 10 ++++++---- ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift | 9 +++++---- ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'ios/LibreOfficeLight') diff --git a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift index b77f53ece586..bb44f98d1ec3 100644 --- a/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift @@ -9,6 +9,8 @@ import UIKit import Foundation +var isCloudEnabled : Bool = false + @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate @@ -72,16 +74,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the active state; - // here you can undo many of the changes made on entering the background. - - //JIX add code to check iCloud again + // 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 1d02c01bb364..82b3613cc789 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift +++ b/ios/LibreOfficeLight/LibreOfficeLight/DocumentController.swift @@ -13,7 +13,7 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega { var currentDocumentName : String? var currentCloudUrl : URL? - var currentStorageLocal : Bool = false + var currentStorageLocal : Bool = true public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) @@ -75,8 +75,10 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega @IBAction func doSelectStorage(_ sender: UIBarButtonItem) { - currentStorageLocal = !currentStorageLocal - sender.image = currentStorageLocal ? #imageLiteral(resourceName: "iCloudDrive") : #imageLiteral(resourceName: "iPhone") + if isCloudEnabled { + currentStorageLocal = !currentStorageLocal + sender.image = currentStorageLocal ? #imageLiteral(resourceName: "iCloudDrive") : #imageLiteral(resourceName: "iPhone") + } self.presentedViewController?.dismiss(animated: true, completion: nil) } @@ -95,7 +97,6 @@ class DocumentController: UIViewController, MenuDelegate, UIDocumentPickerDelega - func actionName(_ name : String) { currentDocumentName = name diff --git a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard index 299547157e8c..aa0295e021c5 100755 --- a/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard +++ b/ios/LibreOfficeLight/LibreOfficeLight/en.lproj/Main.storyboard @@ -41,7 +41,7 @@ - + @@ -583,7 +583,7 @@ - + -- cgit