[Android] Allow immersive mode on older devices without navigation bar
Sébastien Toque
git at videolan.org
Sun Nov 23 09:34:14 CET 2014
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Nov 23 09:33:29 2014 +0100| [65e93bba8e4db5a04595aa93f98992e9b8641dc1] | committer: Sébastien Toque
Allow immersive mode on older devices without navigation bar
using SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and SYSTEM_UI_FLAG_LOW_PROFILE
is useless since there is no navigationbar, and they prevent touchevent
to be handled directly.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=65e93bba8e4db5a04595aa93f98992e9b8641dc1
---
.../vlc/gui/video/VideoPlayerActivity.java | 24 ++++++++++++--------
.../src/org/videolan/vlc/util/AndroidDevices.java | 4 ++--
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index abcecec..faf4d10 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2028,21 +2028,24 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
* Dim the status bar and/or navigation icons when needed on Android 3.x.
* Hide it on Android 4.0 and later
*/
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+ @TargetApi(Build.VERSION_CODES.KITKAT)
private void dimStatusBar(boolean dim) {
- if (!LibVlcUtil.isHoneycombOrLater() || !AndroidDevices.hasNavBar() || mIsNavMenu)
+ if (!LibVlcUtil.isHoneycombOrLater() || mIsNavMenu)
return;
- int layout = 0;
- if (!AndroidDevices.hasCombBar() && LibVlcUtil.isJellyBeanOrLater())
- layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
+ int visibility = 0;
+ int navbar = 0;
+
+ if (!AndroidDevices.hasCombBar() && LibVlcUtil.isJellyBeanOrLater()) {
+ visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
+ navbar = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ }
if (mOverlayUseStatusBar)
- layout |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ visibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
- int visibility = layout;
if (dim) {
- visibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ navbar |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
if (!AndroidDevices.hasCombBar()) {
- visibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ navbar |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
if (LibVlcUtil.isKitKatOrLater())
visibility |= View.SYSTEM_UI_FLAG_IMMERSIVE;
if (mOverlayUseStatusBar)
@@ -2051,6 +2054,9 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
} else {
visibility |= View.SYSTEM_UI_FLAG_VISIBLE;
}
+
+ if (AndroidDevices.hasNavBar())
+ visibility |= navbar;
getWindow().getDecorView().setSystemUiVisibility(visibility);
}
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index dbb7555..d71f55f 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -53,8 +53,8 @@ public class AndroidDevices {
devicesWithoutNavBar.add("HTC One S");
devicesWithoutNavBar.add("HTC One X");
devicesWithoutNavBar.add("HTC One XL");
- hasNavBar = LibVlcUtil.isJellyBeanMR1OrLater() || (LibVlcUtil.isICSOrLater()
- && !devicesWithoutNavBar.contains(android.os.Build.MODEL));
+ hasNavBar = LibVlcUtil.isICSOrLater()
+ && !devicesWithoutNavBar.contains(android.os.Build.MODEL);
hasTsp = VLCApplication.getAppContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen");
}
More information about the Android
mailing list