From 2aaafaa1a892818d7988e653b48fdc59ac21ff5b Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Mon, 11 Apr 2022 16:22:57 +0200 Subject: [PATCH] Fix notifications trimmed when unfolded on keyguard When the number of notifications is limited by mMaxDisplayedNotifications (e.g. on keyguard), it is possible to use the intrinsic content height of the stack, as it is already limited by the maximum number of notifications. The values of bottom and top margin previously used in updateStackEndHeight were wrong for the split shade (while on lockscreen). Fixes: 214504318 Test: Add many notifications and check nothing is truncated both when folded and unfolded. Change-Id: Iae63c3916499c53475475905383c925b13d8f1b1 --- .../stack/NotificationStackScrollLayout.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 bf27550b331be..36cd173d2d1cd 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 @@ -415,6 +415,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private boolean mForwardScrollable; private boolean mBackwardScrollable; private NotificationShelf mShelf; + /** + * Limits the number of visible notifications. The remaining are collapsed in the notification + * shelf. -1 when there is no limit. + */ private int mMaxDisplayedNotifications = -1; private float mKeyguardBottomPadding = -1; @VisibleForTesting int mStatusBarHeight; @@ -1323,7 +1327,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } private float updateStackEndHeight(float height, float bottomMargin, float topPadding) { - final float stackEndHeight = Math.max(0f, height - bottomMargin - topPadding); + final float stackEndHeight; + if (mMaxDisplayedNotifications != -1) { + // The stack intrinsic height already contains the correct value when there is a limit + // in the max number of notifications (e.g. as in keyguard). + stackEndHeight = mIntrinsicContentHeight; + } else { + stackEndHeight = Math.max(0f, height - bottomMargin - topPadding); + } mAmbientState.setStackEndHeight(stackEndHeight); return stackEndHeight; }