From c060228cc2726a9fc99e23b986ad324ef4f9b758 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Mon, 14 Mar 2022 21:54:34 +0100 Subject: [PATCH] Fix last notification trimmed on lockscreen The stack height set to ambientState, and then used by `StackScrollAlgorithm#initAlgorithmState` had some additional padding. For this reason, in `initAlgorithmState()` the `state.firstViewInShelf` was actually the one next to the correct one. intrinsicContentHeight doesn't have those paddings, and result in using the correct size. This can also be double checked by enabling debug draw lines in NotificationStackScrollLayout. The test is deleted as it was just duplicating the method code. Bug: 214504318 Test: existing tests pass + manually verified Change-Id: I83179d56ca7299e5d020e4eea2d460b168a76c6e --- .../stack/NotificationStackScrollLayout.java | 15 +++++++++++---- .../stack/NotificationStackScrollLayoutTest.java | 11 ----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 27cc326fda198..ade95a8cbfe75 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -782,6 +782,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable y = (int) (mAmbientState.getStackY() + mAmbientState.getStackHeight()); drawDebugInfo(canvas, y, Color.BLUE, /* label= */ "mAmbientState.getStackY() + mAmbientState.getStackHeight() = "+y); + + y = (int) mAmbientState.getStackY() + mContentHeight; + drawDebugInfo(canvas, y, Color.MAGENTA, + /* label= */ "mAmbientState.getStackY() + mContentHeight = " + y); + + y = (int) mAmbientState.getStackY() + mIntrinsicContentHeight; + drawDebugInfo(canvas, y, Color.YELLOW, + /* label= */ "mAmbientState.getStackY() + mIntrinsicContentHeight = " + y); } private void drawDebugInfo(Canvas canvas, int y, int color, String label) { @@ -1293,14 +1301,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mOnStackYChanged.accept(listenerNeedsAnimation); } if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) { - final float endHeight = updateStackEndHeight( - getHeight(), getEmptyBottomMargin(), mTopPadding); + final float endHeight = updateStackEndHeight(); updateStackHeight(endHeight, fraction); } } - public float updateStackEndHeight(float height, float bottomMargin, float topPadding) { - final float stackEndHeight = Math.max(0f, height - bottomMargin - topPadding); + private float updateStackEndHeight() { + final float stackEndHeight = Math.max(0f, mIntrinsicContentHeight); mAmbientState.setStackEndHeight(stackEndHeight); return stackEndHeight; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index eafcc354fac48..56541f3ceb6f8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -160,17 +160,6 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { doNothing().when(mNotificationShelf).setAnimationsEnabled(anyBoolean()); } - @Test - public void testUpdateStackEndHeight_forEndOfStackHeightAnimation() { - final float nsslHeight = 10f; - final float bottomMargin = 1f; - final float topPadding = 1f; - - mStackScroller.updateStackEndHeight(nsslHeight, bottomMargin, topPadding); - final float stackEndHeight = nsslHeight - bottomMargin - topPadding; - assertTrue(mAmbientState.getStackEndHeight() == stackEndHeight); - } - @Test public void testUpdateStackHeight_withDozeAmount_whenDozeChanging() { final float dozeAmount = 0.5f;