Fixed the positioning of popups after changing the screen orientation on Android (#8927)

This commit is contained in:
Gualdimar 2023-03-16 20:48:24 +02:00 committed by GitHub
parent a4b6585626
commit ba63f9a62b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.unciv.app
import android.app.Activity
import android.content.Intent
import android.graphics.Rect
import android.net.Uri
@ -14,7 +15,9 @@ import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.screens.basescreen.UncivStage
import com.unciv.utils.concurrency.Concurrency
class AndroidGame : UncivGame() {
class AndroidGame(private val activity: Activity) : UncivGame() {
private var lastOrientation = activity.resources.configuration.orientation
fun addScreenObscuredListener() {
val contentView = (Gdx.graphics as AndroidGraphics).view
@ -53,6 +56,12 @@ class AndroidGame : UncivGame() {
lastFrame = currentFrame
lastVisibleStage = visibleStage
val currentOrientation = activity.resources.configuration.orientation
if (lastOrientation != currentOrientation) {
lastOrientation = currentOrientation
return
}
Concurrency.runOnGLThread {
EventBus.send(UncivStage.VisibleAreaChanged(visibleStage))
}

View File

@ -44,7 +44,7 @@ open class AndroidLauncher : AndroidApplication() {
Display.setOrientation(settings.displayOrientation)
Display.setCutout(settings.androidCutout)
game = AndroidGame()
game = AndroidGame(this)
initialize(game, config)
game!!.setDeepLinkedGame(intent)