From 80c5277936134c3c222f4fdae7ea2560b12d2475 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Thu, 23 Dec 2021 19:10:13 +0100 Subject: [PATCH] Reset flash state when switching to back camera in video mode --- app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt index 7f361c2..a911f52 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt @@ -24,7 +24,6 @@ import android.widget.Toast import androidx.annotation.RequiresApi import androidx.camera.camera2.interop.Camera2CameraInfo import androidx.camera.core.* -//import androidx.camera.core.VideoCapture import androidx.camera.extensions.ExtensionMode import androidx.camera.extensions.ExtensionsManager import androidx.camera.lifecycle.ProcessCameraProvider @@ -242,6 +241,11 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener { false } else { binding.imageCameraSwitch.setImageResource(R.drawable.icon_camera_front) + if (isInVideoMode) { + //reset flash state + imageCapture?.flashMode = ImageCapture.FLASH_MODE_OFF + binding.imageFlash.setImageResource(R.drawable.icon_flash_off) + } true } setupCamera()