Blame client/iOS/AppDelegate.m

Packit Service fa4841
/*
Packit Service fa4841
 App delegate
Packit Service bb5c11
 
Packit Service fa4841
 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
Packit Service bb5c11
 
Packit Service bb5c11
 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
Packit Service bb5c11
 If a copy of the MPL was not distributed with this file, You can obtain one at 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 bb5c11
Packit Service fa4841
@synthesize window = _window, tabBarController = _tabBarController;
Packit Service fa4841
Packit Service bb5c11
Packit Service bb5c11
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Packit Service bb5c11
{    
Packit Service fa4841
	// Set default values for most NSUserDefaults
Packit Service bb5c11
	[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"]]];
Packit Service bb5c11
Packit Service bb5c11
    // init global settings
Packit Service bb5c11
    SetSwapMouseButtonsFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.swap_mouse_buttons"]);
Packit Service bb5c11
    SetInvertScrollingFlag([[NSUserDefaults standardUserDefaults] boolForKey:@"ui.invert_scrolling"]);
Packit Service bb5c11
    
Packit Service bb5c11
    // create bookmark view and navigation controller
Packit Service bb5c11
    BookmarkListController* bookmarkListController = [[[BookmarkListController alloc] initWithNibName:@"BookmarkListView" bundle:nil] autorelease];
Packit Service bb5c11
    UINavigationController* bookmarkNavigationController = [[[UINavigationController alloc] initWithRootViewController:bookmarkListController] autorelease];	
Packit Service bb5c11
Packit Service bb5c11
    // create app settings view and navigation controller
Packit Service bb5c11
    AppSettingsController* appSettingsController = [[[AppSettingsController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
Packit Service bb5c11
    UINavigationController* appSettingsNavigationController = [[[UINavigationController alloc] initWithRootViewController:appSettingsController] autorelease];	
Packit Service bb5c11
     
Packit Service bb5c11
    // create help view controller
Packit Service bb5c11
    HelpController* helpViewController = [[[HelpController alloc] initWithNibName:nil bundle:nil] autorelease];
Packit Service bb5c11
Packit Service bb5c11
    // create about view controller
Packit Service bb5c11
    AboutController* aboutViewController = [[[AboutController alloc] initWithNibName:nil bundle:nil] autorelease];
Packit Service bb5c11
     
Packit Service bb5c11
    // add tab-bar controller to the main window and display everything
Packit Service bb5c11
    NSArray* tabItems = [NSArray arrayWithObjects:bookmarkNavigationController, appSettingsNavigationController, helpViewController, aboutViewController, nil];
Packit Service bb5c11
    [_tabBarController setViewControllers:tabItems];
Packit Service bb5c11
    if ([_window respondsToSelector:@selector(setRootViewController:)])
Packit Service bb5c11
        [_window setRootViewController:_tabBarController];
Packit Service bb5c11
    else
Packit Service bb5c11
        [_window addSubview:[_tabBarController view]];
Packit Service bb5c11
    [_window makeKeyAndVisible];	   
Packit Service bb5c11
Packit Service bb5c11
    return YES;
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)applicationWillResignActive:(UIApplication *)application
Packit Service fa4841
{
Packit Service bb5c11
    /*
Packit Service bb5c11
     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 Service bb5c11
     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 Service bb5c11
     */
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)applicationDidEnterBackground:(UIApplication *)application
Packit Service fa4841
{
Packit Service bb5c11
    /*
Packit Service bb5c11
     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 Service bb5c11
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
Packit Service bb5c11
     */
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)applicationWillEnterForeground:(UIApplication *)application
Packit Service fa4841
{
Packit Service bb5c11
    /*
Packit Service bb5c11
     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 Service bb5c11
     */
Packit Service bb5c11
    // cancel disconnect timer
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)applicationDidBecomeActive:(UIApplication *)application
Packit Service fa4841
{
Packit Service bb5c11
    /*
Packit Service bb5c11
     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 Service bb5c11
     */
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)applicationWillTerminate:(UIApplication *)application
Packit Service fa4841
{
Packit Service bb5c11
    /*
Packit Service bb5c11
     Called when the application is about to terminate.
Packit Service bb5c11
     Save data if appropriate.
Packit Service bb5c11
     See also applicationDidEnterBackground:.
Packit Service bb5c11
     */
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
- (void)dealloc
Packit Service fa4841
{
Packit Service bb5c11
    [_window release];
Packit Service bb5c11
    [super dealloc];
Packit Service fa4841
}
Packit Service fa4841
Packit Service fa4841
@end