From 410822bd38afc01501651dbc14760938e80aeb1c Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 30 May 2018 14:56:53 +0200 Subject: [PATCH] always set camera state to STATE_PICTURE_TAKEN at capturing --- .../simplemobiletools/camera/views/PreviewCameraTwo.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 6eb45333..c9a3b12f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt @@ -279,13 +279,12 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie private fun process(result: CaptureResult) { when (mCameraState) { STATE_WAITING_LOCK -> { - val afState = result.get(CaptureResult.CONTROL_AF_STATE) - if (afState == null) { + val autoFocusState = result.get(CaptureResult.CONTROL_AF_STATE) + if (autoFocusState == null) { captureStillPicture() - } else if (afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) { + } else if (autoFocusState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || autoFocusState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) { val aeState = result.get(CaptureResult.CONTROL_AE_STATE) if (aeState == null || aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) { - mCameraState = STATE_PICTURE_TAKEN captureStillPicture() } else { runPrecaptureSequence() @@ -301,7 +300,6 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie STATE_WAITING_NON_PRECAPTURE -> { val aeState = result.get(CaptureResult.CONTROL_AE_STATE) if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) { - mCameraState = STATE_PICTURE_TAKEN captureStillPicture() } } @@ -332,6 +330,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie return } + mCameraState = STATE_PICTURE_TAKEN mRotationAtCapture = mActivity.mLastHandledOrientation val captureBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply { addTarget(mImageReader!!.surface)