From 936c86b19097a1c971e08281668f220c62e4d3af Mon Sep 17 00:00:00 2001 From: Anish Mishra Date: Wed, 3 Sep 2025 12:37:49 +0530 Subject: [PATCH] [3.x] Address API 35 UI changes --- .../godotengine/godot/FullScreenGodotApp.java | 28 +++++++++++++++++++ .../lib/src/org/godotengine/godot/Godot.java | 4 +++ 2 files changed, 32 insertions(+) diff --git a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java index 714d218f346..233094b43e4 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java +++ b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java @@ -33,12 +33,20 @@ package org.godotengine.godot; import org.godotengine.godot.utils.ProcessPhoenix; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.View; +import android.view.WindowManager; +import androidx.activity.EdgeToEdge; import androidx.annotation.CallSuper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -59,6 +67,8 @@ public abstract class FullScreenGodotApp extends FragmentActivity implements God @Override public void onCreate(Bundle savedInstanceState) { + // Ensure edge-to-edge + EdgeToEdge.enable(this); super.onCreate(savedInstanceState); setContentView(R.layout.godot_app_layout); @@ -73,6 +83,24 @@ public abstract class FullScreenGodotApp extends FragmentActivity implements God godotFragment = initGodotInstance(); getSupportFragmentManager().beginTransaction().replace(R.id.godot_fragment_container, godotFragment).setPrimaryNavigationFragment(godotFragment).commitNowAllowingStateLoss(); } + + if (!godotFragment.isImmersive()) { + View fragmentContainerView = findViewById(R.id.godot_fragment_container); + // Apply padding for the system bars and/or display cutout + ViewCompat.setOnApplyWindowInsetsListener(fragmentContainerView, (v, insets) -> { + int insetType = WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout(); + Insets windowInsets = insets.getInsets(insetType); + v.setPadding(windowInsets.left, windowInsets.top, windowInsets.right, windowInsets.bottom); + return WindowInsetsCompat.CONSUMED; + }); + // Set system bar appearance + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + } + WindowInsetsControllerCompat controller = new WindowInsetsControllerCompat(getWindow(), getWindow().getDecorView()); + controller.setAppearanceLightNavigationBars(false); // Default Background color is Black + controller.setAppearanceLightStatusBars(false); + } } @Override diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 45e0a898b64..ea1e9942737 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -162,6 +162,10 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return mCurrentIntent; } + public boolean isImmersive() { + return use_immersive; + } + private void setState(int newState) { if (mState != newState) { mState = newState;