Skip to content

Commit

Permalink
Added sourceType option support (for photo library) in navigator.came…
Browse files Browse the repository at this point in the history
…ra.getPicture (0 is PhotoLibrary, 1 is Camera[default]
  • Loading branch information
shazron committed Nov 26, 2009
1 parent d880d07 commit f2a76cb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions iphone/PhoneGapLib/Classes/Camera.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,28 @@ - (void) getPicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)op
return;
}

bool hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
NSString* sourceTypeString = [options valueForKey:@"sourceType"];
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
if (sourceTypeString != nil) {
sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
}

bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
if (!hasCamera) {
NSLog(@"Camera.getPicture: Camera not available.");
NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
return;
}

if (pickerController == nil) {
pickerController = [[CameraPicker alloc] init];
pickerController.delegate = self;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.successCallback = successCallback;
pickerController.errorCallback = errorCallback;
pickerController.quality = [options integerValueForKey:@"quality" defaultValue:100 withRange:NSMakeRange(0, 100)];
}

pickerController.delegate = self;
pickerController.sourceType = sourceType;
pickerController.successCallback = successCallback;
pickerController.errorCallback = errorCallback;
pickerController.quality = [options integerValueForKey:@"quality" defaultValue:100 withRange:NSMakeRange(0, 100)];

[[super appViewController] presentModalViewController:pickerController animated:YES];
}

Expand Down

0 comments on commit f2a76cb

Please sign in to comment.