diff options
Diffstat (limited to 'platform/android/java/src/com')
-rw-r--r-- | platform/android/java/src/com/android/godot/Godot.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 2abb4cec53..7fd06a01d6 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -110,6 +110,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private Button mWiFiSettingsButton; private boolean use_32_bits=false; + private boolean use_immersive=false; private boolean mStatePaused; private int mState; @@ -374,6 +375,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger()); } + + @Override protected void onCreate(Bundle icicle) { @@ -402,6 +405,19 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC boolean has_extra = i< command_line.length -1; if (command_line[i].equals("-use_depth_32")) { use_32_bits=true; + } else if (command_line[i].equals("-use_immersive")) { + use_immersive=true; + if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + + UiChangeListener(); + } } else if (command_line[i].equals("-use_apk_expansion")) { use_apk_expansion=true; } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) { @@ -560,6 +576,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mView.onResume(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); GodotLib.focusin(); + if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + Window window = getWindow(); + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } for(int i=0;i<singleton_count;i++) { @@ -570,6 +596,24 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } + public void UiChangeListener() { + final View decorView = getWindow().getDecorView(); + decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { + decorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + } + }); + } + @Override public void onSensorChanged(SensorEvent event) { Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); int displayRotation = display.getRotation(); |