diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index 4b5623c..47908af 100644 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -84,6 +84,9 @@ public class CameraLauncher extends CordovaPlugin { intent.putExtra("opacity", args.getBoolean(7)); intent.putExtra("startOrientation", this.cordova.getActivity().getResources().getConfiguration().orientation); + intent.putExtra("defaultFlash", args.getInt(8)); + intent.putExtra("switchFlash", args.getBoolean(9)); + cordova.startActivityForResult((CordovaPlugin) this, intent, CameraLauncher.REQUEST_CODE); diff --git a/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java b/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java index 2555b8d..65c3863 100644 --- a/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java +++ b/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java @@ -109,6 +109,11 @@ public class CameraActivity extends Activity { Button miniature = (Button) findViewById(R.id.miniature); miniature.setVisibility(View.INVISIBLE); } + + if (!this.getIntent().getBooleanExtra("switchFlash", true)) { + ImageButton flash = (ImageButton)findViewById(R.id.flash); + flash.setVisibility(View.INVISIBLE); + } // The opacity bar SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity); @@ -193,6 +198,8 @@ public class CameraActivity extends Activity { return; } + stateFlash = this.getIntent().getIntExtra("defaultFlash", CameraActivity.FLASH_DISABLE); + updateStateFlash(stateFlash); int orientation = 0; @@ -733,9 +740,13 @@ public class CameraActivity extends Activity { */ public void declinePhoto(View view) { ImageButton imgIcon = (ImageButton)findViewById(R.id.capture); - ImageButton flash = (ImageButton)findViewById(R.id.flash); imgIcon.setEnabled(true); - flash.setVisibility(View.VISIBLE); + + if (hasFlash()) { + ImageButton flash = (ImageButton)findViewById(R.id.flash); + flash.setVisibility(View.VISIBLE); + } + Camera.Parameters params = customCamera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); customCamera.setParameters(params); diff --git a/www/customCamera.js b/www/customCamera.js index d418b8a..b179b79 100644 --- a/www/customCamera.js +++ b/www/customCamera.js @@ -7,6 +7,8 @@ // constructor. function CustomCameraExport() {} + CustomCameraExport.prototype.FlashModes = {DISABLE: 0, ACTIVE: 1, AUTO: 2}; + /** * Start custom camera. * @@ -24,7 +26,9 @@ cameraBackgroundColorPressed: "#dc453d", // color of the pressed camera button. // To get supported color formats, go to see method parseColor : http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) quality: 100, // picture's quality : range 0 - 100 : http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream) (parameter "quality") - opacity: true // active or disable the opacity function. + opacity: true, // active or disable the opacity function. + defaultFlash: this.FlashModes.DISABLE, // default state for flash. Corrects values = 0 (disable) / 1 (active) / 2 (auto) + switchFlash: true // active or disable the switch flash button. }; for (var nameOption in defaultOptions) { @@ -54,7 +58,9 @@ options.cameraBackgroundColor, options.cameraBackgroundColorPressed, options.quality, - options.opacity + options.opacity, + options.defaultFlash, + options.switchFlash ] ); };