diff options
author | Pinyao Ting <pinyaoting@google.com> | 2019-09-18 22:18:03 +0000 |
---|---|---|
committer | Pinyao Ting <pinyaoting@google.com> | 2019-09-23 12:56:11 -0700 |
commit | af6daa2873a82e9222cad3589061e5c2b26702b5 (patch) | |
tree | b453125b817b5ec9ed410e16c1fb2b6126bb39ee /src/com | |
parent | 52b1ff2050538d9b70a7bad6d9b47e5c4217774b (diff) | |
download | android_packages_apps_Trebuchet-af6daa2873a82e9222cad3589061e5c2b26702b5.tar.gz android_packages_apps_Trebuchet-af6daa2873a82e9222cad3589061e5c2b26702b5.tar.bz2 android_packages_apps_Trebuchet-af6daa2873a82e9222cad3589061e5c2b26702b5.zip |
Revert "Revert "support scroll backward to minus one screen via voice/switch access""
This reverts commit 3ad4ace203c73aebac98010812703dbb6879d55d.
Reason for revert: roll forward and bugfixes
Change-Id: Icd56cdeddb3baf9819700cc567c04af0905825ef
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 22 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 7 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index a99c7c28f..5c790f379 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1548,7 +1548,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou snapToPage(getNextPage() - 1); return true; } - return false; + return onOverscroll(-getMeasuredWidth()); } public boolean scrollRight() { @@ -1556,7 +1556,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 @@ -1576,8 +1584,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); @@ -1585,7 +1594,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); @@ -1593,7 +1602,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. @@ -1612,7 +1620,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 diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index f9201d04c..1cb15db98 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1035,6 +1035,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator> } @Override + protected boolean onOverscroll(int amount) { + // Enforce overscroll on -1 direction + if ((amount > 0 && !mIsRtl) || (amount < 0 && mIsRtl)) return false; + return super.onOverscroll(amount); + } + + @Override protected boolean shouldFlingForVelocity(int velocityX) { // When the overlay is moving, the fling or settle transition is controlled by the overlay. return Float.compare(Math.abs(mOverlayTranslation), 0) == 0 && |