mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Mise en place d'une option pour désactiver la fonction d'opacité.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user