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

This commit is contained in:
Selim Cinek
2020-06-30 01:06:55 +00:00
committed by Android (Google) Code Review
2 changed files with 38 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -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))