diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 559582879e..1b5e2e68b4 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -891,6 +891,9 @@ public class Workspace extends PagedView mScreenOrder.removeValue(extraEmptyPageId); }); + // Since we removed some screens, before moving to next page, update the state + // description with correct page numbers. + updateAccessibilityViewPageDescription(); setCurrentPage(getNextPage()); // Update the page indicator to reflect the removed page. @@ -1116,6 +1119,9 @@ public class Workspace extends PagedView if (pageShift >= 0) { setCurrentPage(currentPage - pageShift); } + + // Now that we have removed some pages, ensure state description is up to date. + updateAccessibilityViewPageDescription(); } /** @@ -3479,6 +3485,18 @@ public class Workspace extends PagedView protected void announcePageForAccessibility() { // Talkback focuses on AccessibilityActionView by default, so we need to modify the state // description there in order for the change in page scroll to be announced. + updateAccessibilityViewPageDescription(); + } + + /** + * Updates the state description that is set on the accessibility actions view for the + * workspace. + *

The updated value is called out when talkback focuses on the view and is not disruptive. + *

+ */ + protected void updateAccessibilityViewPageDescription() { + // Set the state description on accessibility action view so that when it is focused, + // talkback describes the correct state of home screen pages. ViewCompat.setStateDescription(mLauncher.getAccessibilityActionView(), getCurrentPageDescription()); }