Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationGestureAction.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubAction.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java +11 −12 Original line number Diff line number Diff line Loading @@ -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); } } } Loading @@ -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 Loading @@ -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; } Loading @@ -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 Loading Loading @@ -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; } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading @@ -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 Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationGestureAction.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubAction.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java +11 −12 Original line number Diff line number Diff line Loading @@ -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); } } } Loading @@ -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 Loading @@ -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; } Loading @@ -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 Loading Loading @@ -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; } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading @@ -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 Loading