Merge "Allow the user to collapse the notification panel on quick settings" into rvc-dev am: 8e47723834

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12039363

Change-Id: I347a2cc058c23ca915420b8f4e8cd7c9e163c96c
This commit is contained in:
Selim Cinek
2020-06-30 01:09:55 +00:00
committed by Automerger Merge Worker
2 changed files with 38 additions and 8 deletions

View File

@@ -434,6 +434,11 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean mAllowExpandForSmallExpansion; private boolean mAllowExpandForSmallExpansion;
private Runnable mExpandAfterLayoutRunnable; 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. * If face auth with bypass is running for the first time after you turn on the screen.
* (From aod or screen off) * (From aod or screen off)
@@ -1064,7 +1069,11 @@ public class NotificationPanelViewController extends PanelViewController {
mInitialTouchX = x; mInitialTouchX = x;
initVelocityTracker(); initVelocityTracker();
trackMovement(event); 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); mView.getParent().requestDisallowInterceptTouchEvent(true);
} }
if (mQsExpansionAnimator != null) { if (mQsExpansionAnimator != null) {
@@ -1097,9 +1106,10 @@ public class NotificationPanelViewController extends PanelViewController {
trackMovement(event); trackMovement(event);
return true; return true;
} }
if (Math.abs(h) > getTouchSlop(event) if ((h > getTouchSlop(event) || (h < -getTouchSlop(event) && mQsExpanded))
&& Math.abs(h) > Math.abs(x - mInitialTouchX) && Math.abs(h) > Math.abs(x - mInitialTouchX)
&& shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) { && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) {
mView.getParent().requestDisallowInterceptTouchEvent(true);
mQsTracking = true; mQsTracking = true;
onQsExpansionStarted(); onQsExpansionStarted();
notifyExpandingFinished(); notifyExpandingFinished();
@@ -1139,6 +1149,7 @@ public class NotificationPanelViewController extends PanelViewController {
mDownX = event.getX(); mDownX = event.getX();
mDownY = event.getY(); mDownY = event.getY();
mCollapsedOnDown = isFullyCollapsed(); mCollapsedOnDown = isFullyCollapsed();
mIsPanelCollapseOnQQS = canPanelCollapseOnQQS(mDownX, mDownY);
mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp(); mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp();
mAllowExpandForSmallExpansion = mExpectingSynthesizedDown; mAllowExpandForSmallExpansion = mExpectingSynthesizedDown;
mTouchSlopExceededBeforeDown = 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) { private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) {
float vel = getCurrentQSVelocity(); float vel = getCurrentQSVelocity();
final boolean expandsQs = flingExpandsQs(vel); final boolean expandsQs = flingExpandsQs(vel);
@@ -1903,10 +1932,11 @@ public class NotificationPanelViewController extends PanelViewController {
} }
@Override @Override
protected boolean isScrolledToBottom() { protected boolean canCollapsePanelOnTouch() {
if (!isInSettings()) { if (!isInSettings()) {
return mBarState == StatusBarState.KEYGUARD return mBarState == StatusBarState.KEYGUARD
|| mNotificationStackScroller.isScrolledToBottom(); || mNotificationStackScroller.isScrolledToBottom()
|| mIsPanelCollapseOnQQS;
} else { } else {
return true; return true;
} }

View File

@@ -460,7 +460,7 @@ public abstract class PanelViewController {
} }
} }
protected boolean isScrolledToBottom() { protected boolean canCollapsePanelOnTouch() {
return true; return true;
} }
@@ -1081,7 +1081,7 @@ public abstract class PanelViewController {
* upwards. This allows closing the shade from anywhere inside the panel. * upwards. This allows closing the shade from anywhere inside the panel.
* *
* We only do this if the current content is scrolled to the bottom, * 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 * gesture
* possible. * possible.
*/ */
@@ -1092,7 +1092,7 @@ public abstract class PanelViewController {
} }
final float x = event.getX(pointerIndex); final float x = event.getX(pointerIndex);
final float y = event.getY(pointerIndex); final float y = event.getY(pointerIndex);
boolean scrolledToBottom = isScrolledToBottom(); boolean canCollapsePanel = canCollapsePanelOnTouch();
switch (event.getActionMasked()) { switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@@ -1139,7 +1139,7 @@ public abstract class PanelViewController {
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
final float h = y - mInitialTouchY; final float h = y - mInitialTouchY;
addMovement(event); addMovement(event);
if (scrolledToBottom || mTouchStartedInEmptyArea || mAnimatingOnDown) { if (canCollapsePanel || mTouchStartedInEmptyArea || mAnimatingOnDown) {
float hAbs = Math.abs(h); float hAbs = Math.abs(h);
float touchSlop = getTouchSlop(event); float touchSlop = getTouchSlop(event);
if ((h < -touchSlop || (mAnimatingOnDown && hAbs > touchSlop)) if ((h < -touchSlop || (mAnimatingOnDown && hAbs > touchSlop))