From 21cd5de4eb3a5e78f99550f4b8a3609fe61d4170 Mon Sep 17 00:00:00 2001 From: Simone Borda Date: Wed, 6 Dec 2017 22:03:56 +0100 Subject: [PATCH 1/2] Facing configuration on Android (on take picture). This modification should allow to configure camerafacing on take picture. --- src/camera.android.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/camera.android.ts b/src/camera.android.ts index 343450b..eccaa3c 100644 --- a/src/camera.android.ts +++ b/src/camera.android.ts @@ -29,6 +29,7 @@ export let takePicture = function (options?): Promise { let reqWidth; let reqHeight; let shouldKeepAspectRatio; + let cameraFacing; let density = utils.layout.getDisplayDensity(); if (options) { @@ -36,6 +37,7 @@ export let takePicture = function (options?): Promise { reqWidth = options.width ? options.width * density : 0; reqHeight = options.height ? options.height * density : reqWidth; shouldKeepAspectRatio = types.isNullOrUndefined(options.keepAspectRatio) ? true : options.keepAspectRatio; + cameraFacing = types.isNullOrUndefined(options.cameraFacing) ? options.cameraFacing : 'rear'; } if ((android.support.v4.content.ContextCompat).checkSelfPermission( @@ -74,10 +76,13 @@ export let takePicture = function (options?): Promise { takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri); - if (options && options.cameraFacing === "front") { takePictureIntent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); } + if (cameraFacing === "rear") { + takePictureIntent.putExtra("android.intent.extras.CAMERA_FACING", + android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK); + } if (takePictureIntent.resolveActivity(utils.ad.getApplicationContext().getPackageManager()) != null) { From 1d9d854bde5ab98f6e76da889bde10fc81845fff Mon Sep 17 00:00:00 2001 From: Simone Borda Date: Thu, 7 Dec 2017 09:14:57 +0100 Subject: [PATCH 2/2] Modified default oprions camerafacing --- src/camera.android.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/camera.android.ts b/src/camera.android.ts index eccaa3c..6361220 100644 --- a/src/camera.android.ts +++ b/src/camera.android.ts @@ -37,7 +37,7 @@ export let takePicture = function (options?): Promise { reqWidth = options.width ? options.width * density : 0; reqHeight = options.height ? options.height * density : reqWidth; shouldKeepAspectRatio = types.isNullOrUndefined(options.keepAspectRatio) ? true : options.keepAspectRatio; - cameraFacing = types.isNullOrUndefined(options.cameraFacing) ? options.cameraFacing : 'rear'; + cameraFacing = types.isNullOrUndefined(options.cameraFacing) ? 'rear': options.cameraFacing; } if ((android.support.v4.content.ContextCompat).checkSelfPermission( @@ -76,6 +76,7 @@ export let takePicture = function (options?): Promise { takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPictureUri); + if (cameraFacing === "front") { takePictureIntent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); }