From ccd421598eaf441a2799f33dc05e418bb17e9588 Mon Sep 17 00:00:00 2001 From: Patrick Babb <72764527+patrickbabb@users.noreply.github.com> Date: Sun, 4 May 2025 23:53:45 -0500 Subject: [PATCH] Update SDLActivity.java Enabled immersive mode on Android devices during onCreate in the lifecycle. --- .../src/org/libsdl/app/SDLActivity.java | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java index 593ee1c35..18d088324 100644 --- a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java +++ b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java @@ -1115,24 +1115,49 @@ public class SDLActivity extends Activity implements OnKeyListener { } // Setup - @Override - protected void onCreate(Bundle savedInstanceState) { - //Log.d(TAG, "onCreate()"); - super.onCreate(savedInstanceState); + private void enterImmersiveMode() { + final View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + ); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (hasFocus) { + enterImmersiveMode(); + } + } - StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll() - .build(); - StrictMode.setThreadPolicy(policy); - setContentView(R.layout.main); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - // So we can call stuff from static callbacks - mSingleton = this; - mContext = this.getApplicationContext(); - RES_FILENAME = getResourceName(); - StorageOptions.determineStorageOptions(mContext); - checkStorageLocationPreference(); - prepareOptionMenu(null); - } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); + StrictMode.setThreadPolicy(policy); + + setContentView(R.layout.main); + + // Enable immersive mode + enterImmersiveMode(); + + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + + // So we can call stuff from static callbacks + mSingleton = this; + mContext = this.getApplicationContext(); + RES_FILENAME = getResourceName(); + StorageOptions.determineStorageOptions(mContext); + checkStorageLocationPreference(); + prepareOptionMenu(null); +} public void forceResDownload(final File oldRes) { AlertDialog.Builder resChooser = new AlertDialog.Builder(this);