remove redundant code for immersive mode, make immersive sticky and disable old fullscreen flags for android devices below api 19
This commit is contained in:
@@ -100,7 +100,10 @@ public class GameActivity extends Activity implements SensorEventListener {
|
|||||||
|
|
||||||
requestWindowFeature (Window.FEATURE_NO_TITLE);
|
requestWindowFeature (Window.FEATURE_NO_TITLE);
|
||||||
::if WIN_FULLSCREEN::
|
::if WIN_FULLSCREEN::
|
||||||
getWindow ().addFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
::if (ANDROID_TARGET_SDK_VERSION < 19)::
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
::end::
|
||||||
::end::
|
::end::
|
||||||
|
|
||||||
metrics = new DisplayMetrics ();
|
metrics = new DisplayMetrics ();
|
||||||
@@ -161,45 +164,18 @@ public class GameActivity extends Activity implements SensorEventListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMMERSIVE MODE SUPPORT
|
||||||
::if (ANDROID_TARGET_SDK_VERSION >= 19)::
|
::if (ANDROID_TARGET_SDK_VERSION >= 19)::
|
||||||
|
|
||||||
private final int HIDE_DELAY = 100;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
|
||||||
super.onPostCreate(savedInstanceState);
|
|
||||||
|
|
||||||
this.delayedHide(HIDE_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
|
||||||
// when the window lost focus cancel all pending hide actions
|
|
||||||
// when the window gains focus, hide the system ui.
|
|
||||||
if(hasFocus) {
|
if(hasFocus) {
|
||||||
this.delayedHide(HIDE_DELAY);
|
|
||||||
} else {
|
|
||||||
hideSystemUiHandler.removeMessages(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// declare handler
|
|
||||||
protected Handler hideSystemUiHandler = new Handler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message message) {
|
|
||||||
hideSystemUi();
|
hideSystemUi();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// hide system ui after delay
|
|
||||||
private void delayedHide(int delayInMilliseconds) {
|
|
||||||
this.hideSystemUiHandler.removeMessages(0);
|
|
||||||
this.hideSystemUiHandler.sendEmptyMessageDelayed(0, delayInMilliseconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideSystemUi() {
|
private void hideSystemUi() {
|
||||||
View decorView = this.getWindow().getDecorView();
|
View decorView = this.getWindow().getDecorView();
|
||||||
|
|
||||||
@@ -209,19 +185,9 @@ public class GameActivity extends Activity implements SensorEventListener {
|
|||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSystemUi() {
|
|
||||||
View decorView = this.getWindow().getDecorView();
|
|
||||||
|
|
||||||
decorView.setSystemUiVisibility(
|
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
::end::
|
::end::
|
||||||
|
|
||||||
public static double CapabilitiesGetPixelAspectRatio () {
|
public static double CapabilitiesGetPixelAspectRatio () {
|
||||||
|
|||||||
Reference in New Issue
Block a user