Changement de la couleur de fond du bouton camera via le JS.
@ -52,6 +52,8 @@ public class CameraLauncher extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intent.putExtra("miniature", args.getBoolean(1));
|
intent.putExtra("miniature", args.getBoolean(1));
|
||||||
|
intent.putExtra("cameraBackgroundColor", args.getString(2));
|
||||||
|
intent.putExtra("cameraBackgroundColorPressed", args.getString(3));
|
||||||
|
|
||||||
cordova.startActivityForResult((CordovaPlugin) this, intent, CameraLauncher.REQUEST_CODE);
|
cordova.startActivityForResult((CordovaPlugin) this, intent, CameraLauncher.REQUEST_CODE);
|
||||||
|
|
||||||
|
BIN
src/android/customCamera/res/drawable-hdpi/accept.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/android/customCamera/res/drawable-hdpi/capture.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/android/customCamera/res/drawable-hdpi/capture2.png
Normal file
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 343 KiB |
BIN
src/android/customCamera/res/drawable-hdpi/delete.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 802 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 585 KiB |
Before Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 343 KiB |
Before Width: | Height: | Size: 802 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 585 KiB |
Before Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 343 KiB |
Before Width: | Height: | Size: 802 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 585 KiB |
Before Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 343 KiB |
Before Width: | Height: | Size: 802 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 585 KiB |
Before Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dip" />
|
||||||
|
<gradient
|
||||||
|
android:startColor="#ffffffff"
|
||||||
|
android:centerColor="#ffdddddd"
|
||||||
|
android:centerY="0.50"
|
||||||
|
android:endColor="#ffffffff"
|
||||||
|
android:angle="270" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:id="@android:id/secondaryProgress">
|
||||||
|
<clip>
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dip" />
|
||||||
|
<gradient
|
||||||
|
android:startColor="#FBFCFA"
|
||||||
|
android:endColor="#FBFCFA"
|
||||||
|
android:angle="90" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<clip>
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dip" />
|
||||||
|
<gradient
|
||||||
|
android:startColor="#777777"
|
||||||
|
android:endColor="#777777"
|
||||||
|
android:angle="90" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="35dp" android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
15
src/android/customCamera/res/drawable-xxxhdpi/thumb.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval" >
|
||||||
|
|
||||||
|
<gradient
|
||||||
|
android:angle="270"
|
||||||
|
android:endColor="#e26760"
|
||||||
|
android:startColor="#e26760"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<size
|
||||||
|
android:height="40dp"
|
||||||
|
android:width="40dp" />
|
||||||
|
|
||||||
|
</shape>
|
@ -39,13 +39,12 @@
|
|||||||
android:onClick="buttonMiniature"
|
android:onClick="buttonMiniature"
|
||||||
android:text="@string/miniature" />
|
android:text="@string/miniature" />
|
||||||
|
|
||||||
<Button
|
<ImageButton
|
||||||
android:id="@+id/capture"
|
android:id="@+id/capture"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:background="@drawable/round_button"
|
||||||
android:onClick="takePhoto"
|
android:src="@drawable/capture2" />
|
||||||
android:text="@string/capture" />
|
|
||||||
|
|
||||||
<org.geneanet.customcamera.VerticalSeekBar
|
<org.geneanet.customcamera.VerticalSeekBar
|
||||||
android:id="@+id/switchOpacity"
|
android:id="@+id/switchOpacity"
|
||||||
@ -78,21 +77,24 @@
|
|||||||
android:background="@color/black"
|
android:background="@color/black"
|
||||||
android:visibility="invisible" >
|
android:visibility="invisible" >
|
||||||
|
|
||||||
<Button
|
<ImageButton
|
||||||
android:id="@+id/accept"
|
android:id="@+id/accept"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:onClick="acceptPhoto"
|
android:onClick="acceptPhoto"
|
||||||
android:text="@string/acceptePicture" />
|
android:src="@drawable/accept"
|
||||||
|
android:background="@android:color/transparent" />
|
||||||
|
|
||||||
<Button
|
<ImageButton
|
||||||
android:id="@+id/decline"
|
android:id="@+id/decline"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:onClick="declinePhoto"
|
android:onClick="declinePhoto"
|
||||||
android:text="@string/declinePicture" />
|
android:src="@drawable/delete"
|
||||||
|
android:background="@android:color/transparent" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">TestCustomCamera</string>
|
<string name="app_name">TestCustomCamera</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
|
@ -7,7 +7,9 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.hardware.Camera.CameraInfo;
|
import android.hardware.Camera.CameraInfo;
|
||||||
import android.hardware.Camera.PictureCallback;
|
import android.hardware.Camera.PictureCallback;
|
||||||
@ -26,6 +28,7 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
@ -118,6 +121,51 @@ public class CameraActivity extends Activity {
|
|||||||
Button miniature = (Button) findViewById(R.id.miniature);
|
Button miniature = (Button) findViewById(R.id.miniature);
|
||||||
miniature.setVisibility(View.INVISIBLE);
|
miniature.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageButton imgIcon = (ImageButton)findViewById(R.id.capture);
|
||||||
|
final Activity currentActivity = this;
|
||||||
|
|
||||||
|
this.setCameraBackgroundColor(this.getIntent().getStringExtra("cameraBackgroundColor"));
|
||||||
|
|
||||||
|
imgIcon.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View view, MotionEvent event) {
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
((CameraActivity) currentActivity).setCameraBackgroundColor(
|
||||||
|
currentActivity.getIntent().getStringExtra("cameraBackgroundColorPressed"));
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
view.performClick();
|
||||||
|
((CameraActivity) currentActivity).setCameraBackgroundColor(
|
||||||
|
currentActivity.getIntent().getStringExtra("cameraBackgroundColor"));
|
||||||
|
((CameraActivity) currentActivity).takePhoto();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the background color of the camera button.
|
||||||
|
* @param color The color of the background.
|
||||||
|
*/
|
||||||
|
protected void setCameraBackgroundColor(String color) {
|
||||||
|
ImageButton imgIcon = (ImageButton)findViewById(R.id.capture);
|
||||||
|
GradientDrawable backgroundGradient = (GradientDrawable)imgIcon.getBackground();
|
||||||
|
if (color.length() > 0) {
|
||||||
|
try {
|
||||||
|
int cameraBackgroundColor = Color.parseColor(color);
|
||||||
|
backgroundGradient.setColor(cameraBackgroundColor);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
backgroundGradient.setColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
backgroundGradient.setColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Method onStart. Handle the zoom level seekBar and the camera orientation. */
|
/** Method onStart. Handle the zoom level seekBar and the camera orientation. */
|
||||||
@ -415,7 +463,7 @@ public class CameraActivity extends Activity {
|
|||||||
*/
|
*/
|
||||||
public void displayAcceptDeclineButtons() {
|
public void displayAcceptDeclineButtons() {
|
||||||
LinearLayout keepPhoto = (LinearLayout) findViewById(R.id.keepPhoto);
|
LinearLayout keepPhoto = (LinearLayout) findViewById(R.id.keepPhoto);
|
||||||
Button photo = (Button) findViewById(R.id.capture);
|
ImageButton photo = (ImageButton) findViewById(R.id.capture);
|
||||||
SeekBar zoomLevel = (SeekBar) findViewById(R.id.zoomLevel);
|
SeekBar zoomLevel = (SeekBar) findViewById(R.id.zoomLevel);
|
||||||
Button miniature = (Button) findViewById(R.id.miniature);
|
Button miniature = (Button) findViewById(R.id.miniature);
|
||||||
ImageView background = (ImageView) findViewById(R.id.background);
|
ImageView background = (ImageView) findViewById(R.id.background);
|
||||||
@ -477,9 +525,8 @@ public class CameraActivity extends Activity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to take picture.
|
* Method to take picture.
|
||||||
* @param view Current view.
|
|
||||||
*/
|
*/
|
||||||
public void takePhoto(View view) {
|
public void takePhoto() {
|
||||||
// Handles the moment where picture is taken
|
// Handles the moment where picture is taken
|
||||||
ShutterCallback shutterCallback = new ShutterCallback() {
|
ShutterCallback shutterCallback = new ShutterCallback() {
|
||||||
public void onShutter() {
|
public void onShutter() {
|
||||||
@ -504,7 +551,7 @@ public class CameraActivity extends Activity {
|
|||||||
BitmapFactory.Options opt;
|
BitmapFactory.Options opt;
|
||||||
opt = new BitmapFactory.Options();
|
opt = new BitmapFactory.Options();
|
||||||
|
|
||||||
// Temp storage to use for decoding
|
// Temporarily storage to use for decoding
|
||||||
opt.inTempStorage = new byte[16 * 1024];
|
opt.inTempStorage = new byte[16 * 1024];
|
||||||
Camera.Parameters paramsCamera = customCamera.getParameters();
|
Camera.Parameters paramsCamera = customCamera.getParameters();
|
||||||
Size size = paramsCamera.getPictureSize();
|
Size size = paramsCamera.getPictureSize();
|
||||||
|
@ -17,7 +17,10 @@ var customCameraExport = function() {
|
|||||||
customCameraExport.prototype.startCamera = function(options, successFct, failFct) {
|
customCameraExport.prototype.startCamera = function(options, successFct, failFct) {
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
imgBackgroundBase64: null, // background picture in base64.
|
imgBackgroundBase64: null, // background picture in base64.
|
||||||
miniature: true // active or disable the miniature function.
|
miniature: true, // active or disable the miniature function.
|
||||||
|
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)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var nameOption in defaultOptions) {
|
for (var nameOption in defaultOptions) {
|
||||||
@ -41,7 +44,9 @@ customCameraExport.prototype.startCamera = function(options, successFct, failFct
|
|||||||
"startCamera",
|
"startCamera",
|
||||||
[
|
[
|
||||||
options.imgBackgroundBase64,
|
options.imgBackgroundBase64,
|
||||||
options.miniature
|
options.miniature,
|
||||||
|
options.cameraBackgroundColor,
|
||||||
|
options.cameraBackgroundColorPressed
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|