summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2015-04-07 16:57:48 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-07 16:57:48 +0000
commit6db1f7fd0bbaedc4df177b672232ec3162c3ce8e (patch)
tree12475a020a2088cbd2ed3fcb5e2a9e4a4a5dc170
parent5575246aae55ec053430d23b9bd515c8bb0cc51c (diff)
parent0d6c44afe2731446e2b96c17ae0fd52e62ea1e54 (diff)
downloadandroid_frameworks_opt_setupwizard-6db1f7fd0bbaedc4df177b672232ec3162c3ce8e.tar.gz
android_frameworks_opt_setupwizard-6db1f7fd0bbaedc4df177b672232ec3162c3ce8e.tar.bz2
android_frameworks_opt_setupwizard-6db1f7fd0bbaedc4df177b672232ec3162c3ce8e.zip
am 0d6c44af: Merge "[SetupWizardLib] Adjust immersive flags for dialogs" into ub-setupwizard-alatar
* commit '0d6c44afe2731446e2b96c17ae0fd52e62ea1e54': [SetupWizardLib] Adjust immersive flags for dialogs
-rw-r--r--library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java23
-rw-r--r--library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java23
2 files changed, 38 insertions, 8 deletions
diff --git a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
index e3611f3..4cba014 100644
--- a/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
+++ b/library/main/src/com/android/setupwizardlib/util/SystemBarHelper.java
@@ -49,6 +49,11 @@ public class SystemBarHelper {
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ @SuppressLint("InlinedApi")
+ private static final int DIALOG_IMMERSIVE_FLAGS =
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+
/**
* Needs to be equal to View.STATUS_BAR_DISABLE_BACK
*/
@@ -63,7 +68,8 @@ public class SystemBarHelper {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
final Window window = dialog.getWindow();
temporarilyDisableDialogFocus(window);
- hideSystemBars(window);
+ addImmersiveFlagsToWindow(window, DIALOG_IMMERSIVE_FLAGS);
+ addImmersiveFlagsToDecorView(window, new Handler(), DIALOG_IMMERSIVE_FLAGS);
}
}
@@ -77,8 +83,8 @@ public class SystemBarHelper {
*/
public static void hideSystemBars(final Window window) {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- addImmersiveFlagsToWindow(window);
- addImmersiveFlagsToDecorView(window, new Handler());
+ addImmersiveFlagsToWindow(window, DEFAULT_IMMERSIVE_FLAGS);
+ addImmersiveFlagsToDecorView(window, new Handler(), DEFAULT_IMMERSIVE_FLAGS);
}
}
@@ -156,27 +162,28 @@ public class SystemBarHelper {
* the window.
*/
@TargetApi(VERSION_CODES.LOLLIPOP)
- private static void addImmersiveFlagsToDecorView(final Window window, final Handler handler) {
+ private static void addImmersiveFlagsToDecorView(final Window window, final Handler handler,
+ final int vis) {
// Use peekDecorView instead of getDecorView so that clients can still set window features
// after calling this method.
final View decorView = window.peekDecorView();
if (decorView != null) {
- addVisibilityFlag(decorView, DEFAULT_IMMERSIVE_FLAGS);
+ addVisibilityFlag(decorView, vis);
} else {
// If the decor view is not installed yet, try again in the next loop.
handler.post(new Runnable() {
@Override
public void run() {
- addImmersiveFlagsToDecorView(window, handler);
+ addImmersiveFlagsToDecorView(window, handler, vis);
}
});
}
}
@TargetApi(VERSION_CODES.LOLLIPOP)
- private static void addImmersiveFlagsToWindow(final Window window) {
+ private static void addImmersiveFlagsToWindow(final Window window, final int vis) {
WindowManager.LayoutParams attrs = window.getAttributes();
- attrs.systemUiVisibility |= DEFAULT_IMMERSIVE_FLAGS;
+ attrs.systemUiVisibility |= vis;
window.setAttributes(attrs);
// Also set the navigation bar and status bar to transparent color. Note that this doesn't
diff --git a/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java b/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java
index 98e3f73..c4250cd 100644
--- a/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java
+++ b/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java
@@ -17,6 +17,7 @@
package com.android.setupwizardlib.test;
import android.annotation.SuppressLint;
+import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
@@ -49,6 +50,11 @@ public class SystemBarHelperTest extends AndroidTestCase {
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ @SuppressLint("InlinedApi")
+ private static final int DIALOG_IMMERSIVE_FLAGS =
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+
@SmallTest
public void testAddVisibilityFlagView() {
final View view = createViewWithSystemUiVisibility(0x456);
@@ -107,6 +113,23 @@ public class SystemBarHelperTest extends AndroidTestCase {
}
@SmallTest
+ public void testHideSystemBarsDialog() {
+ final Dialog dialog = new Dialog(mContext);
+ if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ final WindowManager.LayoutParams attrs = dialog.getWindow().getAttributes();
+ attrs.systemUiVisibility = 0x456;
+ dialog.getWindow().setAttributes(attrs);
+ }
+
+ SystemBarHelper.hideSystemBars(dialog);
+ if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ assertEquals("DIALOG_IMMERSIVE_FLAGS should be added to window's systemUiVisibility",
+ DIALOG_IMMERSIVE_FLAGS | 0x456,
+ dialog.getWindow().getAttributes().systemUiVisibility);
+ }
+ }
+
+ @SmallTest
public void testSetBackButtonVisibleTrue() {
final Window window = createWindowWithSystemUiVisibility(0x456);
SystemBarHelper.setBackButtonVisible(window, true);