summaryrefslogtreecommitdiffstats
path: root/ios/LibreOfficeLight/LibreOfficeLight/AppDelegate.swift
blob: 9bdc1fefa48eb50d31744c2c37a9d10c53410f1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
// This file is part of the LibreOffice project.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
import UIKit
import Foundation



// AppDelegate is a Delegate class that receives calls from the iOS
// kernel, and theirby allows stop/start/sleep of the application
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
    var window: UIWindow?



    // sent when clicking on a OO document in another app
    // allowing this app to handle the document.
    // remark if the app is not started it will be started first
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
    {
        // called when started from another Application.
        // Jan to be done
        return true
    }



    // this function is called when the app is first started (loaded from EEProm)
    // it initializes the LO system and prepares for a normal run
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
    {
        // Get version info
        let appInfo = Bundle.main.infoDictionary! as Dictionary<String,AnyObject>
        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)
        return true
    }



    // Sent when the application is about to move from active to inactive state.
    // This can occur for certain types of temporary interruptions
    // (such as an incoming phone call or SMS message)
    // or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks.
    func applicationWillResignActive(_ application: UIApplication)
    {
        // NOT used in this App
    }



    // Sent when the application enters background (hipernating)
    // Use this method to release shared resources, save user data, invalidate timers,
    // and store enough application state information to restore your application to its current state
    // in case it is terminated later.
    // If your application supports background execution,
    // this method is called instead of applicationWillTerminate: when the user quits.
    func applicationDidEnterBackground(_ application: UIApplication)
    {
        let document = window?.rootViewController?.childViewControllers[0] as! DocumentController
        document.Hipernate()
    }



    // Sent before the application reenters foreground (hipernating -> active)
    // Restart timers, tasks as well as graphic rendering
    func applicationWillEnterForeground(_ application: UIApplication)
    {
        let document = window?.rootViewController?.childViewControllers[0] as! DocumentController
        document.LeaveHipernate()
    }



    // Sent after the application reenters foreground (hipernating -> active)
    // Restart timers, tasks as well as graphic rendering
    func applicationDidBecomeActive(_ application: UIApplication)
    {
        // NOT used in this App
    }



    // Sent when the application is about to terminate. Save data if appropriate.
    // See also applicationDidEnterBackground:.
    // Saves changes in the application's managed object context before the application terminates.
    func applicationWillTerminate(_ application: UIApplication)
    {
        // Jan to be done (terminate LO)
    }
}