Merge Issue 414. App store submission schedules in a fex days

git-svn-id: https://zxing.googlecode.com/svn/trunk@2088 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
rpechayr 2011-12-16 14:46:58 +00:00
parent f3f5720a8e
commit 6f851acf9c
3 changed files with 71 additions and 1 deletions

View file

@ -7,14 +7,20 @@
//
#import <UIKit/UIKit.h>
#import "ZXMainViewController.h"
@interface BarcodesAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
ZXMainViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet ZXMainViewController *viewController;
- (void)registerView:(ZXMainViewController*)controller;
@end

View file

@ -12,12 +12,58 @@
@synthesize window;
@synthesize tabBarController;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)myOpenURL:(NSURL*)url {
if (!url) return NO;
if ([[url scheme] isEqualToString:@"zxing"]) {
if ([[url host] isEqualToString:@"scan"]) {
NSArray *pairs = [[url query] componentsSeparatedByString:@"&amp;"];
for (NSString *pair in pairs) {
NSArray *elements = [pair componentsSeparatedByString:@"="];
NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if ([key isEqualToString:@"ret"]) {
[[NSUserDefaults standardUserDefaults] setObject:val forKey:@"returnURL"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[self viewController] scan:nil];
}
if ([key isEqualToString:@"SCAN_FORMATS"]) {
// Storing these, but they effect nothing yet.
NSArray *formats = [val componentsSeparatedByString:@","];
[[NSUserDefaults standardUserDefaults] setObject:formats forKey:@"scanFormats"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
}
return YES;
} else {
return NO;
}
}
- (void)registerView:(ZXMainViewController*)controller {
[self setViewController:controller];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Check if launching from URL
NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];
if ([url isMemberOfClass: [NSURL class]]) {
return [self myOpenURL: url];
} else {
// Clear the return URL so the application goes back to working as normal...
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"returnURL"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"scanFormats"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
// Override point for customization after application launch.
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
@ -25,6 +71,10 @@
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return [self myOpenURL: url];
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
@ -39,6 +89,11 @@
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.
*/
// Clear the return URL so the application goes back to working as normal...
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"returnURL"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"scanFormats"];
[[NSUserDefaults standardUserDefaults] synchronize];
}

View file

@ -15,6 +15,7 @@
#import "ArchiveController.h"
#import "Database.h"
#import "ScanViewController.h"
#import "BarcodesAppDelegate.h"
@implementation ZXMainViewController
@synthesize actions;
@ -36,6 +37,8 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"Barcodes";
[((BarcodesAppDelegate*)[[UIApplication sharedApplication] delegate]) registerView:self];
}
@ -111,7 +114,13 @@
#endif
Scan * scan = [[Database sharedDatabase] addScanWithText:resultString];
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
NSString *returnUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"returnURL"];
if (returnUrl != nil) {
NSURL *ourURL = [NSURL URLWithString:[returnUrl stringByReplacingOccurrencesOfString:@"{CODE}" withString:resultString]];
[[UIApplication sharedApplication] openURL:ourURL];
return;
}
ParsedResult *parsedResult = [UniversalResultParser parsedResultForString:resultString];
self.result = [parsedResult retain];
self.actions = [self.result.actions retain];