diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-18 05:17:06 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-18 05:17:06 +0000 |
commit | 9f5c919948f1759d88f581c94a89944a2813a8b3 (patch) | |
tree | aafacf3147d562d104a6ff105bdb2927f278a0b7 /remoting/android | |
parent | 05137d60bd6c2ef3039305bf9e5ed3a6226d8ad7 (diff) | |
download | chromium_src-9f5c919948f1759d88f581c94a89944a2813a8b3.zip chromium_src-9f5c919948f1759d88f581c94a89944a2813a8b3.tar.gz chromium_src-9f5c919948f1759d88f581c94a89944a2813a8b3.tar.bz2 |
Use Immersive mode in Chromoting Android client on supported devices
This detects if the device is running KitKat or higher, and sets the
display to Immersive fullscreen mode when the action-bar is hidden.
BUG=338773
Review URL: https://codereview.chromium.org/240153008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/android')
-rw-r--r-- | remoting/android/java/src/org/chromium/chromoting/Desktop.java | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/Desktop.java b/remoting/android/java/src/org/chromium/chromoting/Desktop.java index 662c0d9..425837b 100644 --- a/remoting/android/java/src/org/chromium/chromoting/Desktop.java +++ b/remoting/android/java/src/org/chromium/chromoting/Desktop.java @@ -6,6 +6,7 @@ package org.chromium.chromoting; import android.app.Activity; import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; @@ -72,7 +73,17 @@ public class Desktop extends Activity implements View.OnSystemUiVisibilityChange public void onSystemUiVisibilityChange(int visibility) { // Ensure the action-bar's visibility matches that of the system controls. This // minimizes the number of states the UI can be in, to keep things simple for the user. - if ((visibility & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { + + // Determine if the system is in fullscreen/lights-out mode. LOW_PROFILE is needed since + // it's the only flag supported in 4.0. But it is not sufficient in itself; when + // IMMERSIVE_STICKY mode is used, the system clears this flag (leaving the FULLSCREEN flag + // set) when the user swipes the edge to reveal the bars temporarily. When this happens, + // the action-bar should remain hidden. + int fullscreenFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + fullscreenFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN; + } + if ((visibility & fullscreenFlags) != 0) { hideActionBar(); } else { showActionBar(); @@ -92,8 +103,24 @@ public class Desktop extends Activity implements View.OnSystemUiVisibilityChange getActionBar().hide(); View decorView = getWindow().getDecorView(); - decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE - | View.SYSTEM_UI_FLAG_FULLSCREEN); + + // LOW_PROFILE gives the status and navigation bars a "lights-out" appearance. + // FULLSCREEN hides the status bar on supported devices (4.1 and above). + int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + flags |= View.SYSTEM_UI_FLAG_FULLSCREEN; + } + + // HIDE_NAVIGATION hides the navigation bar. However, if the user touches the screen, the + // event is not seen by the application and instead the navigation bar is re-shown. + // IMMERSIVE(_STICKY) fixes this problem and allows the user to interact with the app while + // keeping the navigation controls hidden. This flag was introduced in 4.4, later than + // HIDE_NAVIGATION, and so a runtime check is needed before setting either of these flags. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + flags |= (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + + decorView.setSystemUiVisibility(flags); } /** The overlay button's onClick handler. */ |