From 3b7f0205668ca2233637c98b4e7456389fbdcc40 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Wed, 25 Oct 2023 12:41:40 +0200 Subject: [PATCH] feat: Basic Flash for Android (#2081) Implements a semi-working version of flash photo capture for Android. This isn't properly implemented because a proper implementation requires a fully custom precapture sequence that enables the torch, then waits for AE/AF to adjust, lock AE/AF, then capture with a single torch burst, and then turn the torch off again. This is quite complex, that's why the feature request #1890 is marked at $3,000. For now, this is a simple flash burst which _sometimes works_, _sometimes not_ - highly depends on the device. If anyone wants true working flash capture, sponsor in #1890. --- .../extensions/CameraDevice+createPhotoCaptureRequest.kt | 4 +++- package/example/ios/Podfile.lock | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createPhotoCaptureRequest.kt b/package/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createPhotoCaptureRequest.kt index 3d76ad5..486707f 100644 --- a/package/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createPhotoCaptureRequest.kt +++ b/package/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createPhotoCaptureRequest.kt @@ -55,9 +55,11 @@ fun CameraDevice.createPhotoCaptureRequest( // Set the Flash Mode Flash.OFF -> { captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON) + captureRequest.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF) } Flash.ON -> { - captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH) + captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON) + captureRequest.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH) } Flash.AUTO -> { if (enableRedEyeReduction) { diff --git a/package/example/ios/Podfile.lock b/package/example/ios/Podfile.lock index b9be9b6..23c0689 100644 --- a/package/example/ios/Podfile.lock +++ b/package/example/ios/Podfile.lock @@ -507,7 +507,7 @@ PODS: - libwebp (~> 1.0) - SDWebImage/Core (~> 5.10) - SocketRocket (0.6.1) - - VisionCamera (3.5.1): + - VisionCamera (3.6.3): - React - React-callinvoker - React-Core @@ -747,7 +747,7 @@ SPEC CHECKSUMS: SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - VisionCamera: 2f5f9841150719f73b9efb9e0c8fa48fe8556f2d + VisionCamera: aebb5adef1296732983129c5fe054337b15c3c0b Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce PODFILE CHECKSUM: 27f53791141a3303d814e09b55770336416ff4eb