9
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-05-02 00:07:24 +08:00

Merge pull request #58 from geneanet/issue#56

Ajout de l'option d'opacité
This commit is contained in:
Thomas BOY
2015-01-26 10:59:06 +01:00
4 changed files with 47 additions and 26 deletions
+4
View File
@@ -60,6 +60,10 @@ L'objet `options` contient les options de configuration de l'appareil photo.
+ La valeur doit être comprise entre 0 et 100. Si la valeur n'est pas dans cet interval, la valeur par défaut est utilisée.
+ Pour plus d'information, consulter la méthode [`compress()`](http://developer.android.com/reference/android/graphics/Bitmap.html).
+ **opacity :** Permet d'activer ou non la fonction d'opacité de l'image en surimpression. `true` : Active l'option. `false` : Désactive l'option.
- **Type :** `boolean`
- **Valeur par défaut :** `true`
#### *{Function}* onSuccess
La fonction `onSuccess` est appelée lorsque la prise de vue a réussie.
+1
View File
@@ -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);
+4 -2
View File
@@ -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
]
);
};