1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Address API 35 UI behavior changes

- Fix issue on foldable where the embedded window would obscure the main window when launching
- Fix edge-to-edge support for non-immersive apps / games
- Add edge-to-edge export option to allow non-immersive apps / games to extend edge to edge
This commit is contained in:
Fredia Huya-Kouadio
2025-06-19 16:01:06 -07:00
parent 5abed52fd9
commit 2f4c3d411c
9 changed files with 97 additions and 18 deletions

View File

@@ -88,8 +88,7 @@
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:process=":EmbeddedGodotGame"
android:supportsPictureInPicture="true"
android:screenOrientation="userLandscape" />
android:supportsPictureInPicture="true" />
<activity
android:name=".GodotXRGame"
android:configChanges="layoutDirection|locale|orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"

View File

@@ -45,9 +45,9 @@ import android.os.Process
import android.preference.PreferenceManager
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.annotation.CallSuper
import androidx.core.content.edit
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
@@ -215,9 +215,9 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
// Prevent the editor window from showing in the display cutout
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && getEditorWindowInfo() == EDITOR_MAIN_INFO) {
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
val editorWindowInfo = getEditorWindowInfo()
if (editorWindowInfo == EDITOR_MAIN_INFO || editorWindowInfo == RUN_GAME_INFO) {
enableEdgeToEdge()
}
// We exclude certain permissions from the set we request at startup, as they'll be
@@ -273,16 +273,29 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
}
}
private fun updateImmersiveAndEdgeToEdgeModes() {
val editorWindowInfo = getEditorWindowInfo()
if (editorWindowInfo == EDITOR_MAIN_INFO || editorWindowInfo == RUN_GAME_INFO) {
godot?.apply {
enableImmersiveMode(isInImmersiveMode(), true)
enableEdgeToEdge(isInEdgeToEdgeMode(), true)
}
}
}
override fun onGodotMainLoopStarted() {
super.onGodotMainLoopStarted()
runOnUiThread {
// Hide the loading indicator
editorLoadingIndicator?.visibility = View.GONE
updateImmersiveAndEdgeToEdgeModes()
}
}
override fun onResume() {
super.onResume()
updateImmersiveAndEdgeToEdgeModes()
if (getEditorWindowInfo() == EDITOR_MAIN_INFO &&
godot?.isEditorHint() == true &&
(editorMessageDispatcher.hasEditorConnection(EMBEDDED_RUN_GAME_INFO) ||
@@ -365,7 +378,7 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
// fullscreen mode, we want to remain in fullscreen mode.
// This doesn't apply to the play / game window since for that window fullscreen is
// controlled by the game logic.
val updatedArgs = if (editorWindowInfo == EDITOR_MAIN_INFO &&
val updatedArgs = if ((editorWindowInfo == EDITOR_MAIN_INFO || editorWindowInfo == RUN_GAME_INFO) &&
godot?.isInImmersiveMode() == true &&
!args.contains(FULLSCREEN_ARG) &&
!args.contains(FULLSCREEN_ARG_SHORT)

View File

@@ -87,8 +87,8 @@ class EmbeddedGodotGame : GodotGame() {
override fun setRequestedOrientation(requestedOrientation: Int) {
// Allow orientation change only if fullscreen mode is active
// or if the requestedOrientation is landscape (i.e switching to default).
if (isFullscreen || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE) {
// or if the requestedOrientation is unspecified (i.e switching to default).
if (isFullscreen || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
super.setRequestedOrientation(requestedOrientation)
} else {
// Cache the requestedOrientation to apply when switching to fullscreen.
@@ -155,7 +155,7 @@ class EmbeddedGodotGame : GodotGame() {
// Cache the last used orientation in fullscreen to reapply when re-entering fullscreen.
gameRequestedOrientation = requestedOrientation
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
updateWindowDimensions(layoutWidthInPx, layoutHeightInPx)
}

View File

@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="GodotEditorTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
</style>
<style name="GodotGameTheme" parent="GodotEditorTheme">