|
19 | 19 | import android.text.Spanned; |
20 | 20 | import android.text.style.AbsoluteSizeSpan; |
21 | 21 | import android.text.style.ClickableSpan; |
22 | | -import android.util.Log; |
23 | 22 | import android.view.View; |
24 | 23 | import android.view.accessibility.AccessibilityEvent; |
25 | 24 | import android.widget.TextView; |
@@ -587,37 +586,24 @@ protected void onPopulateNodeForVirtualView( |
587 | 586 | node.setBoundsInParent(getBoundsInParent(accessibleTextSpan)); |
588 | 587 | node.setRoleDescription(mView.getResources().getString(R.string.link_description)); |
589 | 588 | node.setClassName(AccessibilityRole.getValue(AccessibilityRole.BUTTON)); |
590 | | - Log.w("TESTING::ReactAccessibilityDelegate", "mAccessibilitySpans: " + (mAccessibilitySpans)); |
591 | 589 | if (mAccessibilitySpans == null) { |
592 | 590 | return; |
593 | 591 | } |
594 | 592 | final AccessibilityLinks.AccessibleLink ttsSpan = |
595 | 593 | mAccessibilitySpans.getLinkById(virtualViewId); |
596 | | - Log.w("TESTING::ReactAccessibilityDelegate", "ttsSpan: " + (ttsSpan)); |
597 | 594 | if (ttsSpan == null) { |
598 | 595 | return; |
599 | 596 | } |
600 | | - Log.w("TESTING::ReactAccessibilityDelegate", "node.getText(): " + (node.getText())); |
601 | 597 | if (mView instanceof TextView) { |
602 | | - TextView textView = (TextView) mView; |
603 | | - Log.w("TESTING::ReactAccessibilityDelegate", "textView.getText(): " + (textView.getText())); |
604 | | - SpannableString spannableString = new SpannableString(textView.getText()); |
605 | | - spannableString.setSpan(ttsSpan.span, 0, java.lang.Math.min(6, ttsSpan.end), 0); |
| 598 | + CharSequence textViewText = ((TextView) mView).getText(); |
| 599 | + SpannableString spannableString = new SpannableString(textViewText); |
| 600 | + spannableString.setSpan( |
| 601 | + ttsSpan.span, |
| 602 | + java.lang.Math.min(textViewText.length(), ttsSpan.start), |
| 603 | + java.lang.Math.max(ttsSpan.start, ttsSpan.end - 1), |
| 604 | + 0); |
606 | 605 | node.setContentDescription(spannableString); |
607 | | - // node.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK); |
608 | | - // node.setRoleDescription(mView.getResources().getString(R.string.link_description)); |
609 | | - // node.setHeading(true); |
610 | | - // node.setRoleDescription("heading"); |
611 | | - // node.setClassName(AccessibilityRole.getValue(AccessibilityRole.BUTTON)); |
612 | | - } |
613 | | - // String string = "my test string"; |
614 | | - Log.w("TESTING::ReactAccessibilityDelegate", "ttsSpan.span: " + (ttsSpan.span)); |
615 | | - Log.w("TESTING::ReactAccessibilityDelegate", "ttsSpan.end: " + (ttsSpan.end)); |
616 | | - Log.w( |
617 | | - "TESTING::ReactAccessibilityDelegate", |
618 | | - "ttsSpan.span.getArgs(): " + (ttsSpan.span.getArgs())); |
619 | | - // TtsSpan ttsSpan = new TtsSpan.Builder(TtsSpan.TYPE_VERBATIM).build(); |
620 | | - |
| 606 | + } |
621 | 607 | } |
622 | 608 |
|
623 | 609 | private Rect getBoundsInParent(AccessibilityLinks.AccessibleLink accessibleLink) { |
@@ -700,6 +686,7 @@ public AccessibilityLinks(ReactTtsSpan[] spans, Spannable text) { |
700 | 686 | final AccessibleLink link = new AccessibleLink(); |
701 | 687 | link.span = span; |
702 | 688 | link.start = start; |
| 689 | + link.description = text.subSequence(start, end).toString(); |
703 | 690 | link.end = end; |
704 | 691 |
|
705 | 692 | // ID is the reverse of what is expected, since the ClickableSpans are returned in reverse |
|
0 commit comments