Swipe between QS pages when using mouse scroll
Add the capability to switch between QS pages when scrolling using mouse
wheel.
Bug: 357179684
Flag: NONE not a new feature
Test: manually
Change-Id: Ia921f546bb260b1f4aa601a0224bd9952f01b52d
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 4018320..ca7b06a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -14,7 +14,10 @@
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.AttributeSet;
+import android.view.InputDevice;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
@@ -191,6 +194,34 @@
}
@Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0
+ && event.getAction() == MotionEvent.ACTION_SCROLL) {
+ // Handle mouse (or ext. device) by swiping the page depending on the scroll
+ final float vscroll;
+ final float hscroll;
+ if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
+ vscroll = 0;
+ hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+ } else {
+ vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+ hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
+ }
+ if (hscroll != 0 || vscroll != 0) {
+ boolean isForwardScroll =
+ isLayoutRtl() ? (hscroll < 0 || vscroll < 0) : (hscroll > 0 || vscroll > 0);
+ int swipeDirection = isForwardScroll ? RIGHT : LEFT;
+ if (mScroller.isFinished()) {
+ scrollByX(getDeltaXForPageScrolling(swipeDirection),
+ SINGLE_PAGE_SCROLL_DURATION_MILLIS);
+ }
+ return true;
+ }
+ }
+ return super.onGenericMotionEvent(event);
+ }
+
+ @Override
public void setCurrentItem(int item, boolean smoothScroll) {
if (isLayoutRtl()) {
item = mPages.size() - 1 - item;