diff --git a/plugin.xml b/plugin.xml index 66adcbc..dccb0a6 100644 --- a/plugin.xml +++ b/plugin.xml @@ -27,6 +27,7 @@ + diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index 7d6d34f..791948b 100644 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -16,7 +16,6 @@ import java.io.InputStreamReader; import java.io.IOException; import android.content.Intent; -import android.os.Bundle; import android.util.Base64; public class CameraLauncher extends CordovaPlugin { @@ -35,9 +34,20 @@ public class CameraLauncher extends CordovaPlugin { Intent intent = new Intent(this.cordova.getActivity(), CameraActivity.class); - Bundle imgBackgroundBase64 = new Bundle(); - imgBackgroundBase64.putString("imgBackgroundBase64", args.getString(0)); - intent.putExtras(imgBackgroundBase64); + byte[] imgBackgroundBase64; + try { + imgBackgroundBase64 = Base64.decode(args.getString(0), Base64.NO_WRAP); + } catch (IllegalArgumentException e) { + this.callbackContext.error( + generateError( + CameraLauncher.RESULT_ERROR, + "Error decode base64 picture." + ) + ); + + return false; + } + TransferBigData.setImgBackgroundBase64(imgBackgroundBase64); cordova.startActivityForResult((CordovaPlugin) this, intent, CameraLauncher.REQUEST_CODE); diff --git a/src/android/customCamera/res/layout/activity_camera_view.xml b/src/android/customCamera/res/layout/activity_camera_view.xml index b60c4ab..542df23 100644 --- a/src/android/customCamera/res/layout/activity_camera_view.xml +++ b/src/android/customCamera/res/layout/activity_camera_view.xml @@ -11,20 +11,14 @@ android:layout_alignParentTop="true" > - - - - + android:layout_alignParentTop="true" + android:alpha="0.2" + android:scaleType="fitXY" /> = ratioY && ratioY < 1) { + paramsMiniature.width = (int) (ratioY * widthBackground); + paramsMiniature.height = (int) displayHeightPx; + } + + // set image at the view. + ImageView imageView = (ImageView) findViewById(R.id.background); + imageView.setImageBitmap(imgBackgroundBitmap); + + paramsMiniature.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + imageView.setLayoutParams(paramsMiniature); + } + } } diff --git a/src/android/customCamera/src/org/geneanet/customcamera/TransferBigData.java b/src/android/customCamera/src/org/geneanet/customcamera/TransferBigData.java new file mode 100644 index 0000000..d742960 --- /dev/null +++ b/src/android/customCamera/src/org/geneanet/customcamera/TransferBigData.java @@ -0,0 +1,24 @@ +package org.geneanet.customcamera; + +/** + * Use to transfer big data between activities. + */ +public class TransferBigData { + protected static byte[] imgBackgroundBase64 = null; + + /** + * Get bytes to represent background picture. + * @return byte[] + */ + public static byte[] getImgBackgroundBase64() { + return TransferBigData.imgBackgroundBase64; + } + + /** + * Set bytes to represent background picture. + * @param byte[] imgBackgroundBase64 + */ + public static void setImgBackgroundBase64(byte[] imgBackgroundBase64) { + TransferBigData.imgBackgroundBase64 = imgBackgroundBase64; + } +} diff --git a/www/customCamera.js b/www/customCamera.js index 830df8e..a916fef 100644 --- a/www/customCamera.js +++ b/www/customCamera.js @@ -19,8 +19,8 @@ customCameraExport.prototype.startCamera = function(imgBackgroundBase64, success successFct(data); }; - var failFctCallback = function(data) { - failFct(data.code, data.message); + var failFctCallback = function(message) { + failFct(message); }; exec(