Skip to content

Commit

Permalink
Add zero shutter lag support to cameraview
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Sep 1, 2023
1 parent a9e3968 commit 8bb8854
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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<FragmentPhotoImportSheetBinding>() {

private var isCapturing = false

@SuppressLint("UnsafeOptInUsageError")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand All @@ -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
Expand Down

0 comments on commit 8bb8854

Please sign in to comment.