MessageAdapter: do not apply empty size spans

This commit is contained in:
Daniel Gultsch 2017-11-21 12:41:05 +01:00
parent 9548a4f6af
commit 52e09d17e8
1 changed files with 5 additions and 5 deletions

View File

@ -466,10 +466,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} else { } else {
body.insert(privateMarkerIndex, " "); body.insert(privateMarkerIndex, " ");
} }
body.setSpan(new ForegroundColorSpan(getMessageTextColor(darkBackground, false)), body.setSpan(new ForegroundColorSpan(getMessageTextColor(darkBackground, false)), 0, privateMarkerIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
0, privateMarkerIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); body.setSpan(new StyleSpan(Typeface.BOLD), 0, privateMarkerIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
body.setSpan(new StyleSpan(Typeface.BOLD),
0, privateMarkerIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
if (hasMeCommand) { if (hasMeCommand) {
body.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), privateMarkerIndex + 1, body.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), privateMarkerIndex + 1,
privateMarkerIndex + 1 + nick.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); privateMarkerIndex + 1 + nick.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -484,8 +482,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} }
Matcher matcher = Emoticons.generatePattern(body).matcher(body); Matcher matcher = Emoticons.generatePattern(body).matcher(body);
while(matcher.find()) { while(matcher.find()) {
if (matcher.start() < matcher.end()) {
body.setSpan(new RelativeSizeSpan(1.2f), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); body.setSpan(new RelativeSizeSpan(1.2f), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
}
StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor()); StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor());