This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Sets accessibility panel title when route changes #27713
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1566,7 +1566,7 @@ void updateSemantics( | |||||||||
| if (lastAdded != null | ||||||||||
| && (lastAdded.id != previousRouteId || newRoutes.size() != flutterNavigationStack.size())) { | ||||||||||
| previousRouteId = lastAdded.id; | ||||||||||
| sendWindowChangeEvent(lastAdded); | ||||||||||
| onWindowNameChange(lastAdded); | ||||||||||
| } | ||||||||||
| flutterNavigationStack.clear(); | ||||||||||
| for (SemanticsNode semanticsNode : newRoutes) { | ||||||||||
|
|
@@ -1778,15 +1778,17 @@ private void sendAccessibilityEvent(@NonNull AccessibilityEvent event) { | |||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Creates a {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} and sends the event to Android's | ||||||||||
| * accessibility system. | ||||||||||
| * Informs the TalkBack user about window name changes. | ||||||||||
| * | ||||||||||
| * <p>This method sets accessibility panel title if the API level >= 28, otherwise, it creates a | ||||||||||
| * {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} and sends the event to Android's | ||||||||||
| * accessibility system. In both cases, TalkBack announces the label of the route and re-addjusts | ||||||||||
| * the accessibility focus. | ||||||||||
| * | ||||||||||
| * <p>The given {@code route} should be a {@link SemanticsNode} that represents a navigation route | ||||||||||
| * in the Flutter app. | ||||||||||
| */ | ||||||||||
| private void sendWindowChangeEvent(@NonNull SemanticsNode route) { | ||||||||||
| AccessibilityEvent event = | ||||||||||
| obtainAccessibilityEvent(route.id, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); | ||||||||||
| private void onWindowNameChange(@NonNull SemanticsNode route) { | ||||||||||
| String routeName = route.getRouteName(); | ||||||||||
| if (routeName == null) { | ||||||||||
| // The routeName will be null when there is no semantics node that represnets namesRoute in | ||||||||||
|
|
@@ -1799,8 +1801,20 @@ private void sendWindowChangeEvent(@NonNull SemanticsNode route) { | |||||||||
| // next. | ||||||||||
| routeName = " "; | ||||||||||
| } | ||||||||||
| event.getText().add(routeName); | ||||||||||
| sendAccessibilityEvent(event); | ||||||||||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||||||||||
| setAccessibilityPaneTitle(routeName); | ||||||||||
| } else { | ||||||||||
| AccessibilityEvent event = | ||||||||||
| obtainAccessibilityEvent(route.id, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); | ||||||||||
| event.getText().add(routeName); | ||||||||||
| sendAccessibilityEvent(event); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @TargetApi(28) | ||||||||||
| @RequiresApi(28) | ||||||||||
|
Comment on lines
+1814
to
+1815
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| private void setAccessibilityPaneTitle(String title) { | ||||||||||
| rootAccessibilityView.setAccessibilityPaneTitle(title); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.