<commit_before>//
//  AppDelegate.swift
//  WeatherAlarm
//
//  Created by longyutao on 15-2-28.
//  Copyright (c) 2015年 LongGames. All rights reserved.
//

import UIKit
import Foundation
import AudioToolbox
import AVFoundation

protocol AlarmApplicationDelegate
{
    //typealias Weekday
    func playAlarmSound()
    func setNotificationWithDate(date: NSDate)
    //something wrong with typealias, use Int instead
    func setNotificationWithDate(date: NSDate, onWeekdaysForNotify:[Int])
    func setupNotificationSettings()
    
    
}

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, AVAudioPlayerDelegate, AlarmApplicationDelegate{

    var window: UIWindow?
    var audioPlayer: AVAudioPlayer?
    //var alarmDelegate: AlarmApplicationDelegate?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        //alarmDelegate? = self
        //alarmDelegate!.setupNotificationSettings()
        
        setupNotificationSettings()
        return true
    }
    
    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        
        /*AudioServicesAddSystemSoundCompletion(SystemSoundID(kSystemSoundID_Vibrate),nil,
            nil,
            vibrationCallback,
            nil)*/
        
        playAlarmSound()
        //if app is in foreground, show a alert
        let storageController = UIAlertController(title: "Alarm", message: nil, preferredStyle: .Alert)
        //todo, snooze
        let snoozeOption = UIAlertAction(title: "Snooze", style: .Default) {
            (action:UIAlertAction!)->Void in audioPlayer?.stop()
            
        }
        let stopOption = UIAlertAction(title: "OK", style: .Default) {
            (action:UIAlertAction!)->Void in audioPlayer?.stop()}
        storageController.addAction(snoozeOption)<commit_msg>set window tintcolor to red<commit_after>//
//  AppDelegate.swift
//  WeatherAlarm
//
//  Created by longyutao on 15-2-28.
//  Copyright (c) 2015年 LongGames. All rights reserved.
//

import UIKit
import Foundation
import AudioToolbox
import AVFoundation

protocol AlarmApplicationDelegate
{
    //typealias Weekday
    func playAlarmSound()
    func setNotificationWithDate(date: NSDate)
    //something wrong with typealias, use Int instead
    func setNotificationWithDate(date: NSDate, onWeekdaysForNotify:[Int])
    func setupNotificationSettings()
    
    
}

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, AVAudioPlayerDelegate, AlarmApplicationDelegate{

    var window: UIWindow?
    var audioPlayer: AVAudioPlayer?
    //var alarmDelegate: AlarmApplicationDelegate?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        //alarmDelegate? = self
        //alarmDelegate!.setupNotificationSettings()
        
        setupNotificationSettings()
        window?.tintColor = UIColor.redColor()
        return true
    }
    
    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        
        /*AudioServicesAddSystemSoundCompletion(SystemSoundID(kSystemSoundID_Vibrate),nil,
            nil,
            vibrationCallback,
            nil)*/
        
        playAlarmSound()
        //if app is in foreground, show a alert
        let storageController = UIAlertController(title: "Alarm", message: nil, preferredStyle: .Alert)
        //todo, snooze
        let snoozeOption = UIAlertAction(title: "Snooze", style: .Default) {
            (action:UIAlertAction!)->Void in audioPlayer?.stop()
            
        }
        let stopOption = UIAlertAction(title: "OK", style: .Default) {
            (action:UIAlertAction!)->Void in audioPlayer?.stop()}
        storageController.addAction(snoozeOption)
{'fraction_non_alphanumeric': 0.085580014840465, 'fraction_numerical': 0.004452139500371012, 'mean_word_length': 3.1097560975609757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1666707', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1072, 'n_words': 265}