diff --git a/CHANGELOG.md b/CHANGELOG.md index 711daa8ff..67db92b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes +## Unreleased + +* Fixed a bug where Document Capture would occasionally fail + ## 10.1.0 * Added an Offline Mode, enabled by calling `SmileID.setAllowOfflineMode(true)`. If a job is attempted while the device is offline, and offline mode has been enabled, the UI will complete successfully and the job can be submitted at a later time by calling `SmileID.submitJob(jobId)` diff --git a/lib/src/main/java/com/smileidentity/viewmodel/document/DocumentCaptureViewModel.kt b/lib/src/main/java/com/smileidentity/viewmodel/document/DocumentCaptureViewModel.kt index 108855a33..11d762411 100644 --- a/lib/src/main/java/com/smileidentity/viewmodel/document/DocumentCaptureViewModel.kt +++ b/lib/src/main/java/com/smileidentity/viewmodel/document/DocumentCaptureViewModel.kt @@ -122,7 +122,7 @@ class DocumentCaptureViewModel( * taps the manual capture button. */ fun captureDocument(cameraState: CameraState) { - if (isCapturing) { + if (isCapturing || uiState.value.documentImageToConfirm != null) { Timber.v("Already capturing. Skipping duplicate capture request") return } @@ -132,7 +132,6 @@ class DocumentCaptureViewModel( } val documentFile = createDocumentFile(jobId, (side == DocumentCaptureSide.Front)) cameraState.takePicture(documentFile) { result -> - isCapturing = false when (result) { is ImageCaptureResult.Success -> { _uiState.update { @@ -153,6 +152,8 @@ class DocumentCaptureViewModel( } } } + // NB: This should be set to false last after processing is done for the captured image + isCapturing = false } } @@ -243,7 +244,9 @@ class DocumentCaptureViewModel( ) } - if (captureNextAnalysisFrame && areEdgesDetected && !isCapturing && !isFocusing) { + if (captureNextAnalysisFrame && areEdgesDetected && !isCapturing && !isFocusing && + uiState.value.documentImageToConfirm == null + ) { captureNextAnalysisFrame = false captureDocument(cameraState) }