Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Android editor: Show the StatusBar when in portrait mode

Anish Kumare11e628b3acb
diff --git a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
index dba04e36d12..ff01c0e3e34 100644
--- a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt
@@ -448,13 +448,17 @@ class Godot private constructor(val context: Context) {
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} else {
val fullScreenThemeValue = TypedValue()
- val hasStatusBar = if (activity.theme.resolveAttribute(android.R.attr.windowFullscreen, fullScreenThemeValue, true) && fullScreenThemeValue.type == TypedValue.TYPE_INT_BOOLEAN) {
+ var hasStatusBar = if (activity.theme.resolveAttribute(android.R.attr.windowFullscreen, fullScreenThemeValue, true) && fullScreenThemeValue.type == TypedValue.TYPE_INT_BOOLEAN) {
fullScreenThemeValue.data == 0
} else {
// Fallback to checking the editor build
!isEditorBuild()
}
+ if (isEditorBuild() && orientation == Configuration.ORIENTATION_PORTRAIT) {
+ hasStatusBar = true
+ }
+
val types = if (hasStatusBar) {
WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.statusBars()
} else {
@@ -787,6 +791,18 @@ class Godot private constructor(val context: Context) {
runOnRenderThread {
GodotLib.onOrientationChange(orientation)
}
+
+ if (isEditorBuild() && !isInImmersiveMode()) {
+ val window = getActivity()?.window
+ if (window != null) {
+ val controller = WindowInsetsControllerCompat(window, window.decorView)
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ controller.show(WindowInsetsCompat.Type.statusBars())
+ } else {
+ controller.hide(WindowInsetsCompat.Type.statusBars())
+ }
+ }
+ }
}
}