|
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; |
@@ -703,6 +706,26 @@ public boolean test(ReactForegroundColorSpan span) { |
703 | 706 | return span.getForegroundColor() == getCurrentTextColor(); |
704 | 707 | } |
705 | 708 | }); |
| 709 | + |
| 710 | + stripSpansOfKind( |
| 711 | + sb, |
| 712 | + ReactStrikethroughSpan.class, |
| 713 | + new SpanPredicate<ReactStrikethroughSpan>() { |
| 714 | + @Override |
| 715 | + public boolean test(ReactStrikethroughSpan span) { |
| 716 | + return (getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0; |
| 717 | + } |
| 718 | + }); |
| 719 | + |
| 720 | + stripSpansOfKind( |
| 721 | + sb, |
| 722 | + ReactUnderlineSpan.class, |
| 723 | + new SpanPredicate<ReactUnderlineSpan>() { |
| 724 | + @Override |
| 725 | + public boolean test(ReactUnderlineSpan span) { |
| 726 | + return (getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0; |
| 727 | + } |
| 728 | + }); |
706 | 729 | } |
707 | 730 |
|
708 | 731 | private <T> void stripSpansOfKind( |
@@ -736,6 +759,14 @@ private void restoreStyleEquivalentSpans(SpannableStringBuilder workingText) { |
736 | 759 | spans.add(new ReactBackgroundColorSpan(backgroundColor)); |
737 | 760 | } |
738 | 761 |
|
| 762 | + if ((getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0) { |
| 763 | + spans.add(new ReactStrikethroughSpan()); |
| 764 | + } |
| 765 | + |
| 766 | + if ((getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0) { |
| 767 | + spans.add(new ReactUnderlineSpan()); |
| 768 | + } |
| 769 | + |
739 | 770 | for (Object span : spans) { |
740 | 771 | workingText.setSpan(span, 0, workingText.length(), spanFlags); |
741 | 772 | } |
|
0 commit comments