summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andre Le <leandre@google.com> 2024-09-06 21:18:34 +0000
committer Andre Le <leandre@google.com> 2024-09-06 21:18:34 +0000
commit11ea25d2e32d540300dc27805e5457c95842a81d (patch)
treed4b546a4b021cf43a80153dbdd308d8a40a260f7
parentd81988e0b2da0198c6c57e6bd32761b2c92ec9bc (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 4018320f2195..ca7b06a16a72 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.Context;
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 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
}
@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;