Merge "Ensure background is shown behind gear when notifications overlap" into nyc-dev
This commit is contained in:
@@ -38,7 +38,6 @@ public abstract class ExpandableView extends FrameLayout {
|
|||||||
protected int mClipTopAmount;
|
protected int mClipTopAmount;
|
||||||
private boolean mDark;
|
private boolean mDark;
|
||||||
private ArrayList<View> mMatchParentViews = new ArrayList<View>();
|
private ArrayList<View> mMatchParentViews = new ArrayList<View>();
|
||||||
private int mClipTopOptimization;
|
|
||||||
private static Rect mClipRect = new Rect();
|
private static Rect mClipRect = new Rect();
|
||||||
private boolean mWillBeGone;
|
private boolean mWillBeGone;
|
||||||
private int mMinClipTopAmount = 0;
|
private int mMinClipTopAmount = 0;
|
||||||
@@ -218,6 +217,7 @@ public abstract class ExpandableView extends FrameLayout {
|
|||||||
*/
|
*/
|
||||||
public void setClipTopAmount(int clipTopAmount) {
|
public void setClipTopAmount(int clipTopAmount) {
|
||||||
mClipTopAmount = clipTopAmount;
|
mClipTopAmount = clipTopAmount;
|
||||||
|
updateClipping();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getClipTopAmount() {
|
public int getClipTopAmount() {
|
||||||
@@ -306,7 +306,7 @@ public abstract class ExpandableView extends FrameLayout {
|
|||||||
public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
|
public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
|
||||||
super.getBoundsOnScreen(outRect, clipToParent);
|
super.getBoundsOnScreen(outRect, clipToParent);
|
||||||
outRect.bottom = outRect.top + getActualHeight();
|
outRect.bottom = outRect.top + getActualHeight();
|
||||||
outRect.top += getClipTopOptimization();
|
outRect.top += getClipTopAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSummaryWithChildren() {
|
public boolean isSummaryWithChildren() {
|
||||||
@@ -319,7 +319,7 @@ public abstract class ExpandableView extends FrameLayout {
|
|||||||
|
|
||||||
private void updateClipping() {
|
private void updateClipping() {
|
||||||
if (mClipToActualHeight) {
|
if (mClipToActualHeight) {
|
||||||
int top = mClipTopOptimization;
|
int top = getClipTopAmount();
|
||||||
if (top >= getActualHeight()) {
|
if (top >= getActualHeight()) {
|
||||||
top = getActualHeight() - 1;
|
top = getActualHeight() - 1;
|
||||||
}
|
}
|
||||||
@@ -335,21 +335,6 @@ public abstract class ExpandableView extends FrameLayout {
|
|||||||
updateClipping();
|
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() {
|
public boolean willBeGone() {
|
||||||
return mWillBeGone;
|
return mWillBeGone;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
|
|||||||
|
|
||||||
private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) {
|
private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) {
|
||||||
return notificationGroup.summary == null
|
return notificationGroup.summary == null
|
||||||
|| notificationGroup.summary.row.getClipTopOptimization() > 0
|
|
||||||
|| notificationGroup.summary.row.getClipTopAmount() > 0
|
|| notificationGroup.summary.row.getClipTopAmount() > 0
|
||||||
|| notificationGroup.summary.row.getTranslationY() < 0;
|
|| notificationGroup.summary.row.getTranslationY() < 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -393,7 +393,6 @@ public class NotificationChildrenContainer extends ViewGroup {
|
|||||||
childState.hideSensitive = parentState.hideSensitive;
|
childState.hideSensitive = parentState.hideSensitive;
|
||||||
childState.belowSpeedBump = parentState.belowSpeedBump;
|
childState.belowSpeedBump = parentState.belowSpeedBump;
|
||||||
childState.clipTopAmount = 0;
|
childState.clipTopAmount = 0;
|
||||||
childState.topOverLap = 0;
|
|
||||||
childState.alpha = 0;
|
childState.alpha = 0;
|
||||||
if (i < firstOverflowIndex) {
|
if (i < firstOverflowIndex) {
|
||||||
childState.alpha = 1;
|
childState.alpha = 1;
|
||||||
|
|||||||
@@ -2214,7 +2214,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
updateAnimationState(false, child);
|
updateAnimationState(false, child);
|
||||||
|
|
||||||
// Make sure the clipRect we might have set is removed
|
// Make sure the clipRect we might have set is removed
|
||||||
expandableView.setClipTopOptimization(0);
|
expandableView.setClipTopAmount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isChildInGroup(View child) {
|
private boolean isChildInGroup(View child) {
|
||||||
@@ -3398,9 +3398,6 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
public void setDismissAllInProgress(boolean dismissAllInProgress) {
|
public void setDismissAllInProgress(boolean dismissAllInProgress) {
|
||||||
mDismissAllInProgress = dismissAllInProgress;
|
mDismissAllInProgress = dismissAllInProgress;
|
||||||
mAmbientState.setDismissAllInProgress(dismissAllInProgress);
|
mAmbientState.setDismissAllInProgress(dismissAllInProgress);
|
||||||
if (dismissAllInProgress) {
|
|
||||||
disableClipOptimization();
|
|
||||||
}
|
|
||||||
handleDismissAllClipping();
|
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() {
|
public boolean isDismissViewNotGone() {
|
||||||
return mDismissView.getVisibility() != View.GONE && !mDismissView.willBeGone();
|
return mDismissView.getVisibility() != View.GONE && !mDismissView.willBeGone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,11 +138,9 @@ public class StackScrollAlgorithm {
|
|||||||
|
|
||||||
private void updateClipping(StackScrollState resultState,
|
private void updateClipping(StackScrollState resultState,
|
||||||
StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
|
StackScrollAlgorithmState algorithmState, AmbientState ambientState) {
|
||||||
boolean dismissAllInProgress = ambientState.isDismissAllInProgress();
|
|
||||||
float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation();
|
float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation();
|
||||||
float previousNotificationEnd = 0;
|
float previousNotificationEnd = 0;
|
||||||
float previousNotificationStart = 0;
|
float previousNotificationStart = 0;
|
||||||
boolean previousNotificationIsSwiped = false;
|
|
||||||
int childCount = algorithmState.visibleChildren.size();
|
int childCount = algorithmState.visibleChildren.size();
|
||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
ExpandableView child = algorithmState.visibleChildren.get(i);
|
ExpandableView child = algorithmState.visibleChildren.get(i);
|
||||||
@@ -153,36 +151,21 @@ public class StackScrollAlgorithm {
|
|||||||
}
|
}
|
||||||
float newYTranslation = state.yTranslation;
|
float newYTranslation = state.yTranslation;
|
||||||
float newHeight = state.height;
|
float newHeight = state.height;
|
||||||
// apply clipping and shadow
|
|
||||||
float newNotificationEnd = newYTranslation + newHeight;
|
float newNotificationEnd = newYTranslation + newHeight;
|
||||||
|
|
||||||
float clipHeight;
|
if (newYTranslation < previousNotificationEnd) {
|
||||||
if (previousNotificationIsSwiped) {
|
// The previous view is overlapping on top, clip!
|
||||||
// When the previous notification is swiped, we don't clip the content to the
|
float overlapAmount = previousNotificationEnd - newYTranslation;
|
||||||
// bottom of it.
|
state.clipTopAmount = (int) overlapAmount;
|
||||||
clipHeight = newHeight;
|
|
||||||
} else {
|
} else {
|
||||||
clipHeight = newNotificationEnd - previousNotificationEnd;
|
state.clipTopAmount = 0;
|
||||||
clipHeight = Math.max(0.0f, clipHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateChildClippingAndBackground(state, newHeight, clipHeight,
|
|
||||||
newHeight - (previousNotificationStart - newYTranslation));
|
|
||||||
|
|
||||||
if (dismissAllInProgress) {
|
|
||||||
state.clipTopAmount = Math.max(child.getMinClipTopAmount(), state.clipTopAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!child.isTransparent()) {
|
if (!child.isTransparent()) {
|
||||||
// Only update the previous values if we are not transparent,
|
// Only update the previous values if we are not transparent,
|
||||||
// otherwise we would clip to a transparent view.
|
// otherwise we would clip to a transparent view.
|
||||||
if ((dismissAllInProgress && canChildBeDismissed(child))) {
|
previousNotificationEnd = newNotificationEnd;
|
||||||
previousNotificationIsSwiped = true;
|
previousNotificationStart = newYTranslation;
|
||||||
} else {
|
|
||||||
previousNotificationIsSwiped = ambientState.getDraggedViews().contains(child);
|
|
||||||
previousNotificationEnd = newNotificationEnd;
|
|
||||||
previousNotificationStart =newYTranslation + state.clipTopAmount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,31 +175,6 @@ public class StackScrollAlgorithm {
|
|||||||
return (veto != null && veto.getVisibility() != View.GONE);
|
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.
|
* Updates the dimmed, activated and hiding sensitive states of the children.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -110,11 +110,11 @@ public class StackScrollState {
|
|||||||
}
|
}
|
||||||
if (child instanceof DismissView) {
|
if (child instanceof DismissView) {
|
||||||
DismissView dismissView = (DismissView) child;
|
DismissView dismissView = (DismissView) child;
|
||||||
boolean visible = state.topOverLap < mClearAllTopPadding;
|
boolean visible = state.clipTopAmount < mClearAllTopPadding;
|
||||||
dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
|
dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
|
||||||
} else if (child instanceof EmptyShadeView) {
|
} else if (child instanceof EmptyShadeView) {
|
||||||
EmptyShadeView emptyShadeView = (EmptyShadeView) child;
|
EmptyShadeView emptyShadeView = (EmptyShadeView) child;
|
||||||
boolean visible = state.topOverLap <= 0;
|
boolean visible = state.clipTopAmount <= 0;
|
||||||
emptyShadeView.performVisibilityAnimation(
|
emptyShadeView.performVisibilityAnimation(
|
||||||
visible && !emptyShadeView.willBeGone());
|
visible && !emptyShadeView.willBeGone());
|
||||||
}
|
}
|
||||||
@@ -171,10 +171,6 @@ public class StackScrollState {
|
|||||||
if (oldClipTopAmount != state.clipTopAmount) {
|
if (oldClipTopAmount != state.clipTopAmount) {
|
||||||
view.setClipTopAmount(state.clipTopAmount);
|
view.setClipTopAmount(state.clipTopAmount);
|
||||||
}
|
}
|
||||||
float oldClipTopOptimization = view.getClipTopOptimization();
|
|
||||||
if (oldClipTopOptimization != state.topOverLap) {
|
|
||||||
view.setClipTopOptimization(state.topOverLap);
|
|
||||||
}
|
|
||||||
if (view instanceof ExpandableNotificationRow) {
|
if (view instanceof ExpandableNotificationRow) {
|
||||||
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
|
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
|
||||||
row.applyChildrenState(this);
|
row.applyChildrenState(this);
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ public class StackStateAnimator {
|
|||||||
private int mCurrentLastNotAddedIndex;
|
private int mCurrentLastNotAddedIndex;
|
||||||
private ValueAnimator mTopOverScrollAnimator;
|
private ValueAnimator mTopOverScrollAnimator;
|
||||||
private ValueAnimator mBottomOverScrollAnimator;
|
private ValueAnimator mBottomOverScrollAnimator;
|
||||||
private ExpandableNotificationRow mChildExpandingView;
|
|
||||||
private int mHeadsUpAppearHeightBottom;
|
private int mHeadsUpAppearHeightBottom;
|
||||||
private boolean mShadeExpanded;
|
private boolean mShadeExpanded;
|
||||||
private ArrayList<View> mChildrenToClearFromOverlay = new ArrayList<>();
|
private ArrayList<View> mChildrenToClearFromOverlay = new ArrayList<>();
|
||||||
@@ -128,7 +127,6 @@ public class StackStateAnimator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setClipTopOptimization(0);
|
|
||||||
startStackAnimations(child, viewState, finalState, i, -1 /* fixedDelay */);
|
startStackAnimations(child, viewState, finalState, i, -1 /* fixedDelay */);
|
||||||
}
|
}
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
@@ -139,7 +137,6 @@ public class StackStateAnimator {
|
|||||||
mHeadsUpDisappearChildren.clear();
|
mHeadsUpDisappearChildren.clear();
|
||||||
mNewEvents.clear();
|
mNewEvents.clear();
|
||||||
mNewAddChildren.clear();
|
mNewAddChildren.clear();
|
||||||
mChildExpandingView = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -871,7 +868,6 @@ public class StackStateAnimator {
|
|||||||
.AnimationEvent.ANIMATION_TYPE_GROUP_EXPANSION_CHANGED) {
|
.AnimationEvent.ANIMATION_TYPE_GROUP_EXPANSION_CHANGED) {
|
||||||
ExpandableNotificationRow row = (ExpandableNotificationRow) event.changingView;
|
ExpandableNotificationRow row = (ExpandableNotificationRow) event.changingView;
|
||||||
row.prepareExpansionChanged(finalState);
|
row.prepareExpansionChanged(finalState);
|
||||||
mChildExpandingView = row;
|
|
||||||
} else if (event.animationType == NotificationStackScrollLayout
|
} else if (event.animationType == NotificationStackScrollLayout
|
||||||
.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR) {
|
.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR) {
|
||||||
// This item is added, initialize it's properties.
|
// This item is added, initialize it's properties.
|
||||||
|
|||||||
@@ -40,17 +40,11 @@ public class StackViewState extends ViewState {
|
|||||||
public float shadowAlpha;
|
public float shadowAlpha;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount which the view should be clipped from the top. This is calculated to
|
* How much the child overlaps with the previous child on top. This is used to
|
||||||
* perceive consistent shadows.
|
* show the background properly when the child on top is translating away.
|
||||||
*/
|
*/
|
||||||
public int clipTopAmount;
|
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
|
* 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;
|
hideSensitive = svs.hideSensitive;
|
||||||
belowSpeedBump = svs.belowSpeedBump;
|
belowSpeedBump = svs.belowSpeedBump;
|
||||||
clipTopAmount = svs.clipTopAmount;
|
clipTopAmount = svs.clipTopAmount;
|
||||||
topOverLap = svs.topOverLap;
|
|
||||||
notGoneIndex = svs.notGoneIndex;
|
notGoneIndex = svs.notGoneIndex;
|
||||||
location = svs.location;
|
location = svs.location;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user