diff options
Diffstat (limited to 'src/com/android/launcher3/PagedView.java')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 79d6ca793..ff2b40038 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1296,6 +1296,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { + Launcher launcher = Launcher.getLauncher(getContext()); + if (launcher != null) { + AbstractFloatingView.closeAllOpenViews(launcher); + } // Handle mouse (or ext. device) by shifting the page depending on the scroll final float vscroll; final float hscroll; @@ -1306,6 +1310,9 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL); hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); } + if (Math.abs(vscroll) > Math.abs(hscroll) && !isVerticalScrollable()) { + return true; + } if (hscroll != 0 || vscroll != 0) { boolean isForwardScroll = mIsRtl ? (hscroll < 0 || vscroll < 0) : (hscroll > 0 || vscroll > 0); @@ -1322,6 +1329,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou return super.onGenericMotionEvent(event); } + protected boolean isVerticalScrollable() { + return true; + } + private void acquireVelocityTrackerAndAddMovement(MotionEvent ev) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); @@ -1539,7 +1550,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou snapToPage(getNextPage() - 1); return true; } - return false; + return onOverscroll(-getMeasuredWidth()); } public boolean scrollRight() { @@ -1547,7 +1558,15 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou snapToPage(getNextPage() + 1); return true; } - return false; + return onOverscroll(getMeasuredWidth()); + } + + protected boolean onOverscroll(int amount) { + if (!mAllowOverScroll) return false; + onScrollInteractionBegin(); + overScroll(amount); + onScrollInteractionEnd(); + return true; } @Override @@ -1567,8 +1586,9 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); final boolean pagesFlipped = isPageOrderFlipped(); - info.setScrollable(getPageCount() > 1); - if (getCurrentPage() < getPageCount() - 1) { + int offset = (mAllowOverScroll ? 0 : 1); + info.setScrollable(getPageCount() > offset); + if (getCurrentPage() < getPageCount() - offset) { info.addAction(pagesFlipped ? AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); @@ -1576,7 +1596,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT); } - if (getCurrentPage() > 0) { + if (getCurrentPage() >= offset) { info.addAction(pagesFlipped ? AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); @@ -1584,7 +1604,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT); } - // Accessibility-wise, PagedView doesn't support long click, so disabling it. // Besides disabling the accessibility long-click, this also prevents this view from getting // accessibility focus. @@ -1603,7 +1622,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); - event.setScrollable(getPageCount() > 1); + event.setScrollable(mAllowOverScroll || getPageCount() > 1); } @Override |