Merge "Ensure background is shown behind gear when notifications overlap" into nyc-dev am: 048cabdbcb

am: 573c36a484

* commit '573c36a484f77d2bb41aa851ddce29c5b73302e4':
  Ensure background is shown behind gear when notifications overlap

Change-Id: I88d26ac1012d63215f209ee79e644785f8603a1b
This commit is contained in:
Mady Mellor
2016-05-18 16:53:52 +00:00
committed by android-build-merger
8 changed files with 15 additions and 103 deletions

View File

@@ -38,7 +38,6 @@ public abstract class ExpandableView extends FrameLayout {
protected int mClipTopAmount;
private boolean mDark;
private ArrayList<View> mMatchParentViews = new ArrayList<View>();
private int mClipTopOptimization;
private static Rect mClipRect = new Rect();
private boolean mWillBeGone;
private int mMinClipTopAmount = 0;
@@ -218,6 +217,7 @@ public abstract class ExpandableView extends FrameLayout {
*/
public void setClipTopAmount(int clipTopAmount) {
mClipTopAmount = clipTopAmount;
updateClipping();
}
public int getClipTopAmount() {
@@ -306,7 +306,7 @@ public abstract class ExpandableView extends FrameLayout {
public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
super.getBoundsOnScreen(outRect, clipToParent);
outRect.bottom = outRect.top + getActualHeight();
outRect.top += getClipTopOptimization();
outRect.top += getClipTopAmount();
}
public boolean isSummaryWithChildren() {
@@ -319,7 +319,7 @@ public abstract class ExpandableView extends FrameLayout {
private void updateClipping() {
if (mClipToActualHeight) {
int top = mClipTopOptimization;
int top = getClipTopAmount();
if (top >= getActualHeight()) {
top = getActualHeight() - 1;
}
@@ -335,21 +335,6 @@ public abstract class ExpandableView extends FrameLayout {
updateClipping();
}
public int getClipTopOptimization() {
return mClipTopOptimization;
}
/**
* Set that the view will be clipped by a given amount from the top. Contrary to
* {@link #setClipTopAmount} this amount doesn't effect shadows and the background.
*
* @param clipTopOptimization the amount to clip from the top
*/
public void setClipTopOptimization(int clipTopOptimization) {
mClipTopOptimization = clipTopOptimization;
updateClipping();
}
public boolean willBeGone() {
return mWillBeGone;
}

View File

@@ -430,7 +430,6 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) {
return notificationGroup.summary == null
|| notificationGroup.summary.row.getClipTopOptimization() > 0
|| notificationGroup.summary.row.getClipTopAmount() > 0
|| notificationGroup.summary.row.getTranslationY() < 0;
}

View File

@@ -393,7 +393,6 @@ public class NotificationChildrenContainer extends ViewGroup {
childState.hideSensitive = parentState.hideSensitive;
childState.belowSpeedBump = parentState.belowSpeedBump;
childState.clipTopAmount = 0;
childState.topOverLap = 0;
childState.alpha = 0;
if (i < firstOverflowIndex) {
childState.alpha = 1;

View File

@@ -2214,7 +2214,7 @@ public class NotificationStackScrollLayout extends ViewGroup
updateAnimationState(false, child);
// Make sure the clipRect we might have set is removed
expandableView.setClipTopOptimization(0);
expandableView.setClipTopAmount(0);
}
private boolean isChildInGroup(View child) {
@@ -3398,9 +3398,6 @@ public class NotificationStackScrollLayout extends ViewGroup
public void setDismissAllInProgress(boolean dismissAllInProgress) {
mDismissAllInProgress = dismissAllInProgress;
mAmbientState.setDismissAllInProgress(dismissAllInProgress);
if (dismissAllInProgress) {
disableClipOptimization();
}
handleDismissAllClipping();
}
@@ -3421,17 +3418,6 @@ public class NotificationStackScrollLayout extends ViewGroup
}
}
private void disableClipOptimization() {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
ExpandableView child = (ExpandableView) getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
child.setClipTopOptimization(0);
}
}
public boolean isDismissViewNotGone() {
return mDismissView.getVisibility() != View.GONE && !mDismissView.willBeGone();
}

View File

@@ -138,11 +138,9 @@ public class StackScrollAlgorithm {
private void updateClipping(StackScrollState resultState,
StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
boolean dismissAllInProgress = ambientState.isDismissAllInProgress();
float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation();
float previousNotificationEnd = 0;
float previousNotificationStart = 0;
boolean previousNotificationIsSwiped = false;
int childCount = algorithmState.visibleChildren.size();
for (int i = 0; i < childCount; i++) {
ExpandableView child = algorithmState.visibleChildren.get(i);
@@ -153,36 +151,21 @@ public class StackScrollAlgorithm {
}
float newYTranslation = state.yTranslation;
float newHeight = state.height;
// apply clipping and shadow
float newNotificationEnd = newYTranslation + newHeight;
float clipHeight;
if (previousNotificationIsSwiped) {
// When the previous notification is swiped, we don't clip the content to the
// bottom of it.
clipHeight = newHeight;
if (newYTranslation < previousNotificationEnd) {
// The previous view is overlapping on top, clip!
float overlapAmount = previousNotificationEnd - newYTranslation;
state.clipTopAmount = (int) overlapAmount;
} else {
clipHeight = newNotificationEnd - previousNotificationEnd;
clipHeight = Math.max(0.0f, clipHeight);
}
updateChildClippingAndBackground(state, newHeight, clipHeight,
newHeight - (previousNotificationStart - newYTranslation));
if (dismissAllInProgress) {
state.clipTopAmount = Math.max(child.getMinClipTopAmount(), state.clipTopAmount);
state.clipTopAmount = 0;
}
if (!child.isTransparent()) {
// Only update the previous values if we are not transparent,
// otherwise we would clip to a transparent view.
if ((dismissAllInProgress && canChildBeDismissed(child))) {
previousNotificationIsSwiped = true;
} else {
previousNotificationIsSwiped = ambientState.getDraggedViews().contains(child);
previousNotificationEnd = newNotificationEnd;
previousNotificationStart =newYTranslation + state.clipTopAmount;
}
previousNotificationEnd = newNotificationEnd;
previousNotificationStart = newYTranslation;
}
}
}
@@ -192,31 +175,6 @@ public class StackScrollAlgorithm {
return (veto != null && veto.getVisibility() != View.GONE);
}
/**
* Updates the shadow outline and the clipping for a view.
*
* @param state the viewState to update
* @param realHeight the currently applied height of the view
* @param clipHeight the desired clip height, the rest of the view will be clipped from the top
* @param backgroundHeight the desired background height. The shadows of the view will be
* based on this height and the content will be clipped from the top
*/
private void updateChildClippingAndBackground(StackViewState state, float realHeight,
float clipHeight, float backgroundHeight) {
if (realHeight > clipHeight) {
// Rather overlap than create a hole.
state.topOverLap = (int) Math.floor(realHeight - clipHeight);
} else {
state.topOverLap = 0;
}
if (realHeight > backgroundHeight) {
// Rather overlap than create a hole.
state.clipTopAmount = (int) Math.floor(realHeight - backgroundHeight);
} else {
state.clipTopAmount = 0;
}
}
/**
* Updates the dimmed, activated and hiding sensitive states of the children.
*/

View File

@@ -110,11 +110,11 @@ public class StackScrollState {
}
if (child instanceof DismissView) {
DismissView dismissView = (DismissView) child;
boolean visible = state.topOverLap < mClearAllTopPadding;
boolean visible = state.clipTopAmount < mClearAllTopPadding;
dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
} else if (child instanceof EmptyShadeView) {
EmptyShadeView emptyShadeView = (EmptyShadeView) child;
boolean visible = state.topOverLap <= 0;
boolean visible = state.clipTopAmount <= 0;
emptyShadeView.performVisibilityAnimation(
visible && !emptyShadeView.willBeGone());
}
@@ -171,10 +171,6 @@ public class StackScrollState {
if (oldClipTopAmount != state.clipTopAmount) {
view.setClipTopAmount(state.clipTopAmount);
}
float oldClipTopOptimization = view.getClipTopOptimization();
if (oldClipTopOptimization != state.topOverLap) {
view.setClipTopOptimization(state.topOverLap);
}
if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
row.applyChildrenState(this);

View File

@@ -91,7 +91,6 @@ public class StackStateAnimator {
private int mCurrentLastNotAddedIndex;
private ValueAnimator mTopOverScrollAnimator;
private ValueAnimator mBottomOverScrollAnimator;
private ExpandableNotificationRow mChildExpandingView;
private int mHeadsUpAppearHeightBottom;
private boolean mShadeExpanded;
private ArrayList<View> mChildrenToClearFromOverlay = new ArrayList<>();
@@ -128,7 +127,6 @@ public class StackStateAnimator {
continue;
}
child.setClipTopOptimization(0);
startStackAnimations(child, viewState, finalState, i, -1 /* fixedDelay */);
}
if (!isRunning()) {
@@ -139,7 +137,6 @@ public class StackStateAnimator {
mHeadsUpDisappearChildren.clear();
mNewEvents.clear();
mNewAddChildren.clear();
mChildExpandingView = null;
}
/**
@@ -871,7 +868,6 @@ public class StackStateAnimator {
.AnimationEvent.ANIMATION_TYPE_GROUP_EXPANSION_CHANGED) {
ExpandableNotificationRow row = (ExpandableNotificationRow) event.changingView;
row.prepareExpansionChanged(finalState);
mChildExpandingView = row;
} else if (event.animationType == NotificationStackScrollLayout
.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR) {
// This item is added, initialize it's properties.

View File

@@ -40,17 +40,11 @@ public class StackViewState extends ViewState {
public float shadowAlpha;
/**
* The amount which the view should be clipped from the top. This is calculated to
* perceive consistent shadows.
* How much the child overlaps with the previous child on top. This is used to
* show the background properly when the child on top is translating away.
*/
public int clipTopAmount;
/**
* How much does the child overlap with the previous view on the top? Can be used for
* a clipping optimization
*/
public int topOverLap;
/**
* The index of the view, only accounting for views not equal to GONE
*/
@@ -75,7 +69,6 @@ public class StackViewState extends ViewState {
hideSensitive = svs.hideSensitive;
belowSpeedBump = svs.belowSpeedBump;
clipTopAmount = svs.clipTopAmount;
topOverLap = svs.topOverLap;
notGoneIndex = svs.notGoneIndex;
location = svs.location;
}