@SomeTroglodyte

initialize() calls useImmersiveMode() internally, which would override the system ui visibility we manually set, leading to setting effectively being ignored on startup

Also, we can use LibGDX's builting function, which is more future-proof :)
This commit is contained in:
Yair Morgenstern
2023-12-25 20:04:34 +02:00
parent 30c9876e2f
commit 0ddf67530f
2 changed files with 4 additions and 21 deletions

View File

@ -1,13 +1,12 @@
package com.unciv.app
import android.app.Activity
import android.content.pm.ActivityInfo
import android.os.Build
import android.view.Display
import android.view.Display.Mode
import android.view.View
import android.view.WindowManager
import androidx.annotation.RequiresApi
import com.badlogic.gdx.backends.android.AndroidApplication
import com.unciv.models.metadata.GameSettings
import com.unciv.models.translations.tr
import com.unciv.utils.PlatformDisplay
@ -15,7 +14,7 @@ import com.unciv.utils.ScreenMode
import com.unciv.utils.ScreenOrientation
class AndroidDisplay(private val activity: Activity) : PlatformDisplay {
class AndroidDisplay(private val activity: AndroidApplication) : PlatformDisplay {
private var display: Display? = null
private var displayModes: HashMap<Int, ScreenMode> = hashMapOf()
@ -60,22 +59,7 @@ class AndroidDisplay(private val activity: Activity) : PlatformDisplay {
override fun hasSystemUiVisibility() = true
override fun setSystemUiVisibility(hide: Boolean) {
activity.runOnUiThread {
setSystemUiVisibilityFromUiThread(hide)
}
}
internal fun setSystemUiVisibilityFromUiThread(hide: Boolean) {
@Suppress("DEPRECATION") // Avoids @RequiresApi(Build.VERSION_CODES.R)
activity.window.decorView.systemUiVisibility =
if (hide)
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
else
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
override fun setSystemUiVisibility(hide: Boolean) = activity.runOnUiThread { activity.useImmersiveMode(hide) }
override fun hasCutout(): Boolean {
return when {

View File

@ -33,13 +33,12 @@ open class AndroidLauncher : AndroidApplication() {
UncivFiles.saverLoader = AndroidSaverLoader(this)
UncivFiles.preferExternalStorage = true
val config = AndroidApplicationConfiguration().apply { useImmersiveMode = false }
val settings = UncivFiles.getSettingsForPlatformLaunchers(filesDir.path)
val config = AndroidApplicationConfiguration().apply { useImmersiveMode = settings.androidHideSystemUi }
// Setup orientation, immersive mode and display cutout
displayImpl.setOrientation(settings.displayOrientation)
displayImpl.setCutoutFromUiThread(settings.androidCutout)
displayImpl.setSystemUiVisibilityFromUiThread(settings.androidHideSystemUi)
// Create notification channels for Multiplayer notificator
MultiplayerTurnCheckWorker.createNotificationChannels(applicationContext)