diff --git a/app/src/main/java/no/naiv/tiltshift/ui/CameraScreen.kt b/app/src/main/java/no/naiv/tiltshift/ui/CameraScreen.kt index d5999ed..763d4e4 100644 --- a/app/src/main/java/no/naiv/tiltshift/ui/CameraScreen.kt +++ b/app/src/main/java/no/naiv/tiltshift/ui/CameraScreen.kt @@ -1,9 +1,13 @@ package no.naiv.tiltshift.ui +import android.content.Context import android.content.Intent import android.graphics.SurfaceTexture +import android.hardware.display.DisplayManager import android.opengl.GLSurfaceView import android.util.Log +import android.view.Display +import android.view.Surface import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut @@ -164,11 +168,20 @@ fun CameraScreen( } } - // Forward device rotation to renderer so the camera image stays - // world-aligned as the activity rotates with the device. - val currentRotation by viewModel.currentRotation.collectAsState() - LaunchedEffect(currentRotation, renderer) { - renderer?.setDisplayRotation(currentRotation) + // Forward the activity's actual rotation (Display.rotation) to the + // renderer so the camera image stays world-aligned as the activity rotates + // with the device. Don't drive this from OrientationEventListener — its + // 45° threshold fires *before* the activity has rotated, briefly leaving + // the texcoord set out of sync with the GL surface orientation. + // LocalConfiguration triggers a recomposition on configuration change, + // which is when Display.rotation can have changed. + val configuration = androidx.compose.ui.platform.LocalConfiguration.current + val displayRotation = remember(configuration) { + val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager + displayManager.getDisplay(Display.DEFAULT_DISPLAY)?.rotation ?: Surface.ROTATION_0 + } + LaunchedEffect(displayRotation, renderer) { + renderer?.setDisplayRotation(displayRotation) glSurfaceView?.requestRender() } diff --git a/version.properties b/version.properties index aaf41eb..93b21cf 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ versionMajor=1 versionMinor=1 -versionPatch=12 -versionCode=14 +versionPatch=13 +versionCode=15