From 25b5291e12c5de8be6137ff92afbd64ed54e7e8f Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 2 Nov 2016 16:12:56 -0700 Subject: [PATCH] Fixed a bug with not-gone notifications Notifications with a GONE parent broke the whole scrolling model. The shelf is now always placed at the end instead and the number of GONE views are measured. Test: Add a group with a single notification and see that nothing jumps Bug: 32437839 Change-Id: I27a8c0b46eb8f329f23ad46c3995a19fb839caff --- .../systemui/statusbar/BaseStatusBar.java | 3 +-- .../systemui/statusbar/NotificationShelf.java | 24 ++++++++++--------- .../stack/NotificationStackScrollLayout.java | 1 - 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index f9451c0ccdc06..15ebae8381d61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -2237,8 +2237,7 @@ public abstract class BaseStatusBar extends SystemUI implements mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1); mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2); - mStackScroller.changeViewPosition(mNotificationShelf, - mStackScroller.getChildCount() - 3); + mStackScroller.changeViewPosition(mNotificationShelf, mStackScroller.getChildCount() - 3); } public boolean shouldShowOnKeyguard(StatusBarNotification sbn) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 9fc9b8f878a46..da25852c47eb9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -178,8 +178,11 @@ public class NotificationShelf extends ActivatableNotificationView { int shelfIndex = mAmbientState.getShelfIndex(); mNotGoneIndex = -1; // find the first view that doesn't overlap with the shelf - for (int i = shelfIndex - 1; i >= 0; i--) { - ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i); + int notificationIndex = 0; + int notGoneNotifications = 0; + while (notGoneNotifications < shelfIndex) { + ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex); + notificationIndex++; if (!(child instanceof ExpandableNotificationRow) || child.getVisibility() == GONE) { continue; @@ -188,12 +191,10 @@ public class NotificationShelf extends ActivatableNotificationView { StatusBarIconView icon = row.getEntry().expandedIcon; IconState iconState = iconStates.get(icon); float notificationClipEnd; - float shelfStart; - if (i == shelfIndex - 1) { - shelfStart = getTranslationY(); + float shelfStart = getTranslationY(); + if (notGoneNotifications == shelfIndex - 1) { notificationClipEnd = shelfStart + getIntrinsicHeight(); } else { - shelfStart = getTranslationY(); notificationClipEnd = shelfStart - mPaddingBetweenElements; float height = notificationClipEnd - row.getTranslationY(); if (height <= getNotificationMergeSize()) { @@ -206,14 +207,15 @@ public class NotificationShelf extends ActivatableNotificationView { updateNotificationClipHeight(row, notificationClipEnd); updateIconAppearance(shelfStart, row, iconState, icon); numIconsInShelf += iconState.iconAppearAmount; - if (row.getTranslationY() >= getTranslationY()) { - mNotGoneIndex = i; + if (row.getTranslationY() >= getTranslationY() && mNotGoneIndex == -1) { + mNotGoneIndex = notGoneNotifications; } + notGoneNotifications++; } - for (int i = mHostLayout.getChildCount() - 1; i >= shelfIndex; i--) { + while (notificationIndex < mHostLayout.getChildCount()) { // We need to reset the clipping in case a notification switches from high to low // priority. - ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i); + ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex); if (child.getClipBottomAmount() != 0) { child.setClipBottomAmount(0); } @@ -221,7 +223,7 @@ public class NotificationShelf extends ActivatableNotificationView { ExpandableNotificationRow row = (ExpandableNotificationRow) child; row.setIconTransformationAmount(0); } - + notificationIndex++; } mNotificationIconContainer.calculateIconTranslations(); mNotificationIconContainer.applyIconStates(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 0ec27ab686f8c..a795b2a5bbb18 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -539,7 +539,6 @@ public class NotificationStackScrollLayout extends ViewGroup public void updateShelfIndex(int newIndex, boolean noAmbient) { mAmbientState.setShelfIndex(newIndex); - changeViewPosition(mShelf, newIndex); mNoAmbient = noAmbient; }