Merge "Fix home screen page description when removing an existing page." into main

This commit is contained in:
Treehugger Robot
2025-02-28 21:26:35 -08:00
committed by Android (Google) Code Review

View File

@@ -891,6 +891,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
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<T extends View & PageIndicator> extends PagedView<T>
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<T extends View & PageIndicator> extends PagedView<T>
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());
}