diff --git a/app/src/main/java/no/naiv/tiltshift/util/OrientationDetector.kt b/app/src/main/java/no/naiv/tiltshift/util/OrientationDetector.kt index f7b49da..45bcf3a 100644 --- a/app/src/main/java/no/naiv/tiltshift/util/OrientationDetector.kt +++ b/app/src/main/java/no/naiv/tiltshift/util/OrientationDetector.kt @@ -24,11 +24,17 @@ class OrientationDetector(private val context: Context) { override fun onOrientationChanged(orientation: Int) { if (orientation == ORIENTATION_UNKNOWN) return + // OrientationEventListener reports the device's physical rotation + // (clockwise from natural). Surface.ROTATION_* describes the screen's + // logical rotation, which is the opposite direction — so device tilted + // 90° CW (orientation ≈ 90, "left side at top") maps to ROTATION_270, + // and 90° CCW (orientation ≈ 270) maps to ROTATION_90. Matches the + // CameraX docs example for setTargetRotation. val rotation = when { orientation >= 315 || orientation < 45 -> Surface.ROTATION_0 - orientation >= 45 && orientation < 135 -> Surface.ROTATION_90 + orientation >= 45 && orientation < 135 -> Surface.ROTATION_270 orientation >= 135 && orientation < 225 -> Surface.ROTATION_180 - else -> Surface.ROTATION_270 + else -> Surface.ROTATION_90 } if (rotation != lastRotation) { diff --git a/version.properties b/version.properties index 7f96eb7..0f86d43 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ versionMajor=1 versionMinor=1 -versionPatch=6 -versionCode=8 +versionPatch=7 +versionCode=9