Timer_AppDelegate

@UIApplicationMain
class Timer_AppDelegate : UIResponder, UIApplicationDelegate, WCSessionDelegate

This is the main application delegate class for the timer app.

  • This is the brightness we want our screen to be when the timer is running.

    Declaration

    Swift

    static let runningScreenBrightness: CGFloat
  • This is a special variable that holds the screen brightness level from just before we first change it from the app. We will use this to restore the original screen brightness.

    Declaration

    Swift

    static var originalScreenBrightness: CGFloat!
  • This struct will contain information about a song in our media library.

    See more

    Declaration

    Swift

    struct SongInfo
  • This is a quick way to get this object instance (it’s a SINGLETON), cast as the correct class.

    Declaration

    Swift

    static var appDelegateObject: Timer_AppDelegate { get }
  • Used to force orientation for the individual timer settings page.

    Declaration

    Swift

    var orientationLock: UIInterfaceOrientationMask
  • The app window object.

    Declaration

    Swift

    var window: UIWindow?
  • If a timer is up, we keep it here for easy access.

    Declaration

    Swift

    var currentTimer: TimerRuntimeViewController!
  • The loaded prefs.

    Declaration

    Swift

    var useUserInfo: Bool
  • If the watch app is not connected, this is true.

    Declaration

    Swift

    var watchDisconnected: Bool
  • This is set (for convenience) if the timer settings page is up.

    Declaration

    Swift

    var timerListController: Timer_SettingsViewController!
  • This is a semaphore for preventing multiple signals from the watch.

    Declaration

    Swift

    var ignoreSelectMessageFromWatch: Int
  • This contains information about music items. We keep these here, so they stay loaded up between timers.

    Declaration

    Swift

    var songs: [String : [Timer_AppDelegate.SongInfo]]
  • This is an index of the keys (artists) for the songs Dictionary.

    Declaration

    Swift

    var artists: [String]
  • This will force the screen to ignore the accelerometer setting.

    Declaration

    Swift

    class func lockOrientation(_ orientation: UIInterfaceOrientationMask)

    Parameters

    orientation

    The orientation that should be locked.

  • This will force the screen to ignore the accelerometer setting and force the screen into that orientation.

    Declaration

    Swift

    class func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation: UIInterfaceOrientation)

    Parameters

    orientation

    The orientation that should be locked.

    andRotateTo

    The orientation that should be forced.

  • Displays the given error in an alert with an OK button.

    Declaration

    Swift

    class func displayAlert(_ inTitle: String, inMessage: String, presentedBy inPresentingViewController: UIViewController! = nil)

    Parameters

    inTitle

    a string to be displayed as the title of the alert. It is localized by this method.

    inMessage

    a string to be displayed as the message of the alert. It is localized by this method.

    presentedBy

    An optional UIViewController object that is acting as the presenter context for the alert. If nil, we use the top controller of the Navigation stack.

  • If the brightness level has not already been recorded, we do so now.

    Declaration

    Swift

    class func recordOriginalBrightness()
  • This restores our recorded brightness level to the screen.

    Declaration

    Swift

    class func restoreOriginalBrightness()
  • This will be the watch connection session (UNUSED)

    Declaration

    Swift

    private var _mySession: WCSession!
  • Accessor for the session

    Declaration

    Swift

    var session: WCSession! { get }
  • Returns the current app status.

    Declaration

    Swift

    var appState: LGV_Timer_State! { get }
  • We record our screen brightness, here.

    Declaration

    Swift

    func applicationDidFinishLaunching(_: UIApplication)
  • We record our screen brightness, here.

    Declaration

    Swift

    func applicationDidBecomeActive(_: UIApplication)
  • We record our screen brightness, here.

    Declaration

    Swift

    func applicationWillEnterForeground(_: UIApplication)
  • We restore the screen to its original recorded level.

    Declaration

    Swift

    func applicationWillResignActive(_: UIApplication)
  • Called when the app goes into the background. This will ensure the current timer state is saved.

    Declaration

    Swift

    func applicationDidEnterBackground(_: UIApplication)
  • This is used to lock the orientation while the timer editor is up.

    Declaration

    Swift

    func application(_: UIApplication, supportedInterfaceOrientationsFor: UIWindow?) -> UIInterfaceOrientationMask

    Parameters

    supportedInterfaceOrientationsFor

    ignored

  • Called when the app will terminate. This will ensure the current timer state is saved.

    Declaration

    Swift

    func applicationWillTerminate(_ application: UIApplication)

    Parameters

    application

    The application object.