Skip to content

ProCraft for Android: An Android native painting app written in Rust

Rust

fix(canvas): keep the canvas in place when the display turned while the app was away

Josh6c1b6ecd787f
diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt
index 9fe2ef7..024a98f 100644
--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt
+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt
@@ -305,6 +305,9 @@ class CanvasSurfaceView(context: Context, private val vm: CanvasViewModel) : Sur
try {
s.attachWindow(id.toULong(), width.toUInt(), height.toUInt())
s.setDisplayScale(resources.displayMetrics.density)
+ // the display turned while there was no window (the app away, the upright lock screen):
+ // the view follows now, as it would have then, so the canvas stays put on the glass
+ if (session === s && windowWidth > 0 && rotation != windowRotation) followTurn(s, windowRotation, rotation)
session = s
attached = true
vm.refreshView()