Aperture: Simplify flash mode handling

Change-Id: I5ec3fcb523cf4cc240e9dbaed124bc330b2db08d
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index ed478ac..4864b80 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -1642,13 +1642,8 @@
     private fun cycleFlashMode() {
         val currentFlashMode = flashMode
         val newFlashMode = when (cameraMode) {
-            CameraMode.PHOTO -> currentFlashMode.next()
-            CameraMode.VIDEO ->
-                if (currentFlashMode != FlashMode.OFF) {
-                    FlashMode.OFF
-                } else {
-                    FlashMode.TORCH
-                }
+            CameraMode.PHOTO -> FlashMode.PHOTO_ALLOWED_MODES.next(currentFlashMode)
+            CameraMode.VIDEO -> FlashMode.VIDEO_ALLOWED_MODES.next(currentFlashMode)
             else -> FlashMode.OFF
         }
 
diff --git a/app/src/main/java/org/lineageos/aperture/camera/FlashMode.kt b/app/src/main/java/org/lineageos/aperture/camera/FlashMode.kt
index af41b53..5f501b7 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/FlashMode.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/FlashMode.kt
@@ -38,4 +38,24 @@
      * Get the next mode.
      */
     fun next() = values().next(this)
+
+    companion object {
+        /**
+         * Allowed flash modes when in photo mode.
+         */
+        val PHOTO_ALLOWED_MODES = listOf(
+            OFF,
+            AUTO,
+            ON,
+            TORCH,
+        )
+
+        /**
+         * Allowed flash modes when in video mode.
+         */
+        val VIDEO_ALLOWED_MODES = listOf(
+            OFF,
+            TORCH,
+        )
+    }
 }