diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-04-05 18:02:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-05 18:02:25 +0000 |
commit | f54a8f345bde9a17b0cfbea9bc6c43189bd5209c (patch) | |
tree | d71816482151bc636bcf9c5d363bee066c568114 /src | |
parent | 83bf457aaad9ba96fa5e5ae98c3434cb7559fe60 (diff) | |
parent | 2c430b34cbab3d156c93d90b457b70e3a869ec0a (diff) | |
download | android_packages_apps_Trebuchet-f54a8f345bde9a17b0cfbea9bc6c43189bd5209c.tar.gz android_packages_apps_Trebuchet-f54a8f345bde9a17b0cfbea9bc6c43189bd5209c.tar.bz2 android_packages_apps_Trebuchet-f54a8f345bde9a17b0cfbea9bc6c43189bd5209c.zip |
Merge "Avoid duplicate accessibility announcement upon switching to -1st page" into ub-launcher3-master
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 20 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 79993c11a..15bf76da5 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -424,6 +424,13 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou return computeScrollHelper(true); } + protected void announcePageForAccessibility() { + if (isAccessibilityEnabled(getContext())) { + // Notify the user when the page changes + announceForAccessibility(getCurrentPageDescription()); + } + } + protected boolean computeScrollHelper(boolean shouldInvalidate) { if (mScroller.computeScrollOffset()) { // Don't bother scrolling if the page does not need to be moved @@ -452,9 +459,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou pageEndTransition(); } - if (isAccessibilityEnabled(getContext())) { - // Notify the user when the page changes - announceForAccessibility(getCurrentPageDescription()); + if (canAnnouncePageDescription()) { + announcePageForAccessibility(); } } return false; @@ -1535,6 +1541,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou return getCurrentPageDescription(); } + protected boolean canAnnouncePageDescription() { + return true; + } + protected String getCurrentPageDescription() { return getContext().getString(R.string.default_scroll_format, getNextPage() + 1, getChildCount()); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index a208c7a54..1e2e3b10b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1148,30 +1148,37 @@ public class Workspace extends PagedView<WorkspacePageIndicator> * The overlay scroll is being controlled locally, just update our overlay effect */ public void onOverlayScrollChanged(float scroll) { - if (Float.compare(scroll, 1f) == 0) { if (!mOverlayShown) { mLauncher.getUserEventDispatcher().logActionOnContainer(Action.Touch.SWIPE, Action.Direction.LEFT, ContainerType.WORKSPACE, 0); } mOverlayShown = true; + // Not announcing the overlay page for accessibility since it announces itself. } else if (Float.compare(scroll, 0f) == 0) { if (mOverlayShown) { mLauncher.getUserEventDispatcher().logActionOnContainer(Action.Touch.SWIPE, Action.Direction.RIGHT, ContainerType.WORKSPACE, -1); + } else if (Float.compare(mOverlayTranslation, 0f) != 0) { + // When arriving to 0 overscroll from non-zero overscroll, announce page for + // accessibility since default announcements were disabled while in overscroll + // state. + // Not doing this if mOverlayShown because in that case the accessibility service + // will announce the launcher window description upon regaining focus after + // switching from the overlay screen. + announcePageForAccessibility(); } mOverlayShown = false; tryRunOverlayCallback(); } + float offset = 0f; - float slip = 0f; scroll = Math.max(scroll - offset, 0); scroll = Math.min(1, scroll / (1 - offset)); float alpha = 1 - Interpolators.DEACCEL_3.getInterpolation(scroll); float transX = mLauncher.getDragLayer().getMeasuredWidth() * scroll; - transX *= 1 - slip; if (mIsRtl) { transX = -transX; @@ -3350,6 +3357,13 @@ public class Workspace extends PagedView<WorkspacePageIndicator> } @Override + protected boolean canAnnouncePageDescription() { + // Disable announcements while overscrolling potentially to overlay screen because if we end + // up on the overlay screen, it will take care of announcing itself. + return Float.compare(mOverlayTranslation, 0f) == 0; + } + + @Override protected String getCurrentPageDescription() { int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage; return getPageDescription(page); |