# HG changeset patch # User Olli Kallioinen # Date 1511054723 -7200 # Sun Nov 19 03:25:23 2017 +0200 # Node ID 83f19d548adc593cac5a5e782ab7f69dfda2ced7 # Parent 88462f00ffac3588cd395b752b6b33ad674039ff Android: Better handling for system UI visibility flags. diff -r 88462f00ffac -r 83f19d548adc android-project/app/build.gradle --- a/android-project/app/build.gradle Fri Nov 17 11:03:02 2017 -0800 +++ b/android-project/app/build.gradle Sun Nov 19 03:25:23 2017 +0200 @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 16 + compileSdkVersion 19 buildToolsVersion "26.0.1" defaultConfig { applicationId "org.libsdl.app" minSdkVersion 14 - targetSdkVersion 16 + targetSdkVersion 19 versionCode 1 versionName "1.0" externalNativeBuild { diff -r 88462f00ffac -r 83f19d548adc android-project/app/src/main/java/org/libsdl/app/SDLActivity.java --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java Fri Nov 17 11:03:02 2017 -0800 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java Sun Nov 19 03:25:23 2017 +0200 @@ -142,6 +142,34 @@ mCurrentNativeState = NativeState.INIT; } + /** + * This method is called each time the system ui state needs to be updated. + */ + protected void updateSystemUiVisibility() { + + int visibilityFlags = 0; + // Note: Use a theme defined in the manifest to hide the status bar and the title bar. + + // Hiding the navigation bar. + // Note: The navigation bar can be hidden only for devices that have api level of at + // least 19 (4.4 KitKat). While older devices support a mode where the navigation is + // hidden, the bar will pop back if the screen is touched anywhere so it's really only + // useful for video player apps. + + if (Build.VERSION.SDK_INT >= 19) { + visibilityFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + + // This was causing strange behaviour when status bar is enabled but navigation is + // hidden. Also Didn't see any extra layout calls witout it. + //visibilityFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + + // Make the navigation bar disappear again automatically. + visibilityFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + } + + getWindow().getDecorView().setSystemUiVisibility(visibilityFlags); + } + // Setup @Override protected void onCreate(Bundle savedInstanceState) { @@ -211,20 +239,6 @@ setContentView(mLayout); - /* - * Per SDL_androidwindow.c, Android will only ever have one window, and that window - * is always flagged SDL_WINDOW_FULLSCREEN. Let's treat it as an immersive fullscreen - * window for Android UI purposes, as a result. - */ - int iFlags = - //View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | // Only available since API 19 - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_FULLSCREEN; - - getWindow().getDecorView().setSystemUiVisibility(iFlags); - // Get filename from "Open with" of another application Intent intent = getIntent(); if (intent != null && intent.getData() != null) { @@ -255,6 +269,8 @@ protected void onResume() { Log.v(TAG, "onResume()"); super.onResume(); + updateSystemUiVisibility(); + mNextNativeState = NativeState.RESUMED; mIsResumedCalled = true;