Subversion Repositories Mobile Apps.GyroMouse

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
//
2
//  AppDelegate.swift
3
//  GyroMouse
4
//
5
//  Created by Matteo Riva on 07/08/15.
6
//  Copyright © 2015 Matteo Riva. All rights reserved.
7
//
8
 
9
import UIKit
10
 
11
//let yellow = UIColor(red: 255.0/255.0, green: 223.0/255.0, blue: 17.0/255.0, alpha: 1)
12
//let blue = UIColor(red: 41.0/255.0, green: 95.0/255.0, blue: 196.0/255.0, alpha: 1)
13
let minimumVersion = 0
14
 
15
let DidEnterBackgroundNotification = Notification.Name("DidEnterBackgroundNotification")
16
 
17
@UIApplicationMain
18
class AppDelegate: UIResponder, UIApplicationDelegate {
19
 
20
    var window: UIWindow?
21
 
22
    let client = ClientHandler()
23
 
24
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
25
        if !UserDefaults.standard.bool(forKey: "firstBoot") {
26
            UserDefaults.standard.set(10, forKey: "moveVelocity")
27
            UserDefaults.standard.set(1, forKey: "scrollVelocity")
28
            UserDefaults.standard.set(true, forKey: "shakeToReset")
29
            UserDefaults.standard.set(true, forKey: "keepScreenActive")
30
        }
31
 
32
        application.isIdleTimerDisabled = UserDefaults.standard.bool(forKey: "keepScreenActive")
33
 
34
        client.startBrowsing()
35
        return true
36
    }
37
 
38
    func applicationWillResignActive(_ application: UIApplication) {
39
        client.stopBrowsing()
40
        NotificationCenter.default.post(name: DidEnterBackgroundNotification, object: nil)
41
    }
42
 
43
    func applicationDidEnterBackground(_ application: UIApplication) {
44
        /// 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.
45
        /// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
46
    }
47
 
48
    func applicationWillEnterForeground(_ application: UIApplication) {
49
        client.startBrowsing()
50
    }
51
 
52
    func applicationDidBecomeActive(_ application: UIApplication) {
53
        client.startBrowsing()
54
    }
55
 
56
    func applicationWillTerminate(_ application: UIApplication) {
57
        /// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
58
    }
59
 
60
}
61
/*
62
@main
63
struct MyMain {
64
    static func main() -> Void {
65
        bootstrap_console()
66
         UIApplicationMain(
67
             CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self)
68
         )
69
    }
70
}
71
*/