Aperture: Make zoom slider linear
Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
Change-Id: I5c4038d92fc6f23bfd6aaf113afb550fd3582958
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 40547cc..1536f30 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -231,9 +231,7 @@
return@observe
}
- zoomLevel.valueFrom = it.minZoomRatio
- zoomLevel.valueTo = it.maxZoomRatio
- zoomLevel.value = it.zoomRatio
+ zoomLevel.value = it.linearZoom
zoomLevel.visibility = View.VISIBLE
handler.removeMessages(MSG_HIDE_ZOOM_SLIDER)
@@ -242,10 +240,12 @@
zoomLevel.addOnChangeListener { _, value, fromUser ->
if (fromUser) {
- cameraController.setZoomRatio(value)
+ cameraController.setLinearZoom(value)
}
}
- zoomLevel.setLabelFormatter { "%.1fx".format(it) }
+ zoomLevel.setLabelFormatter {
+ "%.1fx".format(cameraController.zoomState.value?.zoomRatio)
+ }
// Set bottom bar button callbacks
qrModeButton.setOnClickListener { changeCameraMode(CameraMode.QR) }
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 950c847..10a120c 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -184,6 +184,8 @@
android:id="@+id/zoomLevel"
android:layout_width="250dp"
android:layout_height="0dp"
+ android:valueFrom="0.0"
+ android:valueTo="1.0"
android:visibility="gone"
app:labelBehavior="visible"
app:layout_constraintBottom_toBottomOf="@+id/viewFinder"