Blame client/iOS/AppDelegate.m

Packit 1fb8d4
/*
Packit 1fb8d4
 App delegate
Packit 1fb8d4
 
Packit 1fb8d4
 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
Packit 1fb8d4
 
Packit 1fb8d4
 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
Packit 1fb8d4
 If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#import "AppDelegate.h"
Packit 1fb8d4
Packit 1fb8d4
#import "AboutController.h"
Packit 1fb8d4
#import "HelpController.h"
Packit 1fb8d4
#import "BookmarkListController.h"
Packit 1fb8d4
#import "AppSettingsController.h"
Packit 1fb8d4
#import "MainTabBarController.h"
Packit 1fb8d4
#import "Utils.h"
Packit 1fb8d4
Packit 1fb8d4
@implementation AppDelegate
Packit 1fb8d4
Packit 1fb8d4
Packit 1fb8d4
@synthesize window = _window, tabBarController = _tabBarController;
Packit 1fb8d4
Packit 1fb8d4
Packit 1fb8d4
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Packit 1fb8d4
{    
Packit 1fb8d4
	// Set default values for most NSUserDefaults
Packit 1fb8d4
	[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]]];
Packit 1fb8d4
Packit 1fb8d4
    // init global settings
Packit 1fb8d4
    SetSwapMouseButtonsFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]);
Packit 1fb8d4
    SetInvertScrollingFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]);
Packit 1fb8d4
    
Packit 1fb8d4
    // create bookmark view and navigation controller
Packit 1fb8d4
    BookmarkListController* bookmarkListController = [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView" bundle:nil] autorelease];
Packit 1fb8d4
    UINavigationController* bookmarkNavigationController = [[[UINavigationController alloc] initWithRootViewController:bookmarkListController] autorelease];	
Packit 1fb8d4
Packit 1fb8d4
    // create app settings view and navigation controller
Packit 1fb8d4
    AppSettingsController* appSettingsController = [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
Packit 1fb8d4
    UINavigationController* appSettingsNavigationController = [[[UINavigationController alloc] initWithRootViewController:appSettingsController] autorelease];	
Packit 1fb8d4
     
Packit 1fb8d4
    // create help view controller
Packit 1fb8d4
    HelpController* helpViewController = [[[HelpController alloc] initWithNibName:nil bundle:nil] autorelease];
Packit 1fb8d4
Packit 1fb8d4
    // create about view controller
Packit 1fb8d4
    AboutController* aboutViewController = [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease];
Packit 1fb8d4
     
Packit 1fb8d4
    // add tab-bar controller to the main window and display everything
Packit 1fb8d4
    NSArray* tabItems = [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController, helpViewController, aboutViewController, nil];
Packit 1fb8d4
    [_tabBarController setViewControllers:tabItems];
Packit 1fb8d4
    if ([_window respondsToSelector:@selector(setRootViewController:)])
Packit 1fb8d4
        [_window setRootViewController:_tabBarController];
Packit 1fb8d4
    else
Packit 1fb8d4
        [_window addSubview:[_tabBarController view]];
Packit 1fb8d4
    [_window makeKeyAndVisible];	   
Packit 1fb8d4
Packit 1fb8d4
    return YES;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)applicationWillResignActive:(UIApplication *)application
Packit 1fb8d4
{
Packit 1fb8d4
    /*
Packit 1fb8d4
     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.
Packit 1fb8d4
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
Packit 1fb8d4
     */
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)applicationDidEnterBackground:(UIApplication *)application
Packit 1fb8d4
{
Packit 1fb8d4
    /*
Packit 1fb8d4
     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. 
Packit 1fb8d4
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
Packit 1fb8d4
     */
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)applicationWillEnterForeground:(UIApplication *)application
Packit 1fb8d4
{
Packit 1fb8d4
    /*
Packit 1fb8d4
     Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
Packit 1fb8d4
     */
Packit 1fb8d4
    // cancel disconnect timer
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)applicationDidBecomeActive:(UIApplication *)application
Packit 1fb8d4
{
Packit 1fb8d4
    /*
Packit 1fb8d4
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
Packit 1fb8d4
     */
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)applicationWillTerminate:(UIApplication *)application
Packit 1fb8d4
{
Packit 1fb8d4
    /*
Packit 1fb8d4
     Called when the application is about to terminate.
Packit 1fb8d4
     Save data if appropriate.
Packit 1fb8d4
     See also applicationDidEnterBackground:.
Packit 1fb8d4
     */
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
- (void)dealloc
Packit 1fb8d4
{
Packit 1fb8d4
    [_window release];
Packit 1fb8d4
    [super dealloc];
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
@end