v3.2.2: improved fullscreen option eligibility on Android

This commit is contained in:
Evan Debenham
2025-08-22 10:57:06 -04:00
parent 00672f415b
commit 22fb116254
5 changed files with 21 additions and 17 deletions

View File

@@ -28,21 +28,6 @@ import com.watabou.noosa.Game;
//TODO migrate to platformSupport class
public class DeviceCompat {
public static boolean supportsFullScreen(){
switch (Gdx.app.getType()){
case Android:
//TODO perhaps have this vary based on status bar type?
return true;
case iOS:
//iOS supports hiding UI via drawing into the gesture safe area
return Gdx.graphics.getSafeInsetBottom() != 0;
case Desktop:
return true;
default:
return false;
}
}
//return APi level on Android, major OS version on iOS, 0 on desktop
public static int getPlatformVersion(){

View File

@@ -34,6 +34,10 @@ import java.util.HashMap;
public abstract class PlatformSupport {
public abstract void updateDisplaySize();
public boolean supportsFullScreen(){
return true; //default
}
public abstract void updateSystemUI();

View File

@@ -45,6 +45,16 @@ public class AndroidPlatformSupport extends PlatformSupport {
//TODO seem to be existing bugs with handling split screen here, should look into that
}
public boolean supportsFullScreen(){
//Android supports hiding the navigation bar or gesture bar, if it is present
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
WindowInsets insets = ((AndroidApplication)Gdx.app).getApplicationWindow().getDecorView().getRootWindowInsets();
return insets.getStableInsetBottom() > 0 || insets.getStableInsetRight() > 0 || insets.getStableInsetLeft() > 0;
} else {
return true;
}
}
public void updateSystemUI() {
@@ -63,7 +73,6 @@ public class AndroidPlatformSupport extends PlatformSupport {
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
//TODO can immersive be handled by libGDX? It's getting quite dated here
if (SPDSettings.fullscreen()) {
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

View File

@@ -242,7 +242,7 @@ public class WndSettings extends WndTabbed {
SPDSettings.fullscreen(checked());
}
};
if (DeviceCompat.supportsFullScreen()){
if (Game.platform.supportsFullScreen()){
chkFullscreen.checked(SPDSettings.fullscreen());
} else {
chkFullscreen.checked(true);

View File

@@ -67,6 +67,12 @@ public class IOSPlatformSupport extends PlatformSupport {
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
}
@Override
public boolean supportsFullScreen() {
//iOS supports hiding UI via drawing into the gesture safe area
return Gdx.graphics.getSafeInsetBottom() > 0;
}
@Override
public void updateSystemUI() {
int prevInset = Game.bottomInset;