Aperture: Hook up video mirror mode
Change-Id: Icf51620da236ccc5a6a3e1d346f649d7b4423754
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 6045cb3..364f569 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -52,6 +52,7 @@
import androidx.camera.core.AspectRatio
import androidx.camera.core.ImageCapture
import androidx.camera.core.ImageCaptureException
+import androidx.camera.core.MirrorMode
import androidx.camera.core.resolutionselector.AspectRatioStrategy
import androidx.camera.core.resolutionselector.ResolutionSelector
import androidx.camera.extensions.ExtensionMode
@@ -104,6 +105,7 @@
import org.lineageos.aperture.camera.NoiseReductionMode
import org.lineageos.aperture.camera.ShadingMode
import org.lineageos.aperture.camera.VideoDynamicRange
+import org.lineageos.aperture.camera.VideoMirrorMode
import org.lineageos.aperture.camera.VideoQualityInfo
import org.lineageos.aperture.camera.VideoStabilizationMode
import org.lineageos.aperture.ext.*
@@ -1561,6 +1563,16 @@
} ?: supportedVideoDynamicRanges.first()
cameraController.videoCaptureDynamicRange = videoDynamicRange.dynamicRange
+ // Set video mirror mode
+ cameraController.videoCaptureMirrorMode = when (sharedPreferences.videoMirrorMode) {
+ VideoMirrorMode.OFF -> MirrorMode.MIRROR_MODE_OFF
+ VideoMirrorMode.ON -> MirrorMode.MIRROR_MODE_ON
+ VideoMirrorMode.ON_FFC_ONLY -> when (camera.cameraFacing) {
+ CameraFacing.FRONT -> MirrorMode.MIRROR_MODE_ON
+ else -> MirrorMode.MIRROR_MODE_OFF
+ }
+ }
+
CameraController.VIDEO_CAPTURE
}
}
diff --git a/app/src/main/java/org/lineageos/aperture/camera/VideoMirrorMode.kt b/app/src/main/java/org/lineageos/aperture/camera/VideoMirrorMode.kt
new file mode 100644
index 0000000..e823997
--- /dev/null
+++ b/app/src/main/java/org/lineageos/aperture/camera/VideoMirrorMode.kt
@@ -0,0 +1,15 @@
+/*
+ * SPDX-FileCopyrightText: 2022-2023 The LineageOS Project
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.aperture.camera
+
+/**
+ * Video mirror mode.
+ */
+enum class VideoMirrorMode {
+ OFF,
+ ON,
+ ON_FFC_ONLY,
+}
diff --git a/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt b/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
index e71c261..bb3c284 100644
--- a/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
+++ b/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
@@ -23,6 +23,7 @@
import org.lineageos.aperture.camera.NoiseReductionMode
import org.lineageos.aperture.camera.ShadingMode
import org.lineageos.aperture.camera.VideoDynamicRange
+import org.lineageos.aperture.camera.VideoMirrorMode
import org.lineageos.aperture.utils.GestureActions
import org.lineageos.aperture.utils.GridMode
import org.lineageos.aperture.utils.TimerMode
@@ -473,3 +474,15 @@
}
)
}
+
+// Video mirror mode
+private const val VIDEO_MIRROR_MODE_KEY = "video_mirror_mode"
+private const val VIDEO_MIRROR_MODE_DEFAULT = "off"
+internal val SharedPreferences.videoMirrorMode: VideoMirrorMode
+ get() = when (getString(VIDEO_MIRROR_MODE_KEY, VIDEO_MIRROR_MODE_DEFAULT)) {
+ "off" -> VideoMirrorMode.OFF
+ "on" -> VideoMirrorMode.ON
+ "on_ffc_only" -> VideoMirrorMode.ON_FFC_ONLY
+ // Default to off
+ else -> VideoMirrorMode.OFF
+ }
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 4414ff9..5482b61 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -121,4 +121,17 @@
<item>fast</item>
<item>high_quality</item>
</string-array>
+
+ <!-- Video mirror mode preference -->
+ <string-array name="video_mirror_mode_entries" translatable="false">
+ <item>@string/video_mirror_mode_off</item>
+ <item>@string/video_mirror_mode_on</item>
+ <item>@string/video_mirror_mode_on_ffc_only</item>
+ </string-array>
+
+ <string-array name="video_mirror_mode_values" translatable="false">
+ <item>off</item>
+ <item>on</item>
+ <item>on_ffc_only</item>
+ </string-array>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6219fbf..ca98ce5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -99,6 +99,7 @@
<!-- Video Preferences -->
<string name="video_stabilization_title">Enable video stabilization</string>
<string name="video_stabilization_summary">When available, enable video stabilization to reduce camera vibrations during recording</string>
+ <string name="video_mirror_mode_title">Enable video mirroring</string>
<!-- Advanced Preferences -->
<string name="processing_title">Processing</string>
@@ -193,4 +194,9 @@
<string name="video_dynamic_range_hdr10_plus_10_bit" translatable="false">HDR10+ (10 bit)</string>
<string name="video_dynamic_range_dolby_vision_10_bit" translatable="false">Dolby Vision (10 bit)</string>
<string name="video_dynamic_range_dolby_vision_8_bit" translatable="false">Dolby Vision (8 bit)</string>
+
+ <!-- Video mirror mode -->
+ <string name="video_mirror_mode_off">Off</string>
+ <string name="video_mirror_mode_on">On</string>
+ <string name="video_mirror_mode_on_ffc_only">Front facing camera only</string>
</resources>
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index b83869c..3dea1b8 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -88,6 +88,15 @@
app:summary="@string/video_stabilization_summary"
app:title="@string/video_stabilization_title" />
+ <ListPreference
+ app:defaultValue="off"
+ app:entries="@array/video_mirror_mode_entries"
+ app:entryValues="@array/video_mirror_mode_values"
+ app:iconSpaceReserved="false"
+ app:key="video_mirror_mode"
+ app:title="@string/video_mirror_mode_title"
+ app:useSimpleSummaryProvider="true" />
+
</PreferenceCategory>
<PreferenceCategory