|
25 | 25 | import com.facebook.react.uimanager.LayoutShadowNode;
|
26 | 26 | import com.facebook.react.uimanager.NativeViewHierarchyOptimizer;
|
27 | 27 | import com.facebook.react.uimanager.PixelUtil;
|
| 28 | +import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole; |
28 | 29 | import com.facebook.react.uimanager.ReactShadowNode;
|
29 | 30 | import com.facebook.react.uimanager.ViewProps;
|
30 | 31 | import com.facebook.react.uimanager.annotations.ReactProp;
|
@@ -184,10 +185,10 @@ private static void buildSpannedFromShadowNode(
|
184 | 185 | ops.add(
|
185 | 186 | new SetSpanOperation(start, end, new ReactClickableSpan(textShadowNode.getReactTag())));
|
186 | 187 | }
|
187 |
| - if (textShadowNode.mIsAccessibilityUnit && Build.VERSION.SDK_INT >= 21) { |
| 188 | + if (textShadowNode.mAccessibilityUnit != null && Build.VERSION.SDK_INT >= 21) { |
188 | 189 | ops.add(
|
189 | 190 | new SetSpanOperation(
|
190 |
| - start, end, new ReactTtsSpan.Builder(textShadowNode.mAccessibilityRole).build())); |
| 191 | + start, end, new ReactTtsSpan.Builder(textShadowNode.mAccessibilityUnit).build())); |
191 | 192 | }
|
192 | 193 | float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing();
|
193 | 194 | if (!Float.isNaN(effectiveLetterSpacing)
|
@@ -330,9 +331,8 @@ protected Spannable spannedFromShadowNode(
|
330 | 331 | protected int mColor;
|
331 | 332 | protected boolean mIsBackgroundColorSet = false;
|
332 | 333 | protected int mBackgroundColor;
|
333 |
| - protected String mAccessibilityRole; |
| 334 | + protected @Nullable String mAccessibilityUnit = null; |
334 | 335 | protected boolean mIsAccessibilityLink = false;
|
335 |
| - protected boolean mIsAccessibilityUnit; |
336 | 336 |
|
337 | 337 | protected int mNumberOfLines = UNSET;
|
338 | 338 | protected int mTextAlign = Gravity.NO_GRAVITY;
|
@@ -507,10 +507,11 @@ public void setBackgroundColor(@Nullable Integer color) {
|
507 | 507 | @ReactProp(name = ViewProps.ACCESSIBILITY_ROLE)
|
508 | 508 | public void setIsAccessibilityLink(@Nullable String accessibilityRole) {
|
509 | 509 | if (isVirtual()) {
|
510 |
| - mAccessibilityRole = accessibilityRole; |
| 510 | + String roleClassName = |
| 511 | + AccessibilityRole.getValue(AccessibilityRole.fromValue(accessibilityRole)); |
511 | 512 | mIsAccessibilityLink = Objects.equals(accessibilityRole, "link");
|
512 |
| - Set<String> TYPES = Set.of("verbatim", "date"); |
513 |
| - mIsAccessibilityUnit = TYPES.contains(accessibilityRole); |
| 513 | + Set<String> UNIT_TYPES = Set.of(ReactTtsSpan.TYPE_VERBATIM, ReactTtsSpan.TYPE_DATE); |
| 514 | + mAccessibilityUnit = UNIT_TYPES.contains(roleClassName) ? roleClassName : null; |
514 | 515 | markUpdated();
|
515 | 516 | }
|
516 | 517 | }
|
|
0 commit comments