From c8d943eb92db7f530ec1aac96b3cedb3f2aabe2c Mon Sep 17 00:00:00 2001 From: Aran Ink Date: Thu, 30 May 2019 15:44:12 -0400 Subject: [PATCH] Allow all ActivatableNotificationRows to clip properly when interacting with the shelf. Test: Manual. Fixes: 133160365 Change-Id: I69403f12e355e31bc440692c2f96816559d85a86 --- .../systemui/statusbar/NotificationShelf.java | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index d202190724f5e..fc2705f054e0b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -294,17 +294,17 @@ public class NotificationShelf extends ActivatableNotificationView implements int backgroundTop = 0; int clipTopAmount = 0; float firstElementRoundness = 0.0f; - ExpandableNotificationRow previousRow = null; + ActivatableNotificationView previousRow = null; for (int i = 0; i < mHostLayout.getChildCount(); i++) { ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i); - if (!(child instanceof ExpandableNotificationRow) - || child.getVisibility() == GONE) { + if (!(child instanceof ActivatableNotificationView) + || child.getVisibility() == GONE || child == this) { continue; } - ExpandableNotificationRow row = (ExpandableNotificationRow) child; + ActivatableNotificationView row = (ActivatableNotificationView) child; float notificationClipEnd; boolean aboveShelf = ViewState.getFinalTranslationZ(row) > baseZHeight || row.isPinned(); @@ -324,43 +324,55 @@ public class NotificationShelf extends ActivatableNotificationView implements } int clipTop = updateNotificationClipHeight(row, notificationClipEnd, notGoneIndex); clipTopAmount = Math.max(clipTop, clipTopAmount); - float inShelfAmount = updateIconAppearance(row, expandAmount, scrolling, scrollingFast, - expandingAnimated, isLastChild); - numViewsInShelf += inShelfAmount; - int ownColorUntinted = row.getBackgroundColorWithoutTint(); - if (rowTranslationY >= shelfStart && mNotGoneIndex == -1) { - mNotGoneIndex = notGoneIndex; - setTintColor(previousColor); - setOverrideTintColor(colorTwoBefore, transitionAmount); - } else if (mNotGoneIndex == -1) { - colorTwoBefore = previousColor; - transitionAmount = inShelfAmount; - } - if (isLastChild) { - if (colorOfViewBeforeLast == NO_COLOR) { + // If the current row is an ExpandableNotificationRow, update its color, roundedness, + // and icon state. + if (row instanceof ExpandableNotificationRow) { + ExpandableNotificationRow expandableRow = (ExpandableNotificationRow) row; + + float inShelfAmount = updateIconAppearance(expandableRow, expandAmount, scrolling, + scrollingFast, + expandingAnimated, isLastChild); + numViewsInShelf += inShelfAmount; + int ownColorUntinted = row.getBackgroundColorWithoutTint(); + if (rowTranslationY >= shelfStart && mNotGoneIndex == -1) { + mNotGoneIndex = notGoneIndex; + setTintColor(previousColor); + setOverrideTintColor(colorTwoBefore, transitionAmount); + + } else if (mNotGoneIndex == -1) { + colorTwoBefore = previousColor; + transitionAmount = inShelfAmount; + } + if (isLastChild) { + if (colorOfViewBeforeLast == NO_COLOR) { + colorOfViewBeforeLast = ownColorUntinted; + } + row.setOverrideTintColor(colorOfViewBeforeLast, inShelfAmount); + } else { colorOfViewBeforeLast = ownColorUntinted; + row.setOverrideTintColor(NO_COLOR, 0 /* overrideAmount */); } - row.setOverrideTintColor(colorOfViewBeforeLast, inShelfAmount); - } else { - colorOfViewBeforeLast = ownColorUntinted; - row.setOverrideTintColor(NO_COLOR, 0 /* overrideAmount */); - } - if (notGoneIndex != 0 || !aboveShelf) { - row.setAboveShelf(false); - } - if (notGoneIndex == 0) { - StatusBarIconView icon = row.getEntry().expandedIcon; - NotificationIconContainer.IconState iconState = getIconState(icon); - // The icon state might be null in rare cases where the notification is actually - // added to the layout, but not to the shelf. An example are replied messages, since - // they don't show up on AOD - if (iconState != null && iconState.clampedAppearAmount == 1.0f) { - // only if the first icon is fully in the shelf we want to clip to it! - backgroundTop = (int) (row.getTranslationY() - getTranslationY()); - firstElementRoundness = row.getCurrentTopRoundness(); + if (notGoneIndex != 0 || !aboveShelf) { + expandableRow.setAboveShelf(false); } + if (notGoneIndex == 0) { + StatusBarIconView icon = expandableRow.getEntry().expandedIcon; + NotificationIconContainer.IconState iconState = getIconState(icon); + // The icon state might be null in rare cases where the notification is actually + // added to the layout, but not to the shelf. An example are replied messages, + // since they don't show up on AOD + if (iconState != null && iconState.clampedAppearAmount == 1.0f) { + // only if the first icon is fully in the shelf we want to clip to it! + backgroundTop = (int) (row.getTranslationY() - getTranslationY()); + firstElementRoundness = row.getCurrentTopRoundness(); + } + } + + previousColor = ownColorUntinted; + notGoneIndex++; } + if (row.isFirstInSection() && previousRow != null && previousRow.isLastInSection()) { // If the top of the shelf is between the view before a gap and the view after a gap // then we need to adjust the shelf's top roundness. @@ -379,8 +391,6 @@ public class NotificationShelf extends ActivatableNotificationView implements backgroundTop = (int) distanceToGapBottom; } } - notGoneIndex++; - previousColor = ownColorUntinted; previousRow = row; } clipTransientViews(); @@ -497,7 +507,7 @@ public class NotificationShelf extends ActivatableNotificationView implements * Update the clipping of this view. * @return the amount that our own top should be clipped */ - private int updateNotificationClipHeight(ExpandableNotificationRow row, + private int updateNotificationClipHeight(ActivatableNotificationView row, float notificationClipEnd, int childIndex) { float viewEnd = row.getTranslationY() + row.getActualHeight(); boolean isPinned = (row.isPinned() || row.isHeadsUpAnimatingAway())