Skip to content

Commit 48a01d0

Browse files
committed
correctly spelling a span text
1 parent 216a30a commit 48a01d0

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import android.text.Spanned;
2020
import android.text.style.AbsoluteSizeSpan;
2121
import android.text.style.ClickableSpan;
22-
import android.util.Log;
2322
import android.view.View;
2423
import android.view.accessibility.AccessibilityEvent;
2524
import android.widget.TextView;
@@ -587,37 +586,24 @@ protected void onPopulateNodeForVirtualView(
587586
node.setBoundsInParent(getBoundsInParent(accessibleTextSpan));
588587
node.setRoleDescription(mView.getResources().getString(R.string.link_description));
589588
node.setClassName(AccessibilityRole.getValue(AccessibilityRole.BUTTON));
590-
Log.w("TESTING::ReactAccessibilityDelegate", "mAccessibilitySpans: " + (mAccessibilitySpans));
591589
if (mAccessibilitySpans == null) {
592590
return;
593591
}
594592
final AccessibilityLinks.AccessibleLink ttsSpan =
595593
mAccessibilitySpans.getLinkById(virtualViewId);
596-
Log.w("TESTING::ReactAccessibilityDelegate", "ttsSpan: " + (ttsSpan));
597594
if (ttsSpan == null) {
598595
return;
599596
}
600-
Log.w("TESTING::ReactAccessibilityDelegate", "node.getText(): " + (node.getText()));
601597
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);
606605
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+
}
621607
}
622608

623609
private Rect getBoundsInParent(AccessibilityLinks.AccessibleLink accessibleLink) {
@@ -700,6 +686,7 @@ public AccessibilityLinks(ReactTtsSpan[] spans, Spannable text) {
700686
final AccessibleLink link = new AccessibleLink();
701687
link.span = span;
702688
link.start = start;
689+
link.description = text.subSequence(start, end).toString();
703690
link.end = end;
704691

705692
// ID is the reverse of what is expected, since the ClickableSpans are returned in reverse

ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import android.text.StaticLayout;
2020
import android.text.TextPaint;
2121
import android.util.LayoutDirection;
22-
import android.util.Log;
2322
import android.util.LruCache;
2423
import android.view.View;
2524
import androidx.annotation.NonNull;
@@ -156,9 +155,6 @@ private static void buildSpannableFromFragment(
156155
start, end, new ReactBackgroundColorSpan(textAttributes.mBackgroundColor)));
157156
*/
158157
if (Build.VERSION.SDK_INT > 21 && textAttributes.mBackgroundColor == -65536) {
159-
Log.w(
160-
"TESTING::TextLayoutManagerMapBuffer",
161-
"textAttributes.mBackgroundColor: " + (textAttributes.mBackgroundColor));
162158
ops.add(
163159
new SetSpanOperation(
164160
start, end, new ReactTtsSpan.Builder(ReactTtsSpan.TYPE_VERBATIM).build()));

0 commit comments

Comments
 (0)