You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/21 04:30:07 UTC

ios commit: [CB-2732] Only set camera device when allowed.

Updated Branches:
  refs/heads/master cd4eae05b -> 8d285676f


[CB-2732] Only set camera device when allowed.

The camera device can only be set when the source type is
UIImagePickerControllerSourceTypeCamera (ie. we're actually using the
camera).


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8d285676
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8d285676
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8d285676

Branch: refs/heads/master
Commit: 8d285676fcab25da70918d27d3b37210909d3e46
Parents: cd4eae0
Author: Max Woghiren <ma...@gmail.com>
Authored: Wed Mar 20 16:22:59 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Mar 20 23:29:56 2013 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCamera.m |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8d285676/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index 0205e92..1f05333 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -84,12 +84,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
         return;
     }
 
-    NSNumber* cameraDirection = [arguments objectAtIndex:11];
-    UIImagePickerControllerCameraDevice cameraDevice = UIImagePickerControllerCameraDeviceRear; // default
-    if (cameraDirection != nil) {
-        cameraDevice = (UIImagePickerControllerSourceType)[cameraDirection intValue];
-    }
-
     bool allowEdit = [[arguments objectAtIndex:7] boolValue];
     NSNumber* targetWidth = [arguments objectAtIndex:3];
     NSNumber* targetHeight = [arguments objectAtIndex:4];
@@ -113,7 +107,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
 
     cameraPicker.delegate = self;
     cameraPicker.sourceType = sourceType;
-    cameraPicker.cameraDevice = cameraDevice;
     cameraPicker.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING - jm
     cameraPicker.callbackId = callbackId;
     cameraPicker.targetSize = targetSize;
@@ -131,8 +124,16 @@ static NSSet* org_apache_cordova_validArrowDirections;
     cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
 
     if (sourceType == UIImagePickerControllerSourceTypeCamera) {
-        // we only allow taking pictures (no video) in this api
+        // We only allow taking pictures (no video) in this API.
         cameraPicker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
+
+        // We can only set the camera device if we're actually using the camera.
+        NSNumber* cameraDirection = [arguments objectAtIndex:11];
+        UIImagePickerControllerCameraDevice cameraDevice = UIImagePickerControllerCameraDeviceRear; // default
+        if (cameraDirection != nil) {
+            cameraDevice = (UIImagePickerControllerSourceType)[cameraDirection intValue];
+        }
+        cameraPicker.cameraDevice = cameraDevice;
     } else if (mediaType == MediaTypeAll) {
         cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
     } else {