Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit ad40f61

Browse files
Sam1301kunall17
authored andcommitted
Add support for strikethoughs in messages.
1 parent 968cb99 commit ad40f61

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/src/main/java/com/zulip/android/util/CustomHtmlToSpannedConverter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import android.text.style.ParagraphStyle;
3737
import android.text.style.QuoteSpan;
3838
import android.text.style.RelativeSizeSpan;
39+
import android.text.style.StrikethroughSpan;
3940
import android.text.style.StyleSpan;
4041
import android.text.style.SubscriptSpan;
4142
import android.text.style.SuperscriptSpan;
@@ -525,6 +526,12 @@ private void handleStartTag(String tag, Attributes attributes) {
525526
start(mSpannableStringBuilder, new InlineCode());
526527
} else if (tag.equalsIgnoreCase("pre")) {
527528
start(mSpannableStringBuilder, new CodeBlock());
529+
} else if (tag.equalsIgnoreCase("del")) {
530+
start(mSpannableStringBuilder, new StrikeThrough());
531+
} else if (tag.equalsIgnoreCase("s")) {
532+
start(mSpannableStringBuilder, new StrikeThrough());
533+
} else if (tag.equalsIgnoreCase("strike")) {
534+
start(mSpannableStringBuilder, new StrikeThrough());
528535
} else if (tag.length() == 2
529536
&& Character.toLowerCase(tag.charAt(0)) == 'h'
530537
&& tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
@@ -599,6 +606,12 @@ private void handleEndTag(String tag) {
599606
} else if (tag.equalsIgnoreCase("pre")) {
600607
end(mSpannableStringBuilder, CodeBlock.class, new TypefaceSpan(
601608
MONOSPACE));
609+
} else if (tag.equalsIgnoreCase("del")) {
610+
end(mSpannableStringBuilder, StrikeThrough.class, new StrikethroughSpan());
611+
} else if (tag.equalsIgnoreCase("s")) {
612+
end(mSpannableStringBuilder, StrikeThrough.class, new StrikethroughSpan());
613+
} else if (tag.equalsIgnoreCase("strike")) {
614+
end(mSpannableStringBuilder, StrikeThrough.class, new StrikethroughSpan());
602615
} else if (tag.length() == 2
603616
&& Character.toLowerCase(tag.charAt(0)) == 'h'
604617
&& tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
@@ -718,6 +731,9 @@ private static class InlineCode {
718731
private static class CodeBlock {
719732
}
720733

734+
private static class StrikeThrough {
735+
}
736+
721737
private static class Font {
722738
public String mColor;
723739
public String mFace;

0 commit comments

Comments
 (0)