Merge "Hide notification stack footer even if the expansion is changing" into sc-dev am: acac4e7c54

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14467706

Change-Id: I57fc2560f10643b13415834d9e7617f112fdfdd3
This commit is contained in:
Nick Chameyev
2021-05-18 11:33:22 +00:00
committed by Automerger Merge Worker

View File

@@ -225,6 +225,8 @@ public class StackScrollAlgorithm {
// already accounted for by the top padding and doesn't need an additional adaption // already accounted for by the top padding and doesn't need an additional adaption
scrollY = Math.max(0, scrollY); scrollY = Math.max(0, scrollY);
state.scrollY = (int) (scrollY + bottomOverScroll); state.scrollY = (int) (scrollY + bottomOverScroll);
state.mCurrentYPosition = -state.scrollY;
state.mCurrentExpandedYPosition = -state.scrollY;
//now init the visible children and update paddings //now init the visible children and update paddings
int childCount = hostView.getChildCount(); int childCount = hostView.getChildCount();
@@ -321,14 +323,14 @@ public class StackScrollAlgorithm {
*/ */
private void updatePositionsForState(StackScrollAlgorithmState algorithmState, private void updatePositionsForState(StackScrollAlgorithmState algorithmState,
AmbientState ambientState) { AmbientState ambientState) {
// The y coordinate of the current child.
float currentYPosition = -algorithmState.scrollY;
if (!ambientState.isOnKeyguard()) { if (!ambientState.isOnKeyguard()) {
currentYPosition += mNotificationScrimPadding; algorithmState.mCurrentYPosition += mNotificationScrimPadding;
algorithmState.mCurrentExpandedYPosition += mNotificationScrimPadding;
} }
int childCount = algorithmState.visibleChildren.size(); int childCount = algorithmState.visibleChildren.size();
for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) {
currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition); updateChild(i, algorithmState, ambientState);
} }
} }
@@ -368,17 +370,11 @@ public class StackScrollAlgorithm {
* {@link StackScrollAlgorithmState#visibleChildren}. * {@link StackScrollAlgorithmState#visibleChildren}.
* @param algorithmState The overall output state of the algorithm. * @param algorithmState The overall output state of the algorithm.
* @param ambientState The input state provided to the algorithm. * @param ambientState The input state provided to the algorithm.
* @param currentYPosition The Y position of the current pass of the algorithm. For a forward
* pass, this should be the top of the child; for a reverse pass, the
* bottom of the child.
* @return The Y position after laying out the child. This will be the {@code currentYPosition}
* for the next call to this method, after adjusting for any gaps between children.
*/ */
protected float updateChild( protected void updateChild(
int i, int i,
StackScrollAlgorithmState algorithmState, StackScrollAlgorithmState algorithmState,
AmbientState ambientState, AmbientState ambientState) {
float currentYPosition) {
ExpandableView view = algorithmState.visibleChildren.get(i); ExpandableView view = algorithmState.visibleChildren.get(i);
ExpandableViewState viewState = view.getViewState(); ExpandableViewState viewState = view.getViewState();
@@ -407,10 +403,11 @@ public class StackScrollAlgorithm {
ambientState.getSectionProvider(), i, ambientState.getSectionProvider(), i,
view, getPreviousView(i, algorithmState)); view, getPreviousView(i, algorithmState));
if (applyGapHeight) { if (applyGapHeight) {
currentYPosition += expansionFraction * mGapHeight; algorithmState.mCurrentYPosition += expansionFraction * mGapHeight;
algorithmState.mCurrentExpandedYPosition += mGapHeight;
} }
viewState.yTranslation = currentYPosition; viewState.yTranslation = algorithmState.mCurrentYPosition;
if (view instanceof SectionHeaderView) { if (view instanceof SectionHeaderView) {
// Add padding before sections for overscroll effect. // Add padding before sections for overscroll effect.
viewState.yTranslation += expansionFraction * ambientState.getSectionPadding(); viewState.yTranslation += expansionFraction * ambientState.getSectionPadding();
@@ -419,12 +416,11 @@ public class StackScrollAlgorithm {
if (view instanceof FooterView) { if (view instanceof FooterView) {
final boolean isShelfShowing = algorithmState.firstViewInShelf != null; final boolean isShelfShowing = algorithmState.firstViewInShelf != null;
final float footerEnd = viewState.yTranslation + view.getIntrinsicHeight(); final float footerEnd = algorithmState.mCurrentExpandedYPosition
final boolean noSpaceForFooter = footerEnd > ambientState.getStackHeight(); + view.getIntrinsicHeight();
final boolean noSpaceForFooter = footerEnd > ambientState.getStackEndHeight();
viewState.hidden = isShelfShowing
|| (!ambientState.isExpansionChanging() && noSpaceForFooter);
viewState.hidden = isShelfShowing || noSpaceForFooter;
} else if (view != ambientState.getTrackedHeadsUpRow()) { } else if (view != ambientState.getTrackedHeadsUpRow()) {
if (ambientState.isExpansionChanging()) { if (ambientState.isExpansionChanging()) {
// Show all views. Views below the shelf will later be clipped (essentially hidden) // Show all views. Views below the shelf will later be clipped (essentially hidden)
@@ -462,10 +458,13 @@ public class StackScrollAlgorithm {
viewState.height = (int) (maxViewHeight * expansionFraction); viewState.height = (int) (maxViewHeight * expansionFraction);
} }
currentYPosition += viewState.height + expansionFraction * mPaddingBetweenElements; algorithmState.mCurrentYPosition += viewState.height
setLocation(view.getViewState(), currentYPosition, i); + expansionFraction * mPaddingBetweenElements;
algorithmState.mCurrentExpandedYPosition += view.getIntrinsicHeight()
+ mPaddingBetweenElements;
setLocation(view.getViewState(), algorithmState.mCurrentYPosition, i);
viewState.yTranslation += ambientState.getStackY(); viewState.yTranslation += ambientState.getStackY();
return currentYPosition;
} }
/** /**
@@ -738,6 +737,18 @@ public class StackScrollAlgorithm {
* The children from the host view which are not gone. * The children from the host view which are not gone.
*/ */
public final ArrayList<ExpandableView> visibleChildren = new ArrayList<>(); public final ArrayList<ExpandableView> visibleChildren = new ArrayList<>();
/**
* Y position of the current view during updating children
* with expansion factor applied.
*/
private int mCurrentYPosition;
/**
* Y position of the current view during updating children
* without applying the expansion factor.
*/
private int mCurrentExpandedYPosition;
} }
/** /**