Aperture: Handle cameras that don't support video recording
This fixes NoSuchElementException in case the currently selected camera
doesn't support video recording.
Change-Id: Id1040dd26dda7adf48166fc9abea4471b0e38d0a
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index faffcbc..99cc4f3 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -741,9 +741,22 @@
sharedPreferences.photoEffect = ExtensionMode.NONE
}
- // Fallback to highest supported video quality
- if (!camera.supportedVideoQualities.contains(videoQuality)) {
- sharedPreferences.videoQuality = camera.supportedVideoQualities.first()
+ if (camera.supportedVideoQualities.isEmpty()) {
+ // Hide video mode button
+ videoModeButton.isVisible = false
+
+ // Switch to photo mode if we are in video mode
+ if (cameraMode == CameraMode.VIDEO) {
+ changeCameraMode(CameraMode.PHOTO)
+ }
+ } else {
+ // Show video mode button
+ videoModeButton.isVisible = true
+
+ // Fallback to highest supported video quality
+ if (!camera.supportedVideoQualities.contains(videoQuality)) {
+ sharedPreferences.videoQuality = camera.supportedVideoQualities.first()
+ }
}
// Initialize the use case we want and set its properties