Merge "Translucent bars in landscape" into mnc-dev

This commit is contained in:
Adrian Roos
2015-06-01 23:25:33 +00:00
committed by Android (Google) Code Review
3 changed files with 40 additions and 34 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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 */);