feat: debounce RAW capture taps
This commit is contained in:
1 parent
f7886874b1
commit
4621b88cdb
1 file changed
+20
@@ -97,6 +97,7 @@ enum class ActivePanel {
|
||||
|
||||
private const val InitialPreviewTransitionDelayMillis = 150L
|
||||
private const val PreviewTransitionRevealDurationMillis = 800
|
||||
private const val RawCaptureTapDebounceMillis = 1000L
|
||||
|
||||
@Composable
|
||||
fun CameraScreen(
|
||||
@@ -153,6 +154,7 @@ fun CameraScreen(
|
||||
var previewTransitionAwaitingResume by remember { mutableStateOf(false) }
|
||||
var previewTransitionSawPause by remember { mutableStateOf(false) }
|
||||
var hasPlayedInitialPreviewTransition by remember { mutableStateOf(false) }
|
||||
var rawCaptureTapLocked by remember { mutableStateOf(false) }
|
||||
|
||||
// 标记相机是否已打开
|
||||
var cameraOpened by remember { mutableStateOf(false) }
|
||||
@@ -192,6 +194,12 @@ fun CameraScreen(
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(useRaw, state.captureMode) {
|
||||
if (!useRaw || state.captureMode != CaptureMode.PHOTO) {
|
||||
rawCaptureTapLocked = false
|
||||
}
|
||||
}
|
||||
|
||||
// 从后台返回时检查并恢复相机,刷新最新照片
|
||||
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
|
||||
viewModel.checkAndRecoverCamera()
|
||||
@@ -977,6 +985,18 @@ fun CameraScreen(
|
||||
onSwitchCameraClick = ::switchCameraWithPreviewTransition,
|
||||
onCaptureModeSelected = ::setCaptureModeWithPreviewTransition,
|
||||
onCaptureTap = {
|
||||
val shouldDebounceRawCapture = useRaw && state.captureMode == CaptureMode.PHOTO
|
||||
if (shouldDebounceRawCapture) {
|
||||
if (rawCaptureTapLocked) {
|
||||
return@Controls
|
||||
}
|
||||
rawCaptureTapLocked = true
|
||||
scope.launch {
|
||||
delay(RawCaptureTapDebounceMillis)
|
||||
rawCaptureTapLocked = false
|
||||
}
|
||||
}
|
||||
|
||||
if (enableDevelopAnimation && state.captureMode == CaptureMode.PHOTO) {
|
||||
viewModel.glSurfaceView?.capturePreviewFrame { bitmap ->
|
||||
pendingCaptureAnimationBitmap = bitmap
|
||||
|
||||
Reference in new issue
Block a user