Remove re-orientation for OptionsPopup (#6466)

This commit is contained in:
SomeTroglodyte
2022-03-31 22:03:57 +02:00
committed by GitHub
parent 6315a16d98
commit 90a172ab02
4 changed files with 26 additions and 91 deletions

View File

@ -1,7 +1,6 @@
package com.unciv.app
import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import androidx.core.app.NotificationManagerCompat
@ -25,18 +24,19 @@ open class AndroidLauncher : AndroidApplication() {
MultiplayerTurnCheckWorker.createNotificationChannels(applicationContext)
copyMods()
val externalfilesDir = getExternalFilesDir(null)
if (externalfilesDir != null) GameSaver.externalFilesDirForAndroid = externalfilesDir.path
val externalFilesDir = getExternalFilesDir(null)
if (externalFilesDir != null) GameSaver.externalFilesDirForAndroid = externalFilesDir.path
val config = AndroidApplicationConfiguration().apply {
useImmersiveMode = true
}
val settings = GameSettings.getSettingsForPlatformLaunchers(filesDir.path)
val fontFamily = settings.fontFamily
// Manage orientation lock
val limitOrientationsHelper = LimitOrientationsHelperAndroid(this)
limitOrientationsHelper.limitOrientations(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
val config = AndroidApplicationConfiguration().apply {
useImmersiveMode = true;
}
val fontFamily = GameSettings.getSettingsForPlatformLaunchers(filesDir.path).fontFamily
limitOrientationsHelper.allowPortrait(settings.allowAndroidPortrait)
val androidParameters = UncivGameParameters(
version = BuildConfig.VERSION_NAME,
@ -49,14 +49,7 @@ open class AndroidLauncher : AndroidApplication() {
game = UncivGame(androidParameters)
initialize(game, config)
// This is also needed in onCreate to open links and notifications
// correctly even if the app was not running
if (intent.action == Intent.ACTION_VIEW) {
val uri: Uri? = intent.data
deepLinkedMultiplayerGame = uri?.getQueryParameter("id")
} else {
deepLinkedMultiplayerGame = null
}
setDeepLinkedGame(intent)
}
/**
@ -97,7 +90,7 @@ open class AndroidLauncher : AndroidApplication() {
}
if (deepLinkedMultiplayerGame != null) {
game?.deepLinkedMultiplayerGame = deepLinkedMultiplayerGame;
game?.deepLinkedMultiplayerGame = deepLinkedMultiplayerGame
deepLinkedMultiplayerGame = null
}
@ -109,11 +102,15 @@ open class AndroidLauncher : AndroidApplication() {
if (intent == null)
return
if (intent.action == Intent.ACTION_VIEW) {
setDeepLinkedGame(intent)
}
private fun setDeepLinkedGame(intent: Intent) {
// This is needed in onCreate _and_ onNewIntent to open links and notifications
// correctly even if the app was not running
deepLinkedMultiplayerGame = if (intent.action != Intent.ACTION_VIEW) null else {
val uri: Uri? = intent.data
deepLinkedMultiplayerGame = uri?.getQueryParameter("id")
} else {
deepLinkedMultiplayerGame = null
uri?.getQueryParameter("id")
}
}