Merge "Transfer focus to open panel" into qt-r1-dev

This commit is contained in:
Hyunyoung Song
2019-06-27 16:53:29 +00:00
committed by Android (Google) Code Review
4 changed files with 50 additions and 23 deletions

View File

@@ -119,7 +119,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
private boolean mIsEnabled;
private int mCurrentBoundedUserId = -1;
private float mNavBarButtonAlpha;
private MotionEvent mStatusBarGestureDownEvent;
private boolean mInputFocusTransferStarted;
private float mWindowCornerRadius;
private boolean mSupportsRoundedCornersOnWindows;
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
@@ -164,6 +164,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
}
// TODO: change the method signature to use (boolean inputFocusTransferStarted)
@Override
public void onStatusBarMotionEvent(MotionEvent event) {
if (!verifyCaller("onStatusBarMotionEvent")) {
@@ -175,16 +176,16 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
mHandler.post(()->{
StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
if (bar != null) {
bar.dispatchNotificationsPanelTouchEvent(event);
int action = event.getActionMasked();
if (action == ACTION_DOWN) {
mStatusBarGestureDownEvent = MotionEvent.obtain(event);
mInputFocusTransferStarted = true;
}
if (action == ACTION_UP || action == ACTION_CANCEL) {
mStatusBarGestureDownEvent.recycle();
mStatusBarGestureDownEvent = null;
mInputFocusTransferStarted = false;
}
bar.onInputFocusTransfer(mInputFocusTransferStarted);
event.recycle();
}
});
@@ -590,14 +591,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
public void cleanupAfterDeath() {
if (mStatusBarGestureDownEvent != null) {
if (mInputFocusTransferStarted) {
mHandler.post(()-> {
StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
if (bar != null) {
mStatusBarGestureDownEvent.setAction(MotionEvent.ACTION_CANCEL);
bar.dispatchNotificationsPanelTouchEvent(mStatusBarGestureDownEvent);
mStatusBarGestureDownEvent.recycle();
mStatusBarGestureDownEvent = null;
mInputFocusTransferStarted = false;
bar.onInputFocusTransfer(false);
}
});
}
@@ -782,6 +781,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
pw.println(QuickStepContract.isBackGestureDisabled(mSysUiStateFlags));
pw.print(" assistantGestureDisabled=");
pw.println(QuickStepContract.isAssistantGestureDisabled(mSysUiStateFlags));
pw.print(" mInputFocusTransferStarted="); pw.println(mInputFocusTransferStarted);
}
public interface OverviewProxyListener {

View File

@@ -290,6 +290,8 @@ public class NotificationPanelView extends PanelView implements
private boolean mIsFullWidth;
private boolean mBlockingExpansionForCurrentTouch;
private boolean mExpectingOpenPanelGesture;
/**
* Current dark amount that follows regular interpolation curve of animation.
*/
@@ -1246,6 +1248,28 @@ public class NotificationPanelView extends PanelView implements
}
}
/**
* Input focus transfer is about to happen.
*/
public void startWaitingForOpenPanelGesture() {
if (!isFullyCollapsed()) {
return;
}
mExpectingOpenPanelGesture = true;
onTrackingStarted();
}
/**
* Input focus transfer has already happened as this view decided to intercept
* very first down event.
*/
public void stopWaitingForOpenPanelGesture() {
if (mExpectingOpenPanelGesture) {
mExpectingOpenPanelGesture = false;
onTrackingStopped(false);
}
}
@Override
protected boolean flingExpands(float vel, float vectorVel, float x, float y) {
boolean expands = super.flingExpands(vel, vectorVel, x, y);
@@ -1258,8 +1282,12 @@ public class NotificationPanelView extends PanelView implements
}
@Override
protected boolean hasConflictingGestures() {
return mBarState != StatusBarState.SHADE;
protected boolean shouldGestureWaitForTouchSlop() {
if (mExpectingOpenPanelGesture) {
mExpectingOpenPanelGesture = false;
return false;
}
return isFullyCollapsed() || mBarState != StatusBarState.SHADE;
}
@Override

View File

@@ -301,7 +301,7 @@ public abstract class PanelView extends FrameLayout {
final float y = event.getY(pointerIndex);
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mGestureWaitForTouchSlop = isFullyCollapsed() || hasConflictingGestures();
mGestureWaitForTouchSlop = shouldGestureWaitForTouchSlop();
mIgnoreXTouchSlop = isFullyCollapsed() || shouldGestureIgnoreXTouchSlop(x, y);
}
@@ -519,7 +519,7 @@ public abstract class PanelView extends FrameLayout {
return (int) (mUnlockFalsingThreshold * factor);
}
protected abstract boolean hasConflictingGestures();
protected abstract boolean shouldGestureWaitForTouchSlop();
protected abstract boolean shouldGestureIgnoreXTouchSlop(float x, float y);

View File

@@ -1918,19 +1918,18 @@ public class StatusBar extends SystemUI implements DemoMode,
mStatusBarKeyguardViewManager.readyForKeyguardDone();
}
public void dispatchNotificationsPanelTouchEvent(MotionEvent ev) {
/**
* Called when another window is about to transfer it's input focus.
*/
public void onInputFocusTransfer(boolean start) {
if (!mCommandQueue.panelsEnabled()) {
return;
}
mNotificationPanel.dispatchTouchEvent(ev);
int action = ev.getAction();
if (action == MotionEvent.ACTION_DOWN) {
// Start ignoring all touch events coming to status bar window.
// TODO: handle case where ACTION_UP is not sent over the binder
mStatusBarWindowController.setNotTouchable(true);
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mStatusBarWindowController.setNotTouchable(false);
if (start) {
mNotificationPanel.startWaitingForOpenPanelGesture();
} else {
mNotificationPanel.stopWaitingForOpenPanelGesture();
}
}