mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
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:
parent
f3f5720a8e
commit
6f851acf9c
|
@ -7,14 +7,20 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "ZXMainViewController.h"
|
||||||
|
|
||||||
@interface BarcodesAppDelegate : NSObject <UIApplicationDelegate> {
|
@interface BarcodesAppDelegate : NSObject <UIApplicationDelegate> {
|
||||||
UIWindow *window;
|
UIWindow *window;
|
||||||
UITabBarController *tabBarController;
|
UITabBarController *tabBarController;
|
||||||
|
ZXMainViewController *viewController;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
||||||
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
|
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
|
||||||
|
@property (nonatomic, retain) IBOutlet ZXMainViewController *viewController;
|
||||||
|
|
||||||
|
- (void)registerView:(ZXMainViewController*)controller;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,58 @@
|
||||||
|
|
||||||
@synthesize window;
|
@synthesize window;
|
||||||
@synthesize tabBarController;
|
@synthesize tabBarController;
|
||||||
|
@synthesize viewController;
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Application lifecycle
|
#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:@"&"];
|
||||||
|
|
||||||
|
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 {
|
- (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.
|
// Override point for customization after application launch.
|
||||||
[self.window addSubview:tabBarController.view];
|
[self.window addSubview:tabBarController.view];
|
||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
|
@ -25,6 +71,10 @@
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
return [self myOpenURL: url];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
- (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.
|
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.
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#import "ArchiveController.h"
|
#import "ArchiveController.h"
|
||||||
#import "Database.h"
|
#import "Database.h"
|
||||||
#import "ScanViewController.h"
|
#import "ScanViewController.h"
|
||||||
|
#import "BarcodesAppDelegate.h"
|
||||||
|
|
||||||
@implementation ZXMainViewController
|
@implementation ZXMainViewController
|
||||||
@synthesize actions;
|
@synthesize actions;
|
||||||
|
@ -36,6 +37,8 @@
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
self.navigationItem.title = @"Barcodes";
|
self.navigationItem.title = @"Barcodes";
|
||||||
|
|
||||||
|
[((BarcodesAppDelegate*)[[UIApplication sharedApplication] delegate]) registerView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,6 +114,12 @@
|
||||||
#endif
|
#endif
|
||||||
Scan * scan = [[Database sharedDatabase] addScanWithText:resultString];
|
Scan * scan = [[Database sharedDatabase] addScanWithText:resultString];
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
|
[[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];
|
ParsedResult *parsedResult = [UniversalResultParser parsedResultForString:resultString];
|
||||||
self.result = [parsedResult retain];
|
self.result = [parsedResult retain];
|
||||||
|
|
Loading…
Reference in a new issue