in src/android/CameraLauncher.java [147:221]
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
this.applicationId = cordova.getContext().getPackageName();
this.applicationId = preferences.getString("applicationId", this.applicationId);
if (action.equals(TAKE_PICTURE_ACTION)) {
this.srcType = CAMERA;
this.destType = FILE_URI;
this.saveToPhotoAlbum = false;
this.targetHeight = 0;
this.targetWidth = 0;
this.encodingType = JPEG;
this.mediaType = PICTURE;
this.mQuality = 50;
//Take the values from the arguments if they're not already defined (this is tricky)
this.destType = args.getInt(1);
this.srcType = args.getInt(2);
this.mQuality = args.getInt(0);
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
this.encodingType = args.getInt(5);
this.mediaType = args.getInt(6);
this.allowEdit = args.getBoolean(7);
this.correctOrientation = args.getBoolean(8);
this.saveToPhotoAlbum = args.getBoolean(9);
// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
if (this.targetWidth < 1) {
this.targetWidth = -1;
}
if (this.targetHeight < 1) {
this.targetHeight = -1;
}
// We don't return full-quality PNG files. The camera outputs a JPEG
// so requesting it as a PNG provides no actual benefit
if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 &&
!this.correctOrientation && this.encodingType == PNG && this.srcType == CAMERA) {
this.encodingType = JPEG;
}
try {
if (this.srcType == CAMERA) {
this.callTakePicture(destType, encodingType);
}
else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
this.getImage(this.srcType, destType);
}
}
catch (IllegalStateException e)
{
callbackContext.error(e.getLocalizedMessage());
PluginResult r = new PluginResult(PluginResult.Status.ERROR);
callbackContext.sendPluginResult(r);
return true;
}
catch (IllegalArgumentException e)
{
callbackContext.error("Illegal Argument Exception");
PluginResult r = new PluginResult(PluginResult.Status.ERROR);
callbackContext.sendPluginResult(r);
return true;
}
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}