// // PicCastAppDelegate.m // PicCast // // Created by Matthew Handler on 4/15/11. // Copyright 2011 Earl Industries. All rights reserved. // #import "PicCastAppDelegate.h" #import @implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { //NSLog(@"titlebar: %@", self.barStyle); if (self.barStyle == UIBarStyleDefault) { UIImage *image = [UIImage imageNamed: @"titleBarBackground.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } else { UIImage *image = [UIImage imageNamed: @"titleBarBackgroundBlack.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } //[super drawRect:rect]; } @end @implementation PicCastAppDelegate @synthesize window; @synthesize tabBarController; @synthesize navigationController; //- (void)initialize { // [[NSUserDefaults standardUserDefaults] // registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: // NULL, @"facebookToken", // NULL, @"facebookExpirationDate", // NULL, @"twitterToken", // [NSNumber numberWithBool:NO], @"haveSearched", // nil]]; //} #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the tab bar controller's view to the window and display. NSLog(@"launched"); [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; [self.window addSubview:tabBarController.view]; [self.window makeKeyAndVisible]; [self doDefaultPngFade]; //navigationController = [[UINavigationController alloc] initWithRootViewController:(UIViewController *)tabBarController]; // this was put in because i errored out on some gif files that i guess were really large? [[TTURLRequestQueue mainQueue] setMaxContentLength:0]; // UIWindow *window = [appDelegate window]; // UIImageView *bgView = [[UIImageView alloc] init]; // [bgView setImage:[UIImage imageNamed: @"backgroundGradient.png"]]; // [self.window setb]; return YES; } - (void)doDefaultPngFade { // add the new image to fade out UIImageView * defaultFadeImage; defaultFadeImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]] autorelease]; [self.tabBarController.view addSubview:defaultFadeImage]; // and start the default fadeout [UIView beginAnimations:@"InitialFadeIn" context:nil]; [UIView setAnimationDelegate:defaultFadeImage]; [UIView setAnimationDidStopSelector:@selector( removeFromSuperview )]; [UIView setAnimationDelay:0.0]; // stay on this long extra [UIView setAnimationDuration:1.00]; // transition speed [defaultFadeImage setAlpha:0.0]; [UIView commitAnimations]; } - (void)applicationWillResignActive:(UIApplication *)application { /* 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. 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. */ } - (void)applicationDidEnterBackground:(UIApplication *)application { /* 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. If your application supports background execution, called instead of applicationWillTerminate: when the user quits. */ } - (void)applicationWillEnterForeground:(UIApplication *)application { /* Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. */ } - (void)applicationDidBecomeActive:(UIApplication *)application { /* 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. */ } - (void)applicationWillTerminate:(UIApplication *)application { /* Called when the application is about to terminate. See also applicationDidEnterBackground:. */ } #pragma mark - #pragma mark CustomSheeyit + (void) prompt:(NSString *)title withMessage:(NSString *)message andButtonTitle:(NSString *)buttonTitle withDelegate:(id)delegate { UIAlertView *prompt = [UIAlertView alloc]; prompt = [prompt initWithTitle:title message:message delegate:delegate cancelButtonTitle:buttonTitle otherButtonTitles:nil]; [prompt show]; [prompt release]; } + (void) prompt:(NSString *)title withMessage:(NSString *)message andButtonTitle:(NSString *)buttonTitle { [self prompt:title withMessage:message andButtonTitle:buttonTitle withDelegate:self]; } - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { NSLog(@"url: %@", [url absoluteString]); return YES; //return [facebook handleOpenURL:url]; } + (NSString *) getDatabasePath { NSString *databaseName = @"PicCastSqlTable.db"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; NSString *databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; NSFileManager *fileManager = [NSFileManager defaultManager]; // change this when you are ready to test persistence if(![fileManager fileExistsAtPath:databasePath]) { NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; } return databasePath; } #pragma mark - #pragma mark UITabBarControllerDelegate methods /* // Optional UITabBarControllerDelegate method. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { } */ /* // Optional UITabBarControllerDelegate method. - (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed { } */ #pragma mark - #pragma mark Memory management - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { /* Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. */ } - (void)dealloc { [tabBarController release]; [navigationController release]; [window release]; [super dealloc]; } @end