diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index d53d2a5..fea4e1d 100644 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -67,6 +67,7 @@ public class CameraLauncher extends CordovaPlugin { if (args.getInt(5) >= 0 && args.getInt(5) <= 100) { intent.putExtra("quality", args.getInt(5)); } + intent.putExtra("opacity", args.getBoolean(6)); 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 ec29f71..dfd22d1 100644 --- a/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java +++ b/src/android/customCamera/src/org/geneanet/customcamera/CameraActivity.java @@ -55,6 +55,8 @@ public class CameraActivity extends Activity { private boolean modeMiniature = false; // The image in Bitmap format of the preview photo. private Bitmap photoTaken = null; + // Flag to active or disable opacity function. + private Boolean opacity = true; public static final int DEGREE_0 = 0; public static final int DEGREE_90 = 90; @@ -92,36 +94,43 @@ public class CameraActivity extends Activity { WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_camera_view); + + opacity = this.getIntent().getBooleanExtra("opacity", true); + setBackground(); - // The opacity bar - SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity); - - // Event on change opacity. - switchOpacity.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { - int progress = 0; - - @Override - public void onProgressChanged(SeekBar seekBar, int progressValue, - boolean fromUser) { - progress = progressValue; - ImageView background = (ImageView) findViewById(R.id.background); - float newOpacity = (float) (progress * 0.1); - background.setAlpha(newOpacity); - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) {} - - @Override - public void onStopTrackingTouch(SeekBar seekBar) {} - }); - if (!this.getIntent().getBooleanExtra("miniature", true)) { Button miniature = (Button) findViewById(R.id.miniature); miniature.setVisibility(View.INVISIBLE); } + // The opacity bar + SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity); + + if (opacity) { + // Event on change opacity. + switchOpacity.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { + int progress = 0; + + @Override + public void onProgressChanged(SeekBar seekBar, int progressValue, + boolean fromUser) { + progress = progressValue; + ImageView background = (ImageView) findViewById(R.id.background); + float newOpacity = (float) (progress * 0.1); + background.setAlpha(newOpacity); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) {} + + @Override + public void onStopTrackingTouch(SeekBar seekBar) {} + }); + } else { + switchOpacity.setVisibility(View.INVISIBLE); + } + ImageButton imgIcon = (ImageButton)findViewById(R.id.capture); final Activity currentActivity = this; @@ -420,7 +429,12 @@ public class CameraActivity extends Activity { // set image at the view. ImageView background = (ImageView) findViewById(R.id.background); background.setImageBitmap(imgBackgroundBitmap); - background.setAlpha((float)0.5); // Opacity at the beginning + // Opacity at the beginning + if (opacity) { + background.setAlpha((float)0.5); + } else { + background.setAlpha((float)1); + } paramsMiniature.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); diff --git a/www/customCamera.js b/www/customCamera.js index daff79b..d9b331a 100644 --- a/www/customCamera.js +++ b/www/customCamera.js @@ -22,7 +22,8 @@ cameraBackgroundColor: "#e26760", // color of the camera button. 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") + 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. }; for (var nameOption in defaultOptions) { @@ -50,7 +51,8 @@ options.saveInGallery, options.cameraBackgroundColor, options.cameraBackgroundColorPressed, - options.quality + options.quality, + options.opacity ] ); };