diff options
author | Adrian Roos <roosa@google.com> | 2015-05-26 18:30:37 -0700 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2015-06-01 15:42:26 -0700 |
commit | 8a8ffd4e9b15a04d2af0909205658f08c76bd6b2 (patch) | |
tree | 16f9ef2cc03e827fdaf4892191a447771aed0b3f /core/java/com | |
parent | 6920474bac7c212dd384b6ef1134c59b73669942 (diff) | |
download | frameworks_base-8a8ffd4e9b15a04d2af0909205658f08c76bd6b2.zip frameworks_base-8a8ffd4e9b15a04d2af0909205658f08c76bd6b2.tar.gz frameworks_base-8a8ffd4e9b15a04d2af0909205658f08c76bd6b2.tar.bz2 |
Translucent bars in landscape
Bug: 18739556
Change-Id: Ib9602a9d1f09e6bd6c1306927990676120dff012
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/policy/PhoneWindow.java | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index a04218a..22c0680 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -2219,12 +2219,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private final ColorViewState mStatusColorViewState = new ColorViewState( SYSTEM_UI_FLAG_FULLSCREEN, FLAG_TRANSLUCENT_STATUS, Gravity.TOP, + Gravity.LEFT, STATUS_BAR_BACKGROUND_TRANSITION_NAME, com.android.internal.R.id.statusBarBackground, FLAG_FULLSCREEN); private final ColorViewState mNavigationColorViewState = new ColorViewState( SYSTEM_UI_FLAG_HIDE_NAVIGATION, FLAG_TRANSLUCENT_NAVIGATION, Gravity.BOTTOM, + Gravity.RIGHT, NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME, com.android.internal.R.id.navigationBarBackground, 0 /* hideWindowFlag */); @@ -2240,6 +2242,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private int mLastRightInset = 0; private boolean mLastHasTopStableInset = false; private boolean mLastHasBottomStableInset = false; + private boolean mLastHasRightStableInset = false; private int mLastWindowFlags = 0; private int mRootScrollY = 0; @@ -2882,12 +2885,19 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { boolean hasBottomStableInset = insets.getStableInsetBottom() != 0; disallowAnimate |= (hasBottomStableInset != mLastHasBottomStableInset); mLastHasBottomStableInset = hasBottomStableInset; + + boolean hasRightStableInset = insets.getStableInsetRight() != 0; + disallowAnimate |= (hasRightStableInset != mLastHasRightStableInset); + mLastHasRightStableInset = hasRightStableInset; } updateColorViewInt(mStatusColorViewState, sysUiVisibility, mStatusBarColor, - mLastTopInset, animate && !disallowAnimate); + mLastTopInset, false /* matchVertical */, animate && !disallowAnimate); + + boolean navBarToRightEdge = mLastBottomInset == 0 && mLastRightInset > 0; + int navBarSize = navBarToRightEdge ? mLastRightInset : mLastBottomInset; updateColorViewInt(mNavigationColorViewState, sysUiVisibility, mNavigationBarColor, - mLastBottomInset, animate && !disallowAnimate); + navBarSize, navBarToRightEdge, animate && !disallowAnimate); } // When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, we still need @@ -2931,9 +2941,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return insets; } + /** + * Update a color view + * + * @param state the color view to update. + * @param sysUiVis the current systemUiVisibility to apply. + * @param color the current color to apply. + * @param size the current size in the non-parent-matching dimension. + * @param verticalBar if true the view is attached to a vertical edge, otherwise to a + * horizontal edge, + * @param animate if true, the change will be animated. + */ private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color, - int height, boolean animate) { - boolean show = height > 0 && (sysUiVis & state.systemUiHideFlag) == 0 + int size, boolean verticalBar, boolean animate) { + boolean show = size > 0 && (sysUiVis & state.systemUiHideFlag) == 0 && (getAttributes().flags & state.hideWindowFlag) == 0 && (getAttributes().flags & state.translucentFlag) == 0 && (color & Color.BLACK) != 0 @@ -2942,6 +2963,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { boolean visibilityChanged = false; View view = state.view; + int resolvedHeight = verticalBar ? LayoutParams.MATCH_PARENT : size; + int resolvedWidth = verticalBar ? size : LayoutParams.MATCH_PARENT; + int resolvedGravity = verticalBar ? state.horizontalGravity : state.verticalGravity; + if (view == null) { if (show) { state.view = view = new View(mContext); @@ -2952,8 +2977,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { view.setVisibility(INVISIBLE); state.targetVisibility = VISIBLE; - addView(view, new LayoutParams(LayoutParams.MATCH_PARENT, height, - Gravity.START | state.verticalGravity)); + addView(view, new LayoutParams(resolvedWidth, resolvedHeight, resolvedGravity)); updateColorViewTranslations(); } } else { @@ -2962,8 +2986,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { state.targetVisibility = vis; if (show) { LayoutParams lp = (LayoutParams) view.getLayoutParams(); - if (lp.height != height) { - lp.height = height; + if (lp.height != resolvedHeight || lp.width != resolvedWidth + || lp.gravity != resolvedGravity) { + lp.height = resolvedHeight; + lp.width = resolvedWidth; + lp.gravity = resolvedGravity; view.setLayoutParams(lp); } view.setBackgroundColor(color); @@ -4878,16 +4905,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { final int systemUiHideFlag; final int translucentFlag; final int verticalGravity; + final int horizontalGravity; final String transitionName; final int hideWindowFlag; ColorViewState(int systemUiHideFlag, - int translucentFlag, int verticalGravity, + int translucentFlag, int verticalGravity, int horizontalGravity, String transitionName, int id, int hideWindowFlag) { this.id = id; this.systemUiHideFlag = systemUiHideFlag; this.translucentFlag = translucentFlag; this.verticalGravity = verticalGravity; + this.horizontalGravity = horizontalGravity; this.transitionName = transitionName; this.hideWindowFlag = hideWindowFlag; } |