Index: Classes/ZXingAppDelegate.m |
=================================================================== |
--- Classes/ZXingAppDelegate.m (revision 404) |
+++ Classes/ZXingAppDelegate.m (working copy) |
@@ -1,3 +1,9 @@ |
+// |
+// ZXingAppDelegate.m |
+// ZXing |
+// |
+// Created by Christian Brunschen on 23/04/2008. |
+// |
/* |
* Copyright 2008 Google Inc. |
* |
@@ -14,40 +20,56 @@ |
* limitations under the License. |
*/ |
-// |
-// ZXingAppDelegate.m |
-// ZXing |
-// |
-// Created by Christian Brunschen on 23/04/2008. |
-// |
#import "ZXingAppDelegate.h" |
#import "DecoderViewController.h" |
+#import "RotatingNavigationController.h" |
@implementation ZXingAppDelegate |
@synthesize window; |
@synthesize viewController; |
+@synthesize navigationController; |
- (void)applicationDidFinishLaunching:(UIApplication *)application { |
- /* create the view controller */ |
- DecoderViewController *vc = [[DecoderViewController alloc] init]; |
- self.viewController = vc; |
- [vc release]; |
- |
- // hook up the view controller's view to be in the window |
- [window addSubview:viewController.view]; |
- |
- // show the window |
- [window makeKeyAndVisible]; |
- |
- // pick and decode |
- [viewController pickAndDecode]; |
+ /* create the view controller */ |
+ DecoderViewController *vc = |
+ [[DecoderViewController alloc] initWithNibName:@"DecoderView" |
+ bundle:[NSBundle mainBundle]]; |
+ self.viewController = vc; |
+ [vc release]; |
+ |
+ navigationController = [[RotatingNavigationController alloc] |
+ initWithRootViewController:viewController]; |
+ |
+ // hook up the view controller's view to be in the window |
+ [window addSubview:navigationController.view]; |
+ |
+ // show the window |
+ [window makeKeyAndVisible]; |
+ |
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"autoChoosePicture"]) { |
+ // pick and decode using the first available source type in priority order |
+#define N_SOURCE_TYPES 3 |
+ UIImagePickerControllerSourceType sourceTypes[N_SOURCE_TYPES] = { |
+ UIImagePickerControllerSourceTypeCamera, |
+ UIImagePickerControllerSourceTypeSavedPhotosAlbum, |
+ UIImagePickerControllerSourceTypePhotoLibrary |
+ }; |
+ |
+ for (int i = 0; i < N_SOURCE_TYPES; i++) { |
+ if ([UIImagePickerController isSourceTypeAvailable:sourceTypes[i]]) { |
+ [viewController pickAndDecodeFromSource:sourceTypes[i]]; |
+ break; |
+ } |
+ } |
+#undef N_SOURCE_TYPES |
+ } |
} |
- (void)dealloc { |
- [window release]; |
- [super dealloc]; |
+ [window release]; |
+ [super dealloc]; |
} |
@end |