From 94e276c1c5f477d687a0cced04c1d715ce8e111c Mon Sep 17 00:00:00 2001 From: Shamali P Date: Wed, 26 Feb 2025 15:14:32 +0000 Subject: [PATCH] Fix home screen page description when removing an existing page. When we remove an in-between or last empty page, we manually set the current page but don't update the description that's set on the accessibility view. Due to which, when talkback focuses on it, it sees the stale page count in the description. This fix ensures to keep the state updated during removal. Bug: 390360063 Fix: 390360063 Test: Talkback Flag: EXEMPT BUGFIX Change-Id: Idd9a54d3a1ee43e56f51db78e614776eca6a12f7 --- src/com/android/launcher3/Workspace.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 94ff44145b..632cdf929b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -893,6 +893,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. @@ -1118,6 +1121,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(); } /** @@ -3513,6 +3519,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()); }