Skip to content

Commit 8bb0441

Browse files
authored
Revert "Fixes Android text field to use hint text for accessibility (flutter#36846)" (flutter#37083)
This reverts commit f7ed46a.
1 parent 8fcf413 commit 8bb0441

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

shell/platform/android/io/flutter/view/AccessibilityBridge.java

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,7 @@ && shouldSetCollectionInfo(semanticsNode)) {
885885
// Scopes routes are not focusable, only need to set the content
886886
// for non-scopes-routes semantics nodes.
887887
if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
888-
result.setText(semanticsNode.getValue());
889-
result.setHintText(semanticsNode.getTextFieldHint());
888+
result.setText(semanticsNode.getValueLabelHint());
890889
} else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) {
891890
CharSequence content = semanticsNode.getValueLabelHint();
892891
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
@@ -2774,47 +2773,18 @@ private float max(float a, float b, float c, float d) {
27742773
return Math.max(a, Math.max(b, Math.max(c, d)));
27752774
}
27762775

2777-
private CharSequence getValue() {
2778-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
2779-
return value;
2780-
} else {
2781-
return createSpannableString(value, valueAttributes);
2782-
}
2783-
}
2784-
2785-
private CharSequence getLabel() {
2786-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
2787-
return label;
2788-
} else {
2789-
return createSpannableString(label, labelAttributes);
2790-
}
2791-
}
2792-
2793-
private CharSequence getHint() {
2776+
private CharSequence getValueLabelHint() {
2777+
CharSequence[] array;
27942778
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
2795-
return hint;
2779+
array = new CharSequence[] {value, label, hint};
27962780
} else {
2797-
return createSpannableString(hint, hintAttributes);
2781+
array =
2782+
new CharSequence[] {
2783+
createSpannableString(value, valueAttributes),
2784+
createSpannableString(label, labelAttributes),
2785+
createSpannableString(hint, hintAttributes),
2786+
};
27982787
}
2799-
}
2800-
2801-
private CharSequence getValueLabelHint() {
2802-
CharSequence[] array = new CharSequence[] {getValue(), getLabel(), getHint()};
2803-
CharSequence result = null;
2804-
for (CharSequence word : array) {
2805-
if (word != null && word.length() > 0) {
2806-
if (result == null || result.length() == 0) {
2807-
result = word;
2808-
} else {
2809-
result = TextUtils.concat(result, ", ", word);
2810-
}
2811-
}
2812-
}
2813-
return result;
2814-
}
2815-
2816-
private CharSequence getTextFieldHint() {
2817-
CharSequence[] array = new CharSequence[] {getLabel(), getHint()};
28182788
CharSequence result = null;
28192789
for (CharSequence word : array) {
28202790
if (word != null && word.length() > 0) {

shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,18 @@ public void itDescribesNonTextFieldsWithAContentDescription() {
7777
}
7878

7979
@Test
80-
public void itDescribesTextFieldsWithTextAndHint() {
80+
public void itDescribesTextFieldsWithText() {
8181
AccessibilityBridge accessibilityBridge = setUpBridge();
8282

8383
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
84-
testSemanticsNode.value = "Hello, World";
85-
testSemanticsNode.label = "some label";
86-
testSemanticsNode.hint = "some hint";
84+
testSemanticsNode.label = "Hello, World";
8785
testSemanticsNode.addFlag(AccessibilityBridge.Flag.IS_TEXT_FIELD);
8886
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
8987
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
9088
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
9189

9290
assertEquals(nodeInfo.getContentDescription(), null);
9391
assertEquals(nodeInfo.getText().toString(), "Hello, World");
94-
assertEquals(nodeInfo.getHintText().toString(), "some label, some hint");
9592
}
9693

9794
@Test

0 commit comments

Comments
 (0)