diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java index 102a2962..ff8a47df 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java @@ -133,11 +133,17 @@ public class HtmlParser{ public static void parseCustomEmoji(SpannableStringBuilder ssb, List emojis){ Map emojiByCode=emojis.stream().collect(Collectors.toMap(e->e.shortcode, Function.identity())); Matcher matcher=EMOJI_CODE_PATTERN.matcher(ssb); + int spanCount=0; + CustomEmojiSpan lastSpan=null; while(matcher.find()){ Emoji emoji=emojiByCode.get(matcher.group(1)); if(emoji==null) continue; - ssb.setSpan(new CustomEmojiSpan(emoji), matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + ssb.setSpan(lastSpan=new CustomEmojiSpan(emoji), matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spanCount++; + } + if(spanCount==1 && ssb.getSpanStart(lastSpan)==0 && ssb.getSpanEnd(lastSpan)==ssb.length()){ + ssb.append(' '); // To fix line height } }