|
12 | 12 |
|
13 | 13 | import android.content.Context;
|
14 | 14 | import android.graphics.Color;
|
| 15 | +import android.graphics.Paint; |
15 | 16 | import android.graphics.Rect;
|
16 | 17 | import android.graphics.Typeface;
|
17 | 18 | import android.graphics.drawable.Drawable;
|
|
54 | 55 | import com.facebook.react.views.text.ReactBackgroundColorSpan;
|
55 | 56 | import com.facebook.react.views.text.ReactForegroundColorSpan;
|
56 | 57 | import com.facebook.react.views.text.ReactSpan;
|
| 58 | +import com.facebook.react.views.text.ReactStrikethroughSpan; |
57 | 59 | import com.facebook.react.views.text.ReactTextUpdate;
|
58 | 60 | import com.facebook.react.views.text.ReactTypefaceUtils;
|
| 61 | +import com.facebook.react.views.text.ReactUnderlineSpan; |
59 | 62 | import com.facebook.react.views.text.TextAttributes;
|
60 | 63 | import com.facebook.react.views.text.TextInlineImageSpan;
|
61 | 64 | import com.facebook.react.views.text.TextLayoutManager;
|
@@ -668,6 +671,26 @@ public boolean test(ReactForegroundColorSpan span) {
|
668 | 671 | return span.getForegroundColor() == getCurrentTextColor();
|
669 | 672 | }
|
670 | 673 | });
|
| 674 | + |
| 675 | + stripSpansOfKind( |
| 676 | + sb, |
| 677 | + ReactStrikethroughSpan.class, |
| 678 | + new SpanPredicate<ReactStrikethroughSpan>() { |
| 679 | + @Override |
| 680 | + public boolean test(ReactStrikethroughSpan span) { |
| 681 | + return (getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0; |
| 682 | + } |
| 683 | + }); |
| 684 | + |
| 685 | + stripSpansOfKind( |
| 686 | + sb, |
| 687 | + ReactUnderlineSpan.class, |
| 688 | + new SpanPredicate<ReactUnderlineSpan>() { |
| 689 | + @Override |
| 690 | + public boolean test(ReactUnderlineSpan span) { |
| 691 | + return (getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0; |
| 692 | + } |
| 693 | + }); |
671 | 694 | }
|
672 | 695 |
|
673 | 696 | private <T> void stripSpansOfKind(
|
@@ -701,6 +724,14 @@ private void restoreStyleEquivalentSpans(SpannableStringBuilder workingText) {
|
701 | 724 | spans.add(new ReactBackgroundColorSpan(backgroundColor));
|
702 | 725 | }
|
703 | 726 |
|
| 727 | + if ((getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0) { |
| 728 | + spans.add(new ReactStrikethroughSpan()); |
| 729 | + } |
| 730 | + |
| 731 | + if ((getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0) { |
| 732 | + spans.add(new ReactUnderlineSpan()); |
| 733 | + } |
| 734 | + |
704 | 735 | for (Object span : spans) {
|
705 | 736 | workingText.setSpan(span, 0, workingText.length(), spanFlags);
|
706 | 737 | }
|
|
0 commit comments