Merge "Fixed quickscrub regression"

This commit is contained in:
TreeHugger Robot
2018-12-04 11:16:43 +00:00
committed by Android (Google) Code Review
4 changed files with 29 additions and 13 deletions

View File

@@ -126,6 +126,15 @@ public abstract class NavigationGestureAction {
return true;
}
/**
* Decide if the controller should not send the current motion event to launcher via
* {@link OverviewProxyService}
* @return if controller should not proxy
*/
public boolean disableProxyEvents() {
return false;
}
/**
* Tell if action is enabled. Compared to {@link #canPerformAction()} this is based on settings
* if the action is disabled for a particular gesture. For example a back action can be enabled

View File

@@ -211,6 +211,11 @@ public class QuickScrubAction extends NavigationGestureAction {
return mNavigationBarView.isQuickScrubEnabled();
}
@Override
public boolean disableProxyEvents() {
return true;
}
@Override
protected void onGestureStart(MotionEvent event) {
updateHighlight();

View File

@@ -275,25 +275,21 @@ public class QuickStepController implements GestureHelper {
if (mDragVPositive ? (posV < touchDownV) : (posV > touchDownV)) {
// Swiping up gesture
tryToStartGesture(mGestureActions[ACTION_SWIPE_UP_INDEX],
false /* alignedWithNavBar */, false /* positiveDirection */,
event);
false /* alignedWithNavBar */, event);
} else {
// Swiping down gesture
tryToStartGesture(mGestureActions[ACTION_SWIPE_DOWN_INDEX],
false /* alignedWithNavBar */, true /* positiveDirection */,
event);
false /* alignedWithNavBar */, event);
}
} else if (exceededSwipeHorizontalTouchSlop) {
if (mDragHPositive ? (posH < touchDownH) : (posH > touchDownH)) {
// Swiping left (ltr) gesture
tryToStartGesture(mGestureActions[ACTION_SWIPE_LEFT_INDEX],
true /* alignedWithNavBar */, false /* positiveDirection */,
event);
true /* alignedWithNavBar */, event);
} else {
// Swiping right (ltr) gesture
tryToStartGesture(mGestureActions[ACTION_SWIPE_RIGHT_INDEX],
true /* alignedWithNavBar */, true /* positiveDirection */,
event);
true /* alignedWithNavBar */, event);
}
}
}
@@ -306,7 +302,6 @@ public class QuickStepController implements GestureHelper {
case MotionEvent.ACTION_UP:
if (mCurrentAction != null) {
mCurrentAction.endGesture();
mCurrentAction = null;
}
// Return the hit target back to its original position
@@ -329,6 +324,11 @@ public class QuickStepController implements GestureHelper {
if (shouldProxyEvents(action)) {
proxyMotionEvents(event);
}
// Clear action when gesture and event proxy finishes
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
mCurrentAction = null;
}
return mCurrentAction != null || deadZoneConsumed;
}
@@ -354,8 +354,7 @@ public class QuickStepController implements GestureHelper {
private boolean shouldProxyEvents(int action) {
final boolean actionValid = (mCurrentAction == null
|| (mGestureActions[ACTION_SWIPE_UP_INDEX] != null
&& mGestureActions[ACTION_SWIPE_UP_INDEX].isActive()));
|| !mCurrentAction.disableProxyEvents());
if (actionValid && !mIsInScreenPinning) {
// Allow down, cancel and up events, move and other events are passed if notifications
// are not showing and disabled gestures (such as long press) are not executed
@@ -455,7 +454,7 @@ public class QuickStepController implements GestureHelper {
}
private void tryToStartGesture(NavigationGestureAction action, boolean alignedWithNavBar,
boolean positiveDirection, MotionEvent event) {
MotionEvent event) {
if (action == null) {
return;
}

View File

@@ -38,12 +38,12 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.content.Context;
import com.android.systemui.R;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.SysuiTestCase;
import android.content.Context;
import android.content.res.Resources;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
@@ -395,6 +395,7 @@ public class QuickStepControllerTest extends SysuiTestCase {
verify(mProxy, times(1)).onQuickScrubStart();
verify(mProxyService, times(1)).notifyQuickScrubStarted();
verify(mNavigationBarView, times(1)).updateSlippery();
verify(mProxy, never()).onMotionEvent(moveEvent1);
// Move again for scrub
MotionEvent moveEvent2 = event(MotionEvent.ACTION_MOVE, 200, y);
@@ -402,6 +403,7 @@ public class QuickStepControllerTest extends SysuiTestCase {
assertEquals(action, mController.getCurrentAction());
verify(action, times(1)).onGestureMove(200, y);
verify(mProxy, times(1)).onQuickScrubProgress(1f / 2);
verify(mProxy, never()).onMotionEvent(moveEvent2);
// Action up
MotionEvent upEvent = event(MotionEvent.ACTION_UP, 1, y);
@@ -409,6 +411,7 @@ public class QuickStepControllerTest extends SysuiTestCase {
assertNull(mController.getCurrentAction());
verify(action, times(1)).onGestureEnd();
verify(mProxy, times(1)).onQuickScrubEnd();
verify(mProxy, never()).onMotionEvent(upEvent);
}
@Test