Aperture: Force DEFAULT_BACK_CAMERA for barcode scanner
Change-Id: Iffb7d4c7ba6264f55140da807fe5b3ee18a612ef
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index de2136b..7e013c0 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -496,10 +496,14 @@
gridView.alpha = 0f
// Select front/back camera
- var cameraSelector = when (sharedPreferences.lastCameraFacing) {
- CameraFacing.FRONT -> CameraSelector.DEFAULT_FRONT_CAMERA
- CameraFacing.BACK -> CameraSelector.DEFAULT_BACK_CAMERA
- else -> CameraSelector.DEFAULT_BACK_CAMERA
+ cameraMode = sharedPreferences.lastCameraMode
+ var cameraSelector = when (cameraMode) {
+ CameraMode.QR -> CameraSelector.DEFAULT_BACK_CAMERA
+ else -> when (sharedPreferences.lastCameraFacing) {
+ CameraFacing.FRONT -> CameraSelector.DEFAULT_FRONT_CAMERA
+ CameraFacing.BACK -> CameraSelector.DEFAULT_BACK_CAMERA
+ else -> CameraSelector.DEFAULT_BACK_CAMERA
+ }
}
// Get the supported vendor extensions for the given camera selector
@@ -516,7 +520,6 @@
val outputSize = CameraController.OutputSize(aspectRatio)
// Initialize the use case we want and set its aspect ratio
- cameraMode = sharedPreferences.lastCameraMode
val cameraUseCases = when (cameraMode) {
CameraMode.QR -> {
cameraController.imageAnalysisTargetSize = outputSize
@@ -543,9 +546,11 @@
if (cameraMode == CameraMode.QR) {
cameraController.setImageAnalysisAnalyzer(cameraExecutor, QrImageAnalyzer(this))
timerButton.isVisible = false
+ flipCameraButton.isInvisible = true
shutterButton.isInvisible = true
} else {
timerButton.isVisible = true
+ flipCameraButton.isInvisible = false
shutterButton.isInvisible = false
}