diff --git a/templates/android/template/src/org/haxe/lime/GameActivity.java b/templates/android/template/src/org/haxe/lime/GameActivity.java index 320e60b11..eb918e36f 100644 --- a/templates/android/template/src/org/haxe/lime/GameActivity.java +++ b/templates/android/template/src/org/haxe/lime/GameActivity.java @@ -100,7 +100,10 @@ public class GameActivity extends Activity implements SensorEventListener { requestWindowFeature (Window.FEATURE_NO_TITLE); ::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:: metrics = new DisplayMetrics (); @@ -161,45 +164,18 @@ public class GameActivity extends Activity implements SensorEventListener { } + // IMMERSIVE MODE SUPPORT ::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 public void onWindowFocusChanged(boolean 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) { - this.delayedHide(HIDE_DELAY); - } else { - hideSystemUiHandler.removeMessages(0); - } - } - - // declare handler - protected Handler hideSystemUiHandler = new Handler() { - - @Override - public void handleMessage(Message message) { hideSystemUi(); } - }; - - // hide system ui after delay - private void delayedHide(int delayInMilliseconds) { - this.hideSystemUiHandler.removeMessages(0); - this.hideSystemUiHandler.sendEmptyMessageDelayed(0, delayInMilliseconds); } - + private void hideSystemUi() { 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_HIDE_NAVIGATION | 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:: public static double CapabilitiesGetPixelAspectRatio () {