Aperture: Use `onCaptureStarted()` for shutter sound and UI update
Change-Id: I57a42866e54727d96795eb0bd298822aa43cd765
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 32e701c..253cf21 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -1373,13 +1373,7 @@
outputOptions,
ContextCompat.getMainExecutor(this),
object : ImageCapture.OnImageSavedCallback {
- override fun onError(exc: ImageCaptureException) {
- Log.e(LOG_TAG, "Photo capture failed: ${exc.message}", exc)
- cameraState = CameraState.IDLE
- shutterButton.isEnabled = true
- }
-
- override fun onImageSaved(output: ImageCapture.OutputFileResults) {
+ override fun onCaptureStarted() {
cameraSoundsUtils.playShutterClick()
viewFinder.foreground = ColorDrawable(Color.BLACK)
ValueAnimator.ofInt(0, 255, 0).apply {
@@ -1387,6 +1381,15 @@
viewFinder.foreground.alpha = anim.animatedValue as Int
}
}.start()
+ }
+
+ override fun onError(exc: ImageCaptureException) {
+ Log.e(LOG_TAG, "Photo capture failed: ${exc.message}", exc)
+ cameraState = CameraState.IDLE
+ shutterButton.isEnabled = true
+ }
+
+ override fun onImageSaved(output: ImageCapture.OutputFileResults) {
Log.d(LOG_TAG, "Photo capture succeeded: ${output.savedUri}")
cameraState = CameraState.IDLE
shutterButton.isEnabled = true