diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-09-24 21:37:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-09-24 21:37:01 +0000 |
commit | ff4977d42d57b130a7512980b671a1baaa1daf14 (patch) | |
tree | 0d0351cae3d742af55bf32a04deaa7c015ab0514 | |
parent | 32a3421f1ad4d612ec64b475406fafeea7ec093d (diff) | |
parent | 7752023c08643554ef422447c8ed841476137f8f (diff) | |
download | android_packages_apps_Trebuchet-ff4977d42d57b130a7512980b671a1baaa1daf14.tar.gz android_packages_apps_Trebuchet-ff4977d42d57b130a7512980b671a1baaa1daf14.tar.bz2 android_packages_apps_Trebuchet-ff4977d42d57b130a7512980b671a1baaa1daf14.zip |
Merge changes from topic "a11y-minus-one" into ub-launcher3-qt-future-dev
* changes:
fix test for a11y change in supporting -1 page
Revert "Revert "support scroll backward to minus one screen via voice/switch access""
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/testing/TestInformationHandler.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/testing/TestProtocol.java | 2 | ||||
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/Workspace.java | 11 |
5 files changed, 47 insertions, 13 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index a99c7c28f..34b102c0b 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 @@ -1700,4 +1708,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou mTmpIntPair[1] = rightChild; return mTmpIntPair; } + + /** + * Returns true if overscroll is allowed, otherwise false. + */ + public boolean allowOverScroll() { + return mAllowOverScroll; + } } 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 && diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 0d1d1a670..d62b591b8 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -15,9 +15,10 @@ */ package com.android.launcher3.testing; -import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static android.graphics.Bitmap.Config.ARGB_8888; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; + import android.content.Context; import android.graphics.Bitmap; import android.graphics.Color; @@ -81,6 +82,14 @@ public class TestInformationHandler implements ResourceBasedOverride { break; } + case TestProtocol.REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE: { + if (mLauncher == null) return null; + + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, + mLauncher.getWorkspace().getPageCount() > 1); + break; + } + case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: { response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, true); break; diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index d286ae211..d0d31d043 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -66,6 +66,8 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; + public static final String REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE = + "does-workspace-have-second-page"; public static final String REQUEST_HOTSEAT_TOP = "hotseat-top"; public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized"; public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list"; diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 510ea1409..d556afc9b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -22,6 +22,7 @@ import static junit.framework.TestCase.assertTrue; import android.graphics.Point; import android.graphics.Rect; +import android.os.Bundle; import android.os.SystemClock; import android.view.KeyEvent; import android.view.MotionEvent; @@ -125,7 +126,7 @@ public final class Workspace extends Home { */ public void ensureWorkspaceIsScrollable() { final UiObject2 workspace = verifyActiveContainer(); - if (!isWorkspaceScrollable(workspace)) { + if (!isWorkspaceScrollable()) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging icon to a second page of workspace to make it scrollable")) { dragIconToWorkspace( @@ -137,12 +138,12 @@ public final class Workspace extends Home { verifyActiveContainer(); } } - assertTrue("Home screen workspace didn't become scrollable", - isWorkspaceScrollable(workspace)); + assertTrue("Home screen workspace didn't become scrollable", isWorkspaceScrollable()); } - private boolean isWorkspaceScrollable(UiObject2 workspace) { - return workspace.isScrollable(); + private boolean isWorkspaceScrollable() { + Bundle result = mLauncher.getTestInfo(TestProtocol.REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE); + return result.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); } @NonNull |