From 8bb88549b69e5c5d5da3dc40a89b07edafe2b294 Mon Sep 17 00:00:00 2001 From: Kyle Corry Date: Fri, 1 Sep 2023 07:03:23 -0400 Subject: [PATCH] Add zero shutter lag support to cameraview #1811 --- .../shared/camera/PhotoImportBottomSheetFragment.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kylecorry/trail_sense/shared/camera/PhotoImportBottomSheetFragment.kt b/app/src/main/java/com/kylecorry/trail_sense/shared/camera/PhotoImportBottomSheetFragment.kt index a13869b47..87c3fd421 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/shared/camera/PhotoImportBottomSheetFragment.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/shared/camera/PhotoImportBottomSheetFragment.kt @@ -1,5 +1,6 @@ package com.kylecorry.trail_sense.shared.camera +import android.annotation.SuppressLint import android.content.DialogInterface import android.net.Uri import android.os.Bundle @@ -8,6 +9,7 @@ import android.view.KeyEvent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.camera.core.ExperimentalZeroShutterLag import androidx.camera.core.ImageCapture import androidx.camera.view.PreviewView import androidx.core.net.toUri @@ -23,11 +25,13 @@ import com.kylecorry.trail_sense.shared.io.FileSubsystem class PhotoImportBottomSheetFragment( private val resolution: Size? = null, + private val useZeroShutterLag: Boolean = false, private val onCapture: (uri: Uri?) -> Unit ) : BoundFullscreenDialogFragment() { private var isCapturing = false + @SuppressLint("UnsafeOptInUsageError") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -49,7 +53,9 @@ class PhotoImportBottomSheetFragment( lifecycleOwner = this, readFrames = false, captureSettings = ImageCaptureSettings( - captureMode = if (resolution == null) { + captureMode = if (useZeroShutterLag) { + ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG + } else if (resolution == null) { ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY } else { ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY