Aperture: Use `when` in cycleFlashMode()
Change-Id: Id60ce26c2b85a0721d26587ae33f839b178ec81f
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 0257b37..eec0cad 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -768,8 +768,12 @@
@androidx.camera.camera2.interop.ExperimentalCamera2Interop
private fun cycleFlashMode() {
setFlashMode(
- if (cameraController.imageCaptureFlashMode >= ImageCapture.FLASH_MODE_OFF) ImageCapture.FLASH_MODE_AUTO
- else cameraController.imageCaptureFlashMode + 1
+ when (cameraController.imageCaptureFlashMode) {
+ ImageCapture.FLASH_MODE_AUTO -> ImageCapture.FLASH_MODE_ON
+ ImageCapture.FLASH_MODE_ON -> ImageCapture.FLASH_MODE_OFF
+ ImageCapture.FLASH_MODE_OFF -> ImageCapture.FLASH_MODE_AUTO
+ else -> ImageCapture.FLASH_MODE_AUTO
+ }
)
}