Blame client/iOS/AppDelegate.m

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