diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt index 709fca6a..8c7d6272 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt @@ -598,10 +598,8 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie } mCaptureSession!!.stopRepeating() + cancelAutoFocus() mPreviewRequestBuilder!!.apply { - set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL) - mCaptureSession!!.capture(build(), captureCallbackHandler, mBackgroundHandler) - // touch-to-focus inspired by OpenCamera val characteristics = getCameraCharacteristics() if (characteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF) >= 1) { @@ -620,6 +618,12 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie } } + private fun cancelAutoFocus() { + val cancelRequest = mPreviewRequestBuilder + cancelRequest!!.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_IDLE) + mCaptureSession!!.capture(cancelRequest.build(), null, mBackgroundHandler) + } + private fun convertAreaToMeteringRectangle(sensorRect: Rect, focusArea: FocusArea): MeteringRectangle { val camera2Rect = convertRectToCamera2(sensorRect, focusArea.rect) return MeteringRectangle(camera2Rect, focusArea.weight)