From 355652a6c8109a8706cf8c6157cfb1c1b0dcf06e Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 7 Dec 2016 13:32:12 -0800 Subject: [PATCH] Fixes that notifications were sometimes clipped on the lockscreen When dragging down a notification into the bottom, the top notification could become clipped. Test: add notifications, pull down on last notification on lockscreen Bug: 32437839 Change-Id: Ibb58d1aa7575fbe9d84b8542ac57ffae494bb127 --- .../systemui/statusbar/phone/PhoneStatusBar.java | 1 + .../systemui/statusbar/stack/AmbientState.java | 10 ++++++++++ .../stack/NotificationStackScrollLayout.java | 12 +++++++++--- .../statusbar/stack/StackScrollAlgorithm.java | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index bbbdc13d69e34..024c1750bcdf9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -4558,6 +4558,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mGroupManager.setStatusBarState(state); mFalsingManager.setStatusBarState(state); mStatusBarWindowManager.setStatusBarState(state); + mStackScroller.setStatusBarState(state); updateReportRejectedTouchVisibility(); updateDozing(); } 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 f468b5c7e11df..94fc17a8b1d83 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java @@ -22,6 +22,7 @@ import android.view.View; import com.android.systemui.R; import com.android.systemui.statusbar.ActivatableNotificationView; import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.ArrayList; @@ -53,6 +54,7 @@ public class AmbientState { private int mMaxLayoutHeight; private ActivatableNotificationView mLastVisibleBackgroundChild; private float mCurrentScrollVelocity; + private int mStatusBarState; public AmbientState(Context context) { reload(context); @@ -250,4 +252,12 @@ public class AmbientState { public float getCurrentScrollVelocity() { return mCurrentScrollVelocity; } + + public boolean isOnKeyguard() { + return mStatusBarState == StatusBarState.KEYGUARD; + } + + public void setStatusBarState(int statusBarState) { + mStatusBarState = statusBarState; + } } 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 3cd4ebdff329e..543550d6395d2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -357,6 +357,7 @@ public class NotificationStackScrollLayout extends ViewGroup private Rect mRequestedClipBounds; private boolean mInHeadsUpPinnedMode; private boolean mHeadsUpAnimatingAway; + private int mStatusBarState; public NotificationStackScrollLayout(Context context) { this(context, null); @@ -1187,7 +1188,7 @@ public class NotificationStackScrollLayout extends ViewGroup } private boolean onKeyguard() { - return mPhoneStatusBar.getBarState() == StatusBarState.KEYGUARD; + return mStatusBarState == StatusBarState.KEYGUARD; } private void setSwipingInProgress(boolean isSwiped) { @@ -2124,7 +2125,7 @@ public class NotificationStackScrollLayout extends ViewGroup top = mTopPadding; bottom = top; } - if (mPhoneStatusBar.getBarState() != StatusBarState.KEYGUARD) { + if (mStatusBarState != StatusBarState.KEYGUARD) { top = (int) Math.max(mTopPadding + mStackTranslation, top); } else { // otherwise the animation from the shade to the keyguard will jump as it's maxed @@ -2358,7 +2359,7 @@ public class NotificationStackScrollLayout extends ViewGroup } break; case MotionEvent.ACTION_UP: - if (mPhoneStatusBar.getBarState() != StatusBarState.KEYGUARD && mTouchIsClick && + if (mStatusBarState != StatusBarState.KEYGUARD && mTouchIsClick && isBelowLastNotification(mInitialTouchX, mInitialTouchY)) { mOnEmptySpaceClickListener.onEmptySpaceClicked(mInitialTouchX, mInitialTouchY); } @@ -3981,6 +3982,11 @@ public class NotificationStackScrollLayout extends ViewGroup updateClipping(); } + public void setStatusBarState(int statusBarState) { + mStatusBarState = statusBarState; + mAmbientState.setStatusBarState(statusBarState); + } + /** * A listener that is notified when some child locations might have changed. */ 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 7afc7ba0a0c1e..50b6d70f437c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -124,7 +124,8 @@ public class StackScrollAlgorithm { private void updateClipping(StackScrollState resultState, StackScrollAlgorithmState algorithmState, AmbientState ambientState) { - float drawStart = ambientState.getTopPadding() + ambientState.getStackTranslation(); + float drawStart = !ambientState.isOnKeyguard() ? ambientState.getTopPadding() + + ambientState.getStackTranslation() : 0; float previousNotificationEnd = 0; float previousNotificationStart = 0; int childCount = algorithmState.visibleChildren.size();