8
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-05-21 00:00:01 +08:00

Ajout des options JS pour :

+ Activer / desactiver le switch de camera.
 + Choisir une camera par défaut.
This commit is contained in:
Christophe BOUCAUT
2015-02-09 10:28:16 +01:00
parent 04286312f7
commit 91349dc4ed
3 changed files with 25 additions and 4 deletions
+3
View File
@@ -87,6 +87,9 @@ public class CameraLauncher extends CordovaPlugin {
intent.putExtra("defaultFlash", args.getInt(8));
intent.putExtra("switchFlash", args.getBoolean(9));
intent.putExtra("defaultCamera", args.getInt(10));
intent.putExtra("switchCamera", args.getBoolean(11));
cordova.startActivityForResult((CordovaPlugin) this, intent,
CameraLauncher.REQUEST_CODE);
@@ -68,6 +68,9 @@ public class CameraActivity extends Activity {
public static final int FLASH_DISABLE = 0;
public static final int FLASH_ENABLE = 1;
public static final int FLASH_AUTO = 2;
public static final int CAMERA_BACK = 0;
public static final int CAMERA_FRONT = 1;
/**
* To get camera resource or stop this activity.
@@ -75,7 +78,12 @@ public class CameraActivity extends Activity {
* @return boolean
*/
protected boolean initCameraResource() {
int defaultCamera = ManagerCamera.determinePositionBackCamera();
int defaultCamera;
if (this.getIntent().getIntExtra("defaultCamera", CameraActivity.CAMERA_BACK) == CameraActivity.CAMERA_FRONT) {
defaultCamera = ManagerCamera.determinePositionFrontCamera();
} else {
defaultCamera = ManagerCamera.determinePositionBackCamera();
}
customCamera = ManagerCamera.getCameraInstance(defaultCamera);
if (customCamera == null) {
@@ -115,6 +123,11 @@ public class CameraActivity extends Activity {
ImageButton flash = (ImageButton)findViewById(R.id.flash);
flash.setVisibility(View.INVISIBLE);
}
if (!this.getIntent().getBooleanExtra("switchCamera", true)) {
ImageButton switchCamera = (ImageButton)findViewById(R.id.switchCamera);
switchCamera.setVisibility(View.INVISIBLE);
}
// The opacity bar
SeekBar switchOpacity = (SeekBar) findViewById(R.id.switchOpacity);
+8 -3
View File
@@ -8,6 +8,7 @@
function CustomCameraExport() {}
CustomCameraExport.prototype.FlashModes = {DISABLE: 0, ACTIVE: 1, AUTO: 2};
CustomCameraExport.prototype.CameraFacings = {BACK: 0, FRONT: 1};
/**
* Start custom camera.
@@ -27,8 +28,10 @@
// 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.
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.
defaultFlash: this.FlashModes.DISABLE, // default state for flash. See CustomCamera.FlashModes for corrects values.
switchFlash: true, // active or disable the switch flash button.
defaultCamera: this.CameraFacings.BACK, // default camera used. See CustomCamera.CameraFacings for corrects values.
switchCamera: true // active or disable the switch camera button.
};
for (var nameOption in defaultOptions) {
@@ -60,7 +63,9 @@
options.quality,
options.opacity,
options.defaultFlash,
options.switchFlash
options.switchFlash,
options.defaultCamera,
options.switchCamera
]
);
};