mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Implémentation du flash dans le plugin JS.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+8
-2
@@ -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
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user