v3.2.2: improved fullscreen option eligibility on Android
This commit is contained in:
@@ -28,21 +28,6 @@ import com.watabou.noosa.Game;
|
|||||||
|
|
||||||
//TODO migrate to platformSupport class
|
//TODO migrate to platformSupport class
|
||||||
public class DeviceCompat {
|
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
|
//return APi level on Android, major OS version on iOS, 0 on desktop
|
||||||
public static int getPlatformVersion(){
|
public static int getPlatformVersion(){
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ import java.util.HashMap;
|
|||||||
public abstract class PlatformSupport {
|
public abstract class PlatformSupport {
|
||||||
|
|
||||||
public abstract void updateDisplaySize();
|
public abstract void updateDisplaySize();
|
||||||
|
|
||||||
|
public boolean supportsFullScreen(){
|
||||||
|
return true; //default
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void updateSystemUI();
|
public abstract void updateSystemUI();
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,16 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
|
|
||||||
//TODO seem to be existing bugs with handling split screen here, should look into that
|
//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() {
|
public void updateSystemUI() {
|
||||||
|
|
||||||
@@ -63,7 +73,6 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
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()) {
|
if (SPDSettings.fullscreen()) {
|
||||||
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
|
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ public class WndSettings extends WndTabbed {
|
|||||||
SPDSettings.fullscreen(checked());
|
SPDSettings.fullscreen(checked());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (DeviceCompat.supportsFullScreen()){
|
if (Game.platform.supportsFullScreen()){
|
||||||
chkFullscreen.checked(SPDSettings.fullscreen());
|
chkFullscreen.checked(SPDSettings.fullscreen());
|
||||||
} else {
|
} else {
|
||||||
chkFullscreen.checked(true);
|
chkFullscreen.checked(true);
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ public class IOSPlatformSupport extends PlatformSupport {
|
|||||||
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
|
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
|
@Override
|
||||||
public void updateSystemUI() {
|
public void updateSystemUI() {
|
||||||
int prevInset = Game.bottomInset;
|
int prevInset = Game.bottomInset;
|
||||||
|
|||||||
Reference in New Issue
Block a user