From 711b8ddf42c5897d13696338fed1435b44c9793d Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 29 Jun 2020 15:51:37 -0700 Subject: [PATCH] Allow the user to collapse the notification panel on quick settings Previously we were immediately disallowing to intercept when the scrolling started on the header. This is wrong, since the user could also swipe upwards. We're now doing this only once the touchslop has been crossed. Fixes: 159679534 Test: start collapsing on the QS header, observe that it works. Other interactions are unchanged Change-Id: Iee86b2a8a473664846a6b119bf9110b5a751a2a8 --- .../NotificationPanelViewController.java | 38 +++++++++++++++++-- .../statusbar/phone/PanelViewController.java | 8 ++-- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index c32133119386c..375af6b099c24 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -434,6 +434,11 @@ public class NotificationPanelViewController extends PanelViewController { private boolean mAllowExpandForSmallExpansion; private Runnable mExpandAfterLayoutRunnable; + /** + * Is this a collapse that started on the panel where we should allow the panel to intercept + */ + private boolean mIsPanelCollapseOnQQS; + /** * If face auth with bypass is running for the first time after you turn on the screen. * (From aod or screen off) @@ -1064,7 +1069,11 @@ public class NotificationPanelViewController extends PanelViewController { mInitialTouchX = x; initVelocityTracker(); trackMovement(event); - if (shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, 0)) { + if (mKeyguardShowing + && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, 0)) { + // Dragging down on the lockscreen statusbar should prohibit other interactions + // immediately, otherwise we'll wait on the touchslop. This is to allow + // dragging down to expanded quick settings directly on the lockscreen. mView.getParent().requestDisallowInterceptTouchEvent(true); } if (mQsExpansionAnimator != null) { @@ -1097,9 +1106,10 @@ public class NotificationPanelViewController extends PanelViewController { trackMovement(event); return true; } - if (Math.abs(h) > getTouchSlop(event) + if ((h > getTouchSlop(event) || (h < -getTouchSlop(event) && mQsExpanded)) && Math.abs(h) > Math.abs(x - mInitialTouchX) && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) { + mView.getParent().requestDisallowInterceptTouchEvent(true); mQsTracking = true; onQsExpansionStarted(); notifyExpandingFinished(); @@ -1139,6 +1149,7 @@ public class NotificationPanelViewController extends PanelViewController { mDownX = event.getX(); mDownY = event.getY(); mCollapsedOnDown = isFullyCollapsed(); + mIsPanelCollapseOnQQS = canPanelCollapseOnQQS(mDownX, mDownY); mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp(); mAllowExpandForSmallExpansion = mExpectingSynthesizedDown; mTouchSlopExceededBeforeDown = mExpectingSynthesizedDown; @@ -1154,6 +1165,24 @@ public class NotificationPanelViewController extends PanelViewController { } } + /** + * Can the panel collapse in this motion because it was started on QQS? + * + * @param downX the x location where the touch started + * @param downY the y location where the touch started + * + * @return true if the panel could be collapsed because it stared on QQS + */ + private boolean canPanelCollapseOnQQS(float downX, float downY) { + if (mCollapsedOnDown || mKeyguardShowing || mQsExpanded) { + return false; + } + View header = mQs == null ? mKeyguardStatusBar : mQs.getHeader(); + return downX >= mQsFrame.getX() && downX <= mQsFrame.getX() + mQsFrame.getWidth() + && downY <= header.getBottom(); + + } + private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) { float vel = getCurrentQSVelocity(); final boolean expandsQs = flingExpandsQs(vel); @@ -1903,10 +1932,11 @@ public class NotificationPanelViewController extends PanelViewController { } @Override - protected boolean isScrolledToBottom() { + protected boolean canCollapsePanelOnTouch() { if (!isInSettings()) { return mBarState == StatusBarState.KEYGUARD - || mNotificationStackScroller.isScrolledToBottom(); + || mNotificationStackScroller.isScrolledToBottom() + || mIsPanelCollapseOnQQS; } else { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index caddc4a874f47..732f25f90eb5c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -460,7 +460,7 @@ public abstract class PanelViewController { } } - protected boolean isScrolledToBottom() { + protected boolean canCollapsePanelOnTouch() { return true; } @@ -1081,7 +1081,7 @@ public abstract class PanelViewController { * upwards. This allows closing the shade from anywhere inside the panel. * * We only do this if the current content is scrolled to the bottom, - * i.e isScrolledToBottom() is true and therefore there is no conflicting scrolling + * i.e canCollapsePanelOnTouch() is true and therefore there is no conflicting scrolling * gesture * possible. */ @@ -1092,7 +1092,7 @@ public abstract class PanelViewController { } final float x = event.getX(pointerIndex); final float y = event.getY(pointerIndex); - boolean scrolledToBottom = isScrolledToBottom(); + boolean canCollapsePanel = canCollapsePanelOnTouch(); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: @@ -1139,7 +1139,7 @@ public abstract class PanelViewController { case MotionEvent.ACTION_MOVE: final float h = y - mInitialTouchY; addMovement(event); - if (scrolledToBottom || mTouchStartedInEmptyArea || mAnimatingOnDown) { + if (canCollapsePanel || mTouchStartedInEmptyArea || mAnimatingOnDown) { float hAbs = Math.abs(h); float touchSlop = getTouchSlop(event); if ((h < -touchSlop || (mAnimatingOnDown && hAbs > touchSlop))