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 | |
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
3 files changed, 40 insertions, 34 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; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java index a712d29..134c579 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java @@ -33,8 +33,6 @@ public final class NavigationBarTransitions extends BarTransitions { private final IStatusBarService mBarService; private boolean mLightsOut; - private boolean mVertical; - private int mRequestedMode; public NavigationBarTransitions(NavigationBarView view) { super(view, R.drawable.nav_background); @@ -43,31 +41,11 @@ public final class NavigationBarTransitions extends BarTransitions { ServiceManager.getService(Context.STATUS_BAR_SERVICE)); } - public void init(boolean isVertical) { - setVertical(isVertical); + public void init() { applyModeBackground(-1, getMode(), false /*animate*/); applyMode(getMode(), false /*animate*/, true /*force*/); } - public void setVertical(boolean isVertical) { - mVertical = isVertical; - transitionTo(mRequestedMode, false /*animate*/); - } - - @Override - public void transitionTo(int mode, boolean animate) { - mRequestedMode = mode; - if (mVertical) { - // translucent mode not allowed when vertical - if (mode == MODE_TRANSLUCENT || mode == MODE_TRANSPARENT) { - mode = MODE_OPAQUE; - } else if (mode == MODE_LIGHTS_OUT_TRANSPARENT) { - mode = MODE_LIGHTS_OUT; - } - } - super.transitionTo(mode, animate); - } - @Override protected void onTransition(int oldMode, int newMode, boolean animate) { super.onTransition(oldMode, newMode, animate); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 1dec227..636c511 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -47,7 +47,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import com.android.systemui.R; -import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.DelegateViewHelper; import com.android.systemui.statusbar.policy.DeadZone; import com.android.systemui.statusbar.policy.KeyButtonView; @@ -454,7 +453,7 @@ public class NavigationBarView extends LinearLayout { mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone); // force the low profile & disabled states into compliance - mBarTransitions.init(mVertical); + mBarTransitions.init(); setDisabledFlags(mDisabledFlags, true /* force */); setMenuVisibility(mShowMenu, true /* force */); |