Blame client/iOS/AppDelegate.m

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