Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

a11y: Add SemanticsAction "showOnScreen" #3856

Merged
merged 1 commit into from
Jul 12, 2017

Conversation

goderbauer
Copy link
Member

@goderbauer goderbauer commented Jul 10, 2017

This action is triggered when the user swipes (in accessibility mode) to the last visible item of a scrollable list to bring that item fully on screen.

iOS implementation to follow.

Addresses flutter/flutter#1714 for Android.

This action is triggered when the user swipes (in accessibility mode) to the last visible item of a scrollable list to bring that item fully on screen.

iOS implementation to follow.
@@ -77,7 +78,7 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {

AccessibilityNodeInfo result = AccessibilityNodeInfo.obtain(mOwner, virtualViewId);
result.setPackageName(mOwner.getContext().getPackageName());
result.setClassName("Flutter"); // Prettier than the more conventional node.getClass().getName()
result.setClassName("Flutter"); // TODO(goderbauer): Set proper class names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android TalkBack uses the class to determine how to behave (for an example see below where I set the class to ScrollView to get the correct scroll behavoir). And if you set the class to button for example, Android talkback will correctly announce that it is a button. There are more classes with special meaning, apparently.

@Hixie
Copy link
Contributor

Hixie commented Jul 11, 2017

Does this mean you found the magic way that lists get scrolled?

@@ -117,6 +118,9 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
result.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
result.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
result.setScrollable(true);
// This tells Android's a11y to send scroll events when reaching the end of
// the visible viewport of a scrollable.
result.setClassName("android.widget.ScrollView");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. The magic is to fake which class you are?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That's exactly it.

@goderbauer goderbauer merged commit 63bf1d2 into flutter:master Jul 12, 2017
@goderbauer goderbauer deleted the showOnScreen branch July 12, 2017 22:52
goderbauer added a commit to goderbauer/flutter that referenced this pull request Jul 19, 2017
This action is triggered when the user swipes (in accessibility mode) to the last visible item of a scrollable list to bring that item fully on screen.

This requires engine rolled to flutter/engine#3856.

I am in the process of adding tests, but I'd like to get early feedback to see if this approach is OK.
goderbauer added a commit to flutter/flutter that referenced this pull request Jul 19, 2017
* a11y: implement new SemanticsAction "showOnScreen" (v2)

This action is triggered when the user swipes (in accessibility mode) to the last visible item of a scrollable list to bring that item fully on screen.

This requires engine rolled to flutter/engine#3856.

I am in the process of adding tests, but I'd like to get early feedback to see if this approach is OK.

* fix null check

* review comments

* review comments

* Add test

* fix analyzer warning
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants