From 5be1f7c2f0f2b74b721c9d58449e31dce24c2037 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Mon, 21 May 2018 20:50:54 +0800 Subject: [PATCH] Fixed a issue where notification icons don't align vertically while peeking Hide notification in shelf when the height doesn't exceed appearEnd position. Fixes: 77546749 Test: manual, 1) set "Simulate a display with a cutout" to Double display cutout, 2) pull the notification panel down and observe the icon position. Change-Id: I5f21188f528f3283256828d0a70aad52ca52c6dc --- .../statusbar/stack/AmbientState.java | 10 +++++++++- .../stack/NotificationStackScrollLayout.java | 4 +++- .../statusbar/stack/StackScrollAlgorithm.java | 20 ++++--------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java index 91a4b07c21097..db3f0d997e081 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java @@ -30,7 +30,6 @@ import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.ArrayList; -import java.util.Collection; /** * A global state to track all input states for the algorithm. @@ -72,6 +71,7 @@ public class AmbientState { private ExpandableNotificationRow mExpandingNotification; private int mDarkTopPadding; private float mDarkAmount; + private boolean mAppearing; public AmbientState(Context context) { reload(context); @@ -436,4 +436,12 @@ public class AmbientState { public int getDarkTopPadding() { return mDarkTopPadding; } + + public void setAppearing(boolean appearing) { + mAppearing = appearing; + } + + public boolean isAppearing() { + return mAppearing; + } } 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 bd56d7941a290..a2b33fa1a5818 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -885,7 +885,9 @@ public class NotificationStackScrollLayout extends ViewGroup float appearEndPosition = getAppearEndPosition(); float appearStartPosition = getAppearStartPosition(); float appearFraction = 1.0f; - if (height >= appearEndPosition) { + boolean appearing = height < appearEndPosition; + mAmbientState.setAppearing(appearing); + if (!appearing) { translationY = 0; if (mShouldShowShelfOnly) { stackHeight = mTopPadding + mShelf.getIntrinsicHeight(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index 85f33d75e60cf..0d50f5a9eef79 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -478,22 +478,6 @@ public class StackScrollAlgorithm { childState.hidden = false; } } - // Let's hide all the views if we are not expanded. the views might otherwise be visible - // in the headsup area if a view was swiped away - if (!mIsExpanded) { - for (int i = 0; i < childCount; i++) { - boolean visible = false; - View child = algorithmState.visibleChildren.get(i); - if (child instanceof ExpandableNotificationRow) { - ExpandableNotificationRow row = (ExpandableNotificationRow) child; - visible = row.isHeadsUp() || row.isHeadsUpAnimatingAway(); - } - if (!visible) { - ExpandableViewState childState = resultState.getViewStateForView(child); - childState.hidden = true; - } - } - } } private void clampHunToTop(AmbientState ambientState, ExpandableNotificationRow row, @@ -536,6 +520,10 @@ public class StackScrollAlgorithm { int shelfStart = ambientState.getInnerHeight() - ambientState.getShelf().getIntrinsicHeight(); + if (ambientState.isAppearing() && !child.isAboveShelf()) { + // Don't show none heads-up notifications while in appearing phase. + childViewState.yTranslation = Math.max(childViewState.yTranslation, shelfStart); + } childViewState.yTranslation = Math.min(childViewState.yTranslation, shelfStart); if (childViewState.yTranslation >= shelfStart) { childViewState.hidden = !child.isExpandAnimationRunning() && !child.hasExpandingChild();