diff options
| -rw-r--r-- | api/current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 34 | ||||
| -rw-r--r-- | packages/SystemUI/res/values-land/refs.xml | 2 | ||||
| -rw-r--r-- | packages/SystemUI/res/values-sw600dp-port/refs.xml | 2 | ||||
| -rw-r--r-- | packages/SystemUI/res/values/strings.xml | 4 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 130 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java | 2 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 188 |
8 files changed, 209 insertions, 157 deletions
diff --git a/api/current.txt b/api/current.txt index 9df2a162defe..982f9b19afe3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -27257,13 +27257,15 @@ package android.view { field public static final int SOUND_EFFECTS_ENABLED = 134217728; // 0x8000000 field public static final deprecated int STATUS_BAR_HIDDEN = 1; // 0x1 field public static final deprecated int STATUS_BAR_VISIBLE = 0; // 0x0 - field public static final int SYSTEM_UI_FLAG_ALLOW_OVERLAY = 2048; // 0x800 + field public static final int SYSTEM_UI_FLAG_ALLOW_TRANSIENT = 2048; // 0x800 field public static final int SYSTEM_UI_FLAG_FULLSCREEN = 4; // 0x4 field public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2; // 0x2 field public static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024; // 0x400 field public static final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512; // 0x200 field public static final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 256; // 0x100 field public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 1; // 0x1 + field public static final int SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION = 8192; // 0x2000 + field public static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS = 4096; // 0x1000 field public static final int SYSTEM_UI_FLAG_VISIBLE = 0; // 0x0 field public static final int SYSTEM_UI_LAYOUT_FLAGS = 1536; // 0x600 field public static final int TEXT_ALIGNMENT_CENTER = 4; // 0x4 diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 7624b56dd4a4..20938f512733 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2379,9 +2379,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * when hiding the status bar with {@link #SYSTEM_UI_FLAG_FULLSCREEN} and/or hiding the * navigation bar with {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION} instead of having the system * clear these flags upon interaction. The system may compensate by temporarily overlaying - * transparent system ui while also delivering the event. + * transparent system bars while also delivering the event. */ - public static final int SYSTEM_UI_FLAG_ALLOW_OVERLAY = 0x00000800; + public static final int SYSTEM_UI_FLAG_ALLOW_TRANSIENT = 0x00000800; + + /** + * Flag for {@link #setSystemUiVisibility(int)}: View would like the status bar to have + * transparency. + * + * <p>The transparency request may be denied if the bar is in another mode with a specific + * style, like {@link #SYSTEM_UI_FLAG_ALLOW_TRANSIENT transient mode}. + */ + public static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS = 0x00001000; + + /** + * Flag for {@link #setSystemUiVisibility(int)}: View would like the navigation bar to have + * transparency. + * + * <p>The transparency request may be denied if the bar is in another mode with a specific + * style, like {@link #SYSTEM_UI_FLAG_ALLOW_TRANSIENT transient mode}. + */ + public static final int SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION = 0x00002000; /** * @deprecated Use {@link #SYSTEM_UI_FLAG_LOW_PROFILE} instead. @@ -2508,11 +2526,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked * out of the public fields to keep the undefined bits out of the developer's way. * - * Flag to specify that the status bar should temporarily overlay underlying content - * that is otherwise assuming the status bar is hidden. The status bar may - * have some degree of transparency while in this temporary overlay mode. + * Flag to specify that the status bar is displayed in transient mode. */ - public static final int STATUS_BAR_OVERLAY = 0x04000000; + public static final int STATUS_BAR_TRANSIENT = 0x04000000; /** * @hide @@ -2520,11 +2536,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked * out of the public fields to keep the undefined bits out of the developer's way. * - * Flag to specify that the navigation bar should temporarily overlay underlying content - * that is otherwise assuming the navigation bar is hidden. The navigation bar mayu - * have some degree of transparency while in this temporary overlay mode. + * Flag to specify that the navigation bar is displayed in transient mode. */ - public static final int NAVIGATION_BAR_OVERLAY = 0x08000000; + public static final int NAVIGATION_BAR_TRANSIENT = 0x08000000; /** * @hide diff --git a/packages/SystemUI/res/values-land/refs.xml b/packages/SystemUI/res/values-land/refs.xml index f5e79b91f9d4..62fb77dad59c 100644 --- a/packages/SystemUI/res/values-land/refs.xml +++ b/packages/SystemUI/res/values-land/refs.xml @@ -16,5 +16,5 @@ */ --> <resources> - <item type="string" name="hideybar_confirmation_message">@string/hideybar_confirmation_message_long</item> + <item type="string" name="hiding_navigation_confirmation_message">@string/hiding_navigation_confirmation_message_long</item> </resources> diff --git a/packages/SystemUI/res/values-sw600dp-port/refs.xml b/packages/SystemUI/res/values-sw600dp-port/refs.xml index f5e79b91f9d4..62fb77dad59c 100644 --- a/packages/SystemUI/res/values-sw600dp-port/refs.xml +++ b/packages/SystemUI/res/values-sw600dp-port/refs.xml @@ -16,5 +16,5 @@ */ --> <resources> - <item type="string" name="hideybar_confirmation_message">@string/hideybar_confirmation_message_long</item> + <item type="string" name="hiding_navigation_confirmation_message">@string/hiding_navigation_confirmation_message_long</item> </resources> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index b99d20cddc19..0073e60b45ef 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -502,8 +502,8 @@ <string name="status_bar_help_text">Access them anytime by swiping down.\nSwipe down again for system controls.</string> <!-- Toast bar message when hiding the navigation bar --> - <string name="hideybar_confirmation_message">Swipe edge of screen to reveal bar</string> + <string name="hiding_navigation_confirmation_message">Swipe edge of screen to reveal bar</string> <!-- Longer version of toast bar message when hiding the navigation bar (if room) --> - <string name="hideybar_confirmation_message_long">Swipe from edge of screen to reveal system bar</string> + <string name="hiding_navigation_confirmation_message_long">Swipe from edge of screen to reveal system bar</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index d1ccde1897a6..3a8145408c6f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -127,11 +127,15 @@ public class PhoneStatusBar extends BaseStatusBar { private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER; - private static final int STATUS_OR_NAV_OVERLAY = - View.STATUS_BAR_OVERLAY | View.NAVIGATION_BAR_OVERLAY; + private static final int STATUS_OR_NAV_TRANSIENT = + View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; private static final long AUTOHIDE_TIMEOUT_MS = 3000; private static final float TRANSPARENT_ALPHA = 0.7f; + private static final int BAR_MODE_NORMAL = 0; + private static final int BAR_MODE_TRANSIENT = 1; + private static final int BAR_MODE_TRANSPARENT = 2; + // fling gesture tuning parameters, scaled to display density private float mSelfExpandVelocityPx; // classic value: 2000px/s private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up") @@ -306,33 +310,33 @@ public class PhoneStatusBar extends BaseStatusBar { } }; - private Toast mHideybarConfirmation; - private boolean mHideybarConfirmationDismissed; + private Toast mHidingNavigationConfirmation; + private boolean mHidingNavigationConfirmationDismissed; - private final View.OnTouchListener mDismissHideybarConfirmationOnTouchOutside = + private final View.OnTouchListener mDismissHidingNavigationConfirmationOnTouchOutside = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) { - dismissHideybarConfirmation(); + dismissHidingNavigationConfirmation(); } return false; } }; - private final Runnable mHideybarConfirmationAction = new Runnable() { + private final Runnable mHidingNavigationConfirmationAction = new Runnable() { @Override public void run() { - if (mHideybarConfirmation != null) { + if (mHidingNavigationConfirmation != null) { final boolean isGloballyConfirmed = Prefs.read(mContext) - .getBoolean(Prefs.HIDEYBAR_CONFIRMED, false); + .getBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, false); if (!isGloballyConfirmed) { // user pressed button, consider this a confirmation Prefs.edit(mContext) - .putBoolean(Prefs.HIDEYBAR_CONFIRMED, true) + .putBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, true) .apply(); } - dismissHideybarConfirmation(); + dismissHidingNavigationConfirmation(); } } }; @@ -342,7 +346,7 @@ public class PhoneStatusBar extends BaseStatusBar { private final Runnable mAutohide = new Runnable() { @Override public void run() { - int requested = mSystemUiVisibility & ~STATUS_OR_NAV_OVERLAY; + int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT; if (mSystemUiVisibility != requested) { notifyUiVisibilityChanged(requested); } @@ -1892,8 +1896,9 @@ public class PhoneStatusBar extends BaseStatusBar { if (diff != 0) { mSystemUiVisibility = newVal; - if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { - final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); + // update low profile + if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { + final boolean lightsOut = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0; if (lightsOut) { animateCollapsePanels(); if (mTicking) { @@ -1908,70 +1913,93 @@ public class PhoneStatusBar extends BaseStatusBar { setStatusBarLowProfile(lightsOut); } - boolean sbOverlayChanged = 0 != (diff & View.STATUS_BAR_OVERLAY); - boolean nbOverlayChanged = 0 != (diff & View.NAVIGATION_BAR_OVERLAY); - if (sbOverlayChanged || nbOverlayChanged) { - boolean sbOverlay = 0 != (vis & View.STATUS_BAR_OVERLAY); - boolean nbOverlay = 0 != (vis & View.NAVIGATION_BAR_OVERLAY); - if (sbOverlayChanged) { - setTransparent(mStatusBarView, sbOverlay); - } - if (nbOverlayChanged) { - setTransparent(mNavigationBarView, nbOverlay); - } - if (sbOverlayChanged && sbOverlay || nbOverlayChanged && nbOverlay) { + // update status bar mode + int sbMode = updateBarMode(oldVal, newVal, mStatusBarView, + View.STATUS_BAR_TRANSIENT, View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS); + + // update navigation bar mode + int nbMode = updateBarMode(oldVal, newVal, mNavigationBarView, + View.NAVIGATION_BAR_TRANSIENT, View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION); + + if (sbMode != -1 || nbMode != -1) { + // update transient bar autohide + if (sbMode == BAR_MODE_TRANSIENT || nbMode == BAR_MODE_TRANSIENT) { scheduleAutohide(); } else { cancelAutohide(); } } + + // update hiding navigation confirmation if (mNavigationBarView != null) { - int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_ALLOW_OVERLAY; - boolean oldVisible = (oldVal & flags) == flags; - boolean newVisible = (newVal & flags) == flags; - if (!oldVisible && newVisible) { - mHideybarConfirmationDismissed = false; + final int hidingNav = + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT; + boolean oldHidingNav = (oldVal & hidingNav) != 0; + boolean newHidingNav = (newVal & hidingNav) != 0; + if (!oldHidingNav && newHidingNav) { + mHidingNavigationConfirmationDismissed = false; } - setHideybarConfirmationVisible(newVisible); + setHidingNavigationConfirmationVisible(newHidingNav); } + + // send updated sysui visibility to window manager notifyUiVisibilityChanged(mSystemUiVisibility); } } - private void dismissHideybarConfirmation() { - if (mHideybarConfirmation != null) { - mHideybarConfirmationDismissed = true; - mHideybarConfirmation.cancel(); - mHideybarConfirmation = null; + private int updateBarMode(int oldVis, int newVis, View view, + int transientFlag, int transparentFlag) { + final int oldMode = barMode(oldVis, transientFlag, transparentFlag); + final int newMode = barMode(newVis, transientFlag, transparentFlag); + if (oldMode == newMode) { + return -1; // no mode change + } + setTransparent(view, newMode != BAR_MODE_NORMAL); + return newMode; + } + + private int barMode(int vis, int transientFlag, int transparentFlag) { + return (vis & transientFlag) != 0 ? BAR_MODE_TRANSIENT + : (vis & transparentFlag) != 0 ? BAR_MODE_TRANSPARENT + : BAR_MODE_NORMAL; + } + + private void dismissHidingNavigationConfirmation() { + if (mHidingNavigationConfirmation != null) { + mHidingNavigationConfirmationDismissed = true; + mHidingNavigationConfirmation.cancel(); + mHidingNavigationConfirmation = null; } } - private void setHideybarConfirmationVisible(boolean visible) { - if (DEBUG) Log.d(TAG, "setHideybarConfirmationVisible " + visible); - if (visible && mHideybarConfirmation == null && !mHideybarConfirmationDismissed) { + private void setHidingNavigationConfirmationVisible(boolean visible) { + if (DEBUG) Log.d(TAG, "setHidingNavigationConfirmationVisible " + visible); + if (visible && + mHidingNavigationConfirmation == null && !mHidingNavigationConfirmationDismissed) { // create the confirmation toast bar - int msg = R.string.hideybar_confirmation_message; - mHideybarConfirmation = Toast.makeBar(mContext, msg, Toast.LENGTH_INFINITE) - .setAction(com.android.internal.R.string.ok, mHideybarConfirmationAction); - View v = mHideybarConfirmation.getView(); + int msg = R.string.hiding_navigation_confirmation_message; + mHidingNavigationConfirmation = Toast.makeBar(mContext, msg, Toast.LENGTH_INFINITE) + .setAction(com.android.internal.R.string.ok, + mHidingNavigationConfirmationAction); + View v = mHidingNavigationConfirmation.getView(); v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); boolean isGloballyConfirmed = Prefs.read(mContext) - .getBoolean(Prefs.HIDEYBAR_CONFIRMED, false); + .getBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, false); if (isGloballyConfirmed) { // dismiss on outside touch if globally confirmed - v.setOnTouchListener(mDismissHideybarConfirmationOnTouchOutside); + v.setOnTouchListener(mDismissHidingNavigationConfirmationOnTouchOutside); } // position at the bottom like normal toasts, but use top gravity // to avoid jumping around when showing/hiding the nav bar v.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int offsetY = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.toast_y_offset); - mHideybarConfirmation.setGravity(Gravity.TOP, + mHidingNavigationConfirmation.setGravity(Gravity.TOP, 0, mCurrentDisplaySize.y - v.getMeasuredHeight() / 2 - offsetY); // show the confirmation - mHideybarConfirmation.show(); + mHidingNavigationConfirmation.show(); } else if (!visible) { - dismissHideybarConfirmation(); + dismissHidingNavigationConfirmation(); } } @@ -1985,7 +2013,7 @@ public class PhoneStatusBar extends BaseStatusBar { @Override public void suspendAutohide() { mHandler.removeCallbacks(mAutohide); - mAutohideSuspended = 0 != (mSystemUiVisibility & STATUS_OR_NAV_OVERLAY); + mAutohideSuspended = 0 != (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT); } private void cancelAutohide() { @@ -1999,7 +2027,7 @@ public class PhoneStatusBar extends BaseStatusBar { } private void checkUserAutohide(View v, MotionEvent event) { - if ((mSystemUiVisibility & STATUS_OR_NAV_OVERLAY) != 0 // an overlay bar is revealed + if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar && event.getX() == 0 && event.getY() == 0 // a touch outside both bars ) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java index d03f6ce2c68a..3d51f209798d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java @@ -25,7 +25,7 @@ public class Prefs { public static final String SHOWN_COMPAT_MODE_HELP = "shown_compat_mode_help"; public static final String SHOWN_QUICK_SETTINGS_HELP = "shown_quick_settings_help"; - public static final String HIDEYBAR_CONFIRMED = "hideybar_confirmed"; + public static final String HIDING_NAVIGATION_CONFIRMED = "hiding_navigation_confirmed"; public static SharedPreferences read(Context context) { return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 2dfe6af72fce..f83b017c50ed 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -164,7 +164,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { * of the screen to change. */ static final int SYSTEM_UI_CHANGING_LAYOUT = - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS + | View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION; /** * Keyguard stuff @@ -526,7 +529,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Settings.Secure.DEFAULT_INPUT_METHOD), false, this, UserHandle.USER_ALL); resolver.registerContentObserver(Settings.System.getUriFor( - OverlayTesting.ENABLED_SETTING), false, this, + ImmersiveModeTesting.ENABLED_SETTING), false, this, UserHandle.USER_ALL); updateSettings(); } @@ -550,11 +553,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { } MyOrientationListener mOrientationListener; - private static final int HIDEYBAR_NONE = 0; - private static final int HIDEYBAR_SHOWING = 1; - private static final int HIDEYBAR_HIDING = 2; - private int mStatusHideybar; - private int mNavigationHideybar; + private static final int TRANSIENT_BAR_NONE = 0; + private static final int TRANSIENT_BAR_SHOWING = 1; + private static final int TRANSIENT_BAR_HIDING = 2; + private int mStatusTransientBar; + private int mNavigationTransientBar; private SystemGesturesPointerEventListener mSystemGestures; @@ -917,25 +920,25 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public void onSwipeFromTop() { if (mStatusBar != null) { - requestHideybars(mStatusBar); + requestTransientBars(mStatusBar); } } @Override public void onSwipeFromBottom() { if (mNavigationBar != null && mNavigationBarOnBottom) { - requestHideybars(mNavigationBar); + requestTransientBars(mNavigationBar); } } @Override public void onSwipeFromRight() { if (mNavigationBar != null && !mNavigationBarOnBottom) { - requestHideybars(mNavigationBar); + requestTransientBars(mNavigationBar); } } @Override public void onDebug() { - if (OverlayTesting.enabled) { - OverlayTesting.toggleForceOverlay(mFocusedWindow, mContext); + if (ImmersiveModeTesting.enabled) { + ImmersiveModeTesting.toggleForceImmersiveMode(mFocusedWindow, mContext); } } }); @@ -1152,8 +1155,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mHasSoftInput = hasSoftInput; updateRotation = true; } - OverlayTesting.enabled = Settings.System.getIntForUser(resolver, - OverlayTesting.ENABLED_SETTING, 0, UserHandle.USER_CURRENT) != 0; + ImmersiveModeTesting.enabled = Settings.System.getIntForUser(resolver, + ImmersiveModeTesting.ENABLED_SETTING, 0, UserHandle.USER_CURRENT) != 0; } if (updateRotation) { updateRotation(true); @@ -2541,14 +2544,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public int adjustSystemUiVisibilityLw(int visibility) { - if (mStatusBar != null && mStatusHideybar == HIDEYBAR_SHOWING && - 0 == (visibility & View.STATUS_BAR_OVERLAY)) { - mStatusHideybar = HIDEYBAR_HIDING; + if (mStatusBar != null && mStatusTransientBar == TRANSIENT_BAR_SHOWING && + 0 == (visibility & View.STATUS_BAR_TRANSIENT)) { + mStatusTransientBar = TRANSIENT_BAR_HIDING; setBarShowingLw(mStatusBar, false); } - if (mNavigationBar != null && mNavigationHideybar == HIDEYBAR_SHOWING && - 0 == (visibility & View.NAVIGATION_BAR_OVERLAY)) { - mNavigationHideybar = HIDEYBAR_HIDING; + if (mNavigationBar != null && mNavigationTransientBar == TRANSIENT_BAR_SHOWING && + 0 == (visibility & View.NAVIGATION_BAR_TRANSIENT)) { + mNavigationTransientBar = TRANSIENT_BAR_HIDING; setBarShowingLw(mNavigationBar, false); } // Reset any bits in mForceClearingStatusBarVisibility that @@ -2678,14 +2681,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (isDefaultDisplay) { // For purposes of putting out fake window up to steal focus, we will // drive nav being hidden only by whether it is requested. - boolean navVisible = (mLastSystemUiFlags&View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; - boolean overlayAllowed = (mLastSystemUiFlags&View.SYSTEM_UI_FLAG_ALLOW_OVERLAY) != 0; + final int sysui = mLastSystemUiFlags; + boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; + boolean navTransparent = (sysui & View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION) != 0; + boolean transientAllowed = (sysui & View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT) != 0; + navTransparent &= !transientAllowed; // transient trumps transparent // When the navigation bar isn't visible, we put up a fake // input window to catch all touch events. This way we can // detect when the user presses anywhere to bring back the nav // bar and ensure the application doesn't see the event. - if (navVisible || overlayAllowed) { + if (navVisible || transientAllowed) { if (mHideNavFakeWindow != null) { mHideNavFakeWindow.dismiss(); mHideNavFakeWindow = null; @@ -2704,7 +2710,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean updateSysUiVisibility = false; if (mNavigationBar != null) { - boolean navBarHideyShowing = mNavigationHideybar == HIDEYBAR_SHOWING; + boolean transientNavBarShowing = mNavigationTransientBar == TRANSIENT_BAR_SHOWING; // Force the navigation bar to its appropriate place and // size. We need to do this directly, instead of relying on // it to bubble up from the nav bar, because this needs to @@ -2716,7 +2722,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { - mNavigationBarHeightForRotation[displayRotation]; mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; - if (navBarHideyShowing) { + if (transientNavBarShowing || navTransparent) { setBarShowingLw(mNavigationBar, true); } else if (navVisible) { setBarShowingLw(mNavigationBar, true); @@ -2727,8 +2733,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // We currently want to hide the navigation UI. setBarShowingLw(mNavigationBar, false); } - if (navVisible && !mNavigationBar.isAnimatingLw()) { - // If the nav bar is currently requested to be visible, + if (navVisible && !navTransparent && !mNavigationBar.isAnimatingLw()) { + // If the opaque nav bar is currently requested to be visible, // and not in the process of animating on or off, then // we can tell the app that it is covered by it. mSystemBottom = mTmpNavigationFrame.top; @@ -2739,7 +2745,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { - mNavigationBarWidthForRotation[displayRotation]; mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; - if (navBarHideyShowing) { + if (transientNavBarShowing || navTransparent) { setBarShowingLw(mNavigationBar, true); } else if (navVisible) { setBarShowingLw(mNavigationBar, true); @@ -2750,7 +2756,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // We currently want to hide the navigation UI. setBarShowingLw(mNavigationBar, false); } - if (navVisible && !mNavigationBar.isAnimatingLw()) { + if (navVisible && !navTransparent && !mNavigationBar.isAnimatingLw()) { // If the nav bar is currently requested to be visible, // and not in the process of animating on or off, then // we can tell the app that it is covered by it. @@ -2768,9 +2774,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame); if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); - if (mNavigationHideybar == HIDEYBAR_HIDING && !mNavigationBar.isVisibleLw()) { + if (mNavigationTransientBar == TRANSIENT_BAR_HIDING && !mNavigationBar.isVisibleLw()) { // Finished animating out, clean up and reset alpha - mNavigationHideybar = HIDEYBAR_NONE; + mNavigationTransientBar = TRANSIENT_BAR_NONE; updateSysUiVisibility = true; } } @@ -2798,11 +2804,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { // For layout, the status bar is always at the top with our fixed height. mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; - boolean statusBarOverlay = (mLastSystemUiFlags & View.STATUS_BAR_OVERLAY) != 0; + boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; + boolean statusBarTransparent = (sysui & View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS) != 0; // If the status bar is hidden, we don't want to cause // windows behind it to scroll. - if (mStatusBar.isVisibleLw() && !statusBarOverlay) { + if (mStatusBar.isVisibleLw() && !statusBarTransient && !statusBarTransparent) { // Status bar may go away, so the screen area it occupies // is available to apps but just covering them when the // status bar is visible. @@ -2820,16 +2827,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { mContentLeft, mContentTop, mContentRight, mContentBottom, mCurLeft, mCurTop, mCurRight, mCurBottom)); } - if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() && !statusBarOverlay) { - // If the status bar is currently requested to be visible, + if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() + && !statusBarTransient && !statusBarTransparent) { + // If the opaque status bar is currently requested to be visible, // and not in the process of animating on or off, then // we can tell the app that it is covered by it. mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; } - if (mStatusHideybar == HIDEYBAR_HIDING && !mStatusBar.isVisibleLw()) { + if (mStatusTransientBar == TRANSIENT_BAR_HIDING && !mStatusBar.isVisibleLw()) { // Finished animating out, clean up and reset alpha - mStatusHideybar = HIDEYBAR_NONE; + mStatusTransientBar = TRANSIENT_BAR_NONE; updateSysUiVisibility = true; } } @@ -3411,7 +3419,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the // case though. - if (mStatusHideybar == HIDEYBAR_SHOWING) { + if (mStatusTransientBar == TRANSIENT_BAR_SHOWING) { if (setBarShowingLw(mStatusBar, true)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; } @@ -4135,32 +4143,32 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }; - private void requestHideybars(WindowState swipeTarget) { + private void requestTransientBars(WindowState swipeTarget) { synchronized (mWindowManagerFuncs.getWindowManagerLock()) { - boolean sb = checkShowHideybar("status", mStatusHideybar, mStatusBar); - boolean nb = checkShowHideybar("navigation", mNavigationHideybar, mNavigationBar); + boolean sb = checkShowTransientBar("status", mStatusTransientBar, mStatusBar); + boolean nb = checkShowTransientBar("nav", mNavigationTransientBar, mNavigationBar); if (sb || nb) { - WindowState hideyTarget = sb ? mStatusBar : mNavigationBar; - if (sb ^ nb && hideyTarget != swipeTarget) { - if (DEBUG) Slog.d(TAG, "Not showing hideybar, wrong swipe target"); + WindowState barTarget = sb ? mStatusBar : mNavigationBar; + if (sb ^ nb && barTarget != swipeTarget) { + if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); return; } - mStatusHideybar = sb ? HIDEYBAR_SHOWING : mStatusHideybar; - mNavigationHideybar = nb ? HIDEYBAR_SHOWING : mNavigationHideybar; + mStatusTransientBar = sb ? TRANSIENT_BAR_SHOWING : mStatusTransientBar; + mNavigationTransientBar = nb ? TRANSIENT_BAR_SHOWING : mNavigationTransientBar; updateSystemUiVisibilityLw(); } } } - private boolean checkShowHideybar(String tag, int hideybar, WindowState win) { - if (hideybar == HIDEYBAR_SHOWING) { - if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, already shown"); + private boolean checkShowTransientBar(String tag, int transientBar, WindowState win) { + if (transientBar == TRANSIENT_BAR_SHOWING) { + if (DEBUG) Slog.d(TAG, "Not showing " + tag + " transient bar, already shown"); return false; } else if (win == null) { - if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, bar doesn't exist"); + if (DEBUG) Slog.d(TAG, "Not showing " + tag + " transient bar, bar doesn't exist"); return false; } else if (win.isDisplayedLw()) { - if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, bar already visible"); + if (DEBUG) Slog.d(TAG, "Not showing " + tag + " transient bar, bar already visible"); return false; } else { return true; @@ -5009,7 +5017,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mForcingShowNavBar && mFocusedWindow.getSurfaceLayer() < mForcingShowNavBarLayer) { tmpVisibility &= ~View.SYSTEM_UI_CLEARABLE_FLAGS; } - final int visibility = updateHideybarsLw(tmpVisibility); + final int visibility = updateTransientBarsLw(tmpVisibility); final int diff = visibility ^ mLastSystemUiFlags; final boolean needsMenu = mFocusedWindow.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); if (diff == 0 && mLastFocusNeedsMenu == needsMenu @@ -5037,35 +5045,34 @@ public class PhoneWindowManager implements WindowManagerPolicy { return diff; } - private int updateHideybarsLw(int tmpVisibility) { - if (OverlayTesting.enabled) { - tmpVisibility = OverlayTesting.applyForced(mFocusedWindow, tmpVisibility); + private int updateTransientBarsLw(int vis) { + if (ImmersiveModeTesting.enabled) { + vis = ImmersiveModeTesting.applyForced(mFocusedWindow, vis); } - boolean statusBarHasFocus = - mFocusedWindow.getAttrs().type == TYPE_STATUS_BAR; + boolean statusBarHasFocus = mFocusedWindow.getAttrs().type == TYPE_STATUS_BAR; if (statusBarHasFocus) { // prevent status bar interaction from clearing certain flags int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_ALLOW_OVERLAY; - tmpVisibility = (tmpVisibility & ~flags) | (mLastSystemUiFlags & flags); + | View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT; + vis = (vis & ~flags) | (mLastSystemUiFlags & flags); } - boolean overlayAllowed = (tmpVisibility & View.SYSTEM_UI_FLAG_ALLOW_OVERLAY) != 0; - if (mStatusHideybar == HIDEYBAR_SHOWING) { - // status hideybar requested + boolean transientAllowed = (vis & View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT) != 0; + if (mStatusTransientBar == TRANSIENT_BAR_SHOWING) { + // status transient bar requested boolean hideStatusBarWM = (mFocusedWindow.getAttrs().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; boolean hideStatusBarSysui = - (tmpVisibility & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; + (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; - boolean statusHideyAllowed = + boolean transientStatusBarAllowed = hideStatusBarWM - || (hideStatusBarSysui && overlayAllowed) + || (hideStatusBarSysui && transientAllowed) || statusBarHasFocus; - if (mStatusBar == null || !statusHideyAllowed) { - mStatusHideybar = HIDEYBAR_NONE; + if (mStatusBar == null || !transientStatusBarAllowed) { + mStatusTransientBar = TRANSIENT_BAR_NONE; if (mStatusBar != null && hideStatusBarSysui) { // clear the clearable flags instead int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; @@ -5075,32 +5082,32 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } else { - // show status hideybar - tmpVisibility |= View.STATUS_BAR_OVERLAY; - if ((mLastSystemUiFlags & View.STATUS_BAR_OVERLAY) == 0) { - tmpVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; + // show status transient bar + vis |= View.STATUS_BAR_TRANSIENT; + if ((mLastSystemUiFlags & View.STATUS_BAR_TRANSIENT) == 0) { + vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; setBarShowingLw(mStatusBar, true); } } } - if (mNavigationHideybar == HIDEYBAR_SHOWING) { - // navigation hideybar requested + if (mNavigationTransientBar == TRANSIENT_BAR_SHOWING) { + // navigation transient bar requested boolean hideNavigationBarSysui = - (tmpVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; - boolean navigationHideyAllowed = - hideNavigationBarSysui && overlayAllowed && mNavigationBar != null; - if (!navigationHideyAllowed) { - mNavigationHideybar = HIDEYBAR_NONE; + (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; + boolean transientNavigationBarAllowed = + mNavigationBar != null && hideNavigationBarSysui && transientAllowed; + if (!transientNavigationBarAllowed) { + mNavigationTransientBar = TRANSIENT_BAR_NONE; } else { - // show navigation hideybar - tmpVisibility |= View.NAVIGATION_BAR_OVERLAY; - if ((mLastSystemUiFlags & View.NAVIGATION_BAR_OVERLAY) == 0) { - tmpVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; + // show navigation transient bar + vis |= View.NAVIGATION_BAR_TRANSIENT; + if ((mLastSystemUiFlags & View.NAVIGATION_BAR_TRANSIENT) == 0) { + vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; setBarShowingLw(mNavigationBar, true); } } } - return tmpVisibility; + return vis; } private boolean setBarShowingLw(WindowState win, final boolean show) { @@ -5129,9 +5136,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { return show ? win.showLw(true) : win.hideLw(true); } - // TODO temporary helper that allows testing overlay bars on existing apps - private static final class OverlayTesting { - static String ENABLED_SETTING = "overlay_testing_enabled"; + // Temporary helper that allows testing immersive mode on existing apps + // TODO remove + private static final class ImmersiveModeTesting { + static String ENABLED_SETTING = "immersive_mode_testing_enabled"; static boolean enabled = false; private static final HashSet<String> sForced = new HashSet<String>(); @@ -5153,21 +5161,21 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (sForced.contains(parseActivity(focused))) { vis |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_ALLOW_OVERLAY; + View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT; } return vis; } - public static void toggleForceOverlay(WindowState focused, Context context) { + public static void toggleForceImmersiveMode(WindowState focused, Context context) { String activity = parseActivity(focused); if (activity != null) { String action; if (sForced.contains(activity)) { sForced.remove(activity); - action = "Force overlay disabled"; + action = "Force immersive mode disabled"; } else { sForced.add(activity); - action = "Force overlay enabled"; + action = "Force immersive mode enabled"; } android.widget.Toast.makeText(context, action + " for " + activity, android.widget.Toast.LENGTH_SHORT).show(); |