From 02cc84889625ada6f601203e494aae94577db199 Mon Sep 17 00:00:00 2001 From: yingleiw Date: Fri, 2 Aug 2019 16:14:27 -0700 Subject: [PATCH] Add directional accessibility page actions to PagedView For PagedView, when isPageOrderFlipped is true, it means the LTR mode is flipped. For the "recents" in launcher, isPageOrderFlipped is true. However, this doesn't affect the directional page operations since scrollLeft()/Right() already has correct Rtl considerations. See b/78788182 for more information on the LTR mode. Test: Tested with the "recents" in launcher. Verified that page left action always move pages to the right (so that the next page from the left side shows), and page right actions always move pages to the left (so that the next page from the right side shows). Also tested with the home screen 1/2, 2/2 paging. Bug: 136277517 Change-Id: I965d651c37d258eaa8ea347d1ad6f698f9b590bf --- src/com/android/launcher3/PagedView.java | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index d2b8d4e300..bbb3915b58 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1562,12 +1562,20 @@ public abstract class PagedView extends ViewGrou final boolean pagesFlipped = isPageOrderFlipped(); info.setScrollable(getPageCount() > 1); if (getCurrentPage() < getPageCount() - 1) { - info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD - : AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + info.addAction(pagesFlipped ? + AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD + : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); + info.addAction(mIsRtl ? + AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT + : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT); } if (getCurrentPage() > 0) { - info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD - : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + info.addAction(pagesFlipped ? + AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD + : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); + info.addAction(mIsRtl ? + AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT + : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT); } // Accessibility-wise, PagedView doesn't support long click, so disabling it. @@ -1607,8 +1615,21 @@ public abstract class PagedView extends ViewGrou if (pagesFlipped ? scrollRight() : scrollLeft()) { return true; } + } break; + case android.R.id.accessibilityActionPageRight: { + if (!mIsRtl) { + return scrollRight(); + } else { + return scrollLeft(); + } + } + case android.R.id.accessibilityActionPageLeft: { + if (!mIsRtl) { + return scrollLeft(); + } else { + return scrollRight(); + } } - break; } return false; }