-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semantics framework updates #5601
Changes from 42 commits
eb006ca
5329a88
446621b
87b2b01
f53d5e3
e3a3c58
fa7b778
65d55f1
cd9fa47
a82dd2f
38c62ae
91ea4f3
fca700a
e5cec1c
8915945
61e4617
7e060d2
37380f7
e21a2ae
d7bc1f6
fc98ca0
4cc928a
c83e15a
b75b257
8114b03
9169bf2
2ed58bd
4dbca6c
fb13c0f
1778dde
99fef79
788e239
c0d6d30
f25ae65
17e60b3
20134b4
89bfcc1
9efe1ac
f32c555
4249d62
8f2df6a
a1e0882
11ea454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ class SemanticsAction { | |
static const int _kDidGainAccessibilityFocusIndex = 1 << 15; | ||
static const int _kDidLoseAccessibilityFocusIndex = 1 << 16; | ||
static const int _kCustomAction = 1 << 17; | ||
static const int _kDismissIndex = 1 << 18; | ||
|
||
/// The numerical value for this action. | ||
/// | ||
|
@@ -148,11 +149,20 @@ class SemanticsAction { | |
static const SemanticsAction didLoseAccessibilityFocus = const SemanticsAction._(_kDidLoseAccessibilityFocusIndex); | ||
|
||
/// Indicates that the user has invoked a custom accessibility action. | ||
/// | ||
/// | ||
/// This handler is added automatically whenever a custom accessibility | ||
/// action is added to a semantics node. | ||
static const SemanticsAction customAction = const SemanticsAction._(_kCustomAction); | ||
|
||
/// A request that the node should be dismissed. | ||
/// | ||
/// A [Snackbar], for example, may have a dismiss action to indicate to the | ||
/// user that it can be removed after it is no longer relevant. On Android, | ||
/// (with TalkBack) special hint text is spoken when focusing the node and | ||
/// a custom action is availible in the local context menu. On iOS, | ||
/// (with VoiceOver) users can perform a standard gesture to dismiss it. | ||
static const SemanticsAction dismiss = const SemanticsAction._(_kDismissIndex); | ||
|
||
/// The possible semantics actions. | ||
/// | ||
/// The map's key is the [index] of the action and the value is the action | ||
|
@@ -176,6 +186,7 @@ class SemanticsAction { | |
_kDidGainAccessibilityFocusIndex: didGainAccessibilityFocus, | ||
_kDidLoseAccessibilityFocusIndex: didLoseAccessibilityFocus, | ||
_kCustomAction: customAction, | ||
_kDismissIndex: dismiss, | ||
}; | ||
|
||
@override | ||
|
@@ -217,6 +228,8 @@ class SemanticsAction { | |
return 'SemanticsAction.didLoseAccessibilityFocus'; | ||
case _kCustomAction: | ||
return 'SemanticsAction.customAction'; | ||
case _kDismissIndex: | ||
return 'SemanticsAction.dismiss'; | ||
} | ||
return null; | ||
} | ||
|
@@ -238,6 +251,10 @@ class SemanticsFlag { | |
static const int _kScopesRouteIndex= 1 << 11; | ||
static const int _kNamesRouteIndex = 1 << 12; | ||
static const int _kIsHiddenIndex = 1 << 13; | ||
static const int _kIsImageIndex = 1 << 14; | ||
static const int _kIsLiveRegionIndex = 1 << 15; | ||
static const int _kHasToggledStateIndex = 1 << 16; | ||
static const int _kIsToggledIndex = 1 << 17; | ||
|
||
const SemanticsFlag._(this.index); | ||
|
||
|
@@ -248,7 +265,13 @@ class SemanticsFlag { | |
|
||
/// The semantics node has the quality of either being "checked" or "unchecked". | ||
/// | ||
/// This flag is mutually exclusive with [hasToggledState]. | ||
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. We should enforce this with an assert on the framework side. 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. I was planning to do this in the same place with handle the scopesRoute assert |
||
/// | ||
/// For example, a checkbox or a radio button widget has checked state. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [SemanticsFlag.isChecked], which controls whether the node is "checked" or "unchecked". | ||
static const SemanticsFlag hasCheckedState = const SemanticsFlag._(_kHasCheckedStateIndex); | ||
|
||
/// Whether a semantics node that [hasCheckedState] is checked. | ||
|
@@ -257,6 +280,10 @@ class SemanticsFlag { | |
/// "unchecked". | ||
/// | ||
/// For example, if a checkbox has a visible checkmark, [isChecked] is true. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [SemanticsFlag.hasCheckedState], which enables a checked state. | ||
static const SemanticsFlag isChecked = const SemanticsFlag._(_kIsCheckedIndex); | ||
|
||
|
||
|
@@ -376,6 +403,44 @@ class SemanticsFlag { | |
/// used to implement accessibility scrolling on iOS. | ||
static const SemanticsFlag isHidden = const SemanticsFlag._(_kIsHiddenIndex); | ||
|
||
/// Whether the semantics node represents an image. | ||
/// | ||
/// Both TalkBack and VoiceOver will inform the user the the semantics node | ||
/// represents an image. | ||
static const SemanticsFlag isImage = const SemanticsFlag._(_kIsImageIndex); | ||
|
||
/// Whether the semantics node is a live region. | ||
/// | ||
/// A live region indicates that updates to semantics node are important. | ||
/// Platforms may use this information to make polite announcements to the | ||
/// user to inform them of updates to this node. | ||
/// | ||
/// An example of a live region is a [SnackBar] widget. On Android, A live | ||
/// region causes a polite announcement to be generated automatically, even | ||
/// if the user does not have focus of the widget. | ||
static const SemanticsFlag isLiveRegion = const SemanticsFlag._(_kIsLiveRegionIndex); | ||
|
||
/// The semantics node has the quality of either being "on" or "off". | ||
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. This doc should link to isToggled. 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. Done |
||
/// | ||
/// This flag is mutually exclusive with [hasCheckedState]. | ||
/// | ||
/// For example, a switch has toggled state. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [SemanticsFlag.isToggled], which controls whether the node is "on" or "off". | ||
static const SemanticsFlag hasToggledState = const SemanticsFlag._(_kHasToggledStateIndex); | ||
|
||
/// If true, the semantics node is "on". If false, the semantics node is | ||
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. And this doc to hasToggledState 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. Done |
||
/// "off". | ||
/// | ||
/// For example, if a switch is in the on position, [isToggled] is true. | ||
/// | ||
/// See also: | ||
/// | ||
/// * [SemanticsFlag.hasToggledState], which enables a toggled state. | ||
static const SemanticsFlag isToggled = const SemanticsFlag._(_kIsToggledIndex); | ||
|
||
/// The possible semantics flags. | ||
/// | ||
/// The map's key is the [index] of the flag and the value is the flag itself. | ||
|
@@ -394,6 +459,10 @@ class SemanticsFlag { | |
_kScopesRouteIndex: scopesRoute, | ||
_kNamesRouteIndex: namesRoute, | ||
_kIsHiddenIndex: isHidden, | ||
_kIsImageIndex: isImage, | ||
_kIsLiveRegionIndex: isLiveRegion, | ||
_kHasToggledStateIndex: hasToggledState, | ||
_kIsToggledIndex: isToggled, | ||
}; | ||
|
||
@override | ||
|
@@ -427,6 +496,14 @@ class SemanticsFlag { | |
return 'SemanticsFlag.namesRoute'; | ||
case _kIsHiddenIndex: | ||
return 'SemanticsFlag.isHidden'; | ||
case _kIsImageIndex: | ||
return 'SemanticsFlag.isImage'; | ||
case _kIsLiveRegionIndex: | ||
return 'SemanticsFlag.isLiveRegion'; | ||
case _kHasToggledStateIndex: | ||
return 'SemanticsFlag.hasToggledState'; | ||
case _kIsToggledIndex: | ||
return 'SemanticsFlag.isToggled'; | ||
} | ||
return null; | ||
} | ||
|
@@ -563,8 +640,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { | |
) native 'SemanticsUpdateBuilder_updateNode'; | ||
|
||
/// Update the custom accessibility action associated with the given `id`. | ||
/// | ||
/// The name of the action exposed to the user is the `label`. The text | ||
/// | ||
/// The name of the action exposed to the user is the `label`. The text | ||
/// direction of this label is the same as the global window. | ||
void updateCustomAction({int id, String label}) { | ||
assert(id != null); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does TalkBack expose the dismiss action? Is this not just a custom action of the snackbar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses https://developer.apple.com/documentation/uikit/accessibility/uiaccessibilityaction?language=objc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That link is for VoiceOver :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
derp, I meant: https://developer.apple.com/documentation/objectivec/nsobject/1615091-accessibilityperformescape?language=objc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what the ios MDC use for snackbar, for example