Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@
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;

Expand All @@ -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);

Expand All @@ -73,6 +83,24 @@ public void onCreate(Bundle savedInstanceState) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ static public Intent getCurrentIntent() {
return mCurrentIntent;
}

public boolean isImmersive() {
return use_immersive;
}

private void setState(int newState) {
if (mState != newState) {
mState = newState;
Expand Down
Loading