Properly identify CheckBox and RadioButton on Android (flutter/engine#4547)
This commit is contained in:
committed by
GitHub
parent
9cadf74d34
commit
2c53613b1f
@@ -147,6 +147,7 @@ class SemanticsFlag {
|
||||
static const int _kIsFocusedIndex = 1 << 5;
|
||||
static const int _kHasEnabledStateIndex = 1 << 6;
|
||||
static const int _kIsEnabledIndex = 1 << 7;
|
||||
static const int _kIsInMutuallyExclusiveGroupIndex = 1 << 8;
|
||||
|
||||
const SemanticsFlag._(this.index);
|
||||
|
||||
@@ -210,6 +211,12 @@ class SemanticsFlag {
|
||||
/// marked as disabled.
|
||||
static const SemanticsFlag isEnabled = const SemanticsFlag._(_kIsEnabledIndex);
|
||||
|
||||
/// Whether a semantic node is in a mutually exclusive group.
|
||||
///
|
||||
/// For example, a radio button is in a mutually exclusive group because
|
||||
/// only one radio button in that group can be marked as [isChecked].
|
||||
static const SemanticsFlag isInMutuallyExclusiveGroup = const SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);
|
||||
|
||||
/// The possible semantics flags.
|
||||
///
|
||||
/// The map's key is the [index] of the flag and the value is the flag itself.
|
||||
@@ -222,6 +229,7 @@ class SemanticsFlag {
|
||||
_kIsFocusedIndex: isFocused,
|
||||
_kHasEnabledStateIndex: hasEnabledState,
|
||||
_kIsEnabledIndex: isEnabled,
|
||||
_kIsInMutuallyExclusiveGroupIndex: isInMutuallyExclusiveGroup,
|
||||
};
|
||||
|
||||
@override
|
||||
@@ -243,6 +251,8 @@ class SemanticsFlag {
|
||||
return 'SemanticsFlag.hasEnabledState';
|
||||
case _kIsEnabledIndex:
|
||||
return 'SemanticsFlag.isEnabled';
|
||||
case _kIsInMutuallyExclusiveGroupIndex:
|
||||
return 'SemanticsFlag.isInMutuallyExclusiveGroup';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
IS_TEXT_FIELD(1 << 4),
|
||||
IS_FOCUSED(1 << 5),
|
||||
HAS_ENABLED_STATE(1 << 6),
|
||||
IS_ENABLED(1 << 7);
|
||||
IS_ENABLED(1 << 7),
|
||||
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(1 << 8);
|
||||
|
||||
Flag(int value) {
|
||||
this.value = value;
|
||||
@@ -198,8 +199,16 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
}
|
||||
}
|
||||
|
||||
result.setCheckable(object.hasFlag(Flag.HAS_CHECKED_STATE));
|
||||
result.setChecked(object.hasFlag(Flag.IS_CHECKED));
|
||||
boolean hasCheckedState = object.hasFlag(Flag.HAS_CHECKED_STATE);
|
||||
result.setCheckable(hasCheckedState);
|
||||
if (hasCheckedState) {
|
||||
result.setChecked(object.hasFlag(Flag.IS_CHECKED));
|
||||
if (object.hasFlag(Flag.IS_IN_MUTUALLY_EXCLUSIVE_GROUP))
|
||||
result.setClassName("android.widget.RadioButton");
|
||||
else
|
||||
result.setClassName("android.widget.CheckBox");
|
||||
}
|
||||
|
||||
result.setSelected(object.hasFlag(Flag.IS_SELECTED));
|
||||
result.setText(object.getValueLabelHint());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user