From 8f3ba5abbd18087b756a89eb8985e265199d0a17 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Tue, 19 Jan 2021 18:06:31 -0600 Subject: [PATCH] Clip view before shelf and leave the rest unclipped Bug: 172289889 Test: visual Change-Id: Ic49edf84ba246be9bfff7d39d822ced1d7a23e46 --- .../systemui/statusbar/NotificationShelf.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 20efa32d63c6f..4a8057201c2f7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -204,6 +204,30 @@ public class NotificationShelf extends ActivatableNotificationView implements } } + /** + * @return whether to clip bottom of given view + */ + private boolean shouldClipBottom(ExpandableView view) { + final boolean showShelf = ((ShelfState) getViewState()).hasItemsInStableShelf; + if (showShelf) { + if (mAmbientState.isShadeOpening()) { + final float viewEnd = view.getTranslationY() + + view.getActualHeight() + + mPaddingBetweenElements; + final float finalShelfStart = mMaxLayoutHeight - getIntrinsicHeight(); + // While the shade is opening, only clip view if it overlaps with shelf; + // otherwise leave view unclipped. + if (viewEnd < finalShelfStart) { + return false; + } + } + // Clip for scrolling. + return true; + } + // Don't clip since we have enough space to show all views. + return false; + } + /** * Update the shelf appearance based on the other notifications around it. This transforms * the icons from the notification area into the shelf. @@ -345,7 +369,9 @@ public class NotificationShelf extends ActivatableNotificationView implements clipTransientViews(); setClipTopAmount(clipTopAmount); - boolean isHidden = getViewState().hidden || clipTopAmount >= getIntrinsicHeight(); + boolean isHidden = getViewState().hidden + || clipTopAmount >= getIntrinsicHeight() + || mAmbientState.isShadeOpening(); if (mShowNotificationShelf) { setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE); } @@ -468,7 +494,8 @@ public class NotificationShelf extends ActivatableNotificationView implements } else { shouldClipOwnTop = view.showingPulsing(); } - if (viewEnd > notificationClipEnd && !shouldClipOwnTop + if (shouldClipBottom(view) + && viewEnd > notificationClipEnd && !shouldClipOwnTop && (mAmbientState.isShadeExpanded() || !isPinned)) { int clipBottomAmount = (int) (viewEnd - notificationClipEnd); if (isPinned) {