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
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 94ff441..632cdf9 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -893,6 +893,9 @@
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 @@
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 @@
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.
+ * <p>The updated value is called out when talkback focuses on the view and is not disruptive.
+ * </p>
+ */
+ 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());
}