Hide trailing newlines in text messages

Change-Id: I4e11feeb28abd5f186691d6f61bdf65252b2db0d
This commit is contained in:
SpiritCroc 2020-09-05 17:59:38 +02:00
parent 3a47c1b438
commit b212344ad9

View File

@ -52,8 +52,15 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
if (searchForPills) {
message?.findPillsAndProcess(coroutineScope) { it.bind(holder.messageView) }
}
var m = message
if (m != null) {
// Remove last trailing newline: looks especially bad in message bubble
if (m.last() == '\n') {
m = m.subSequence(0, m.length-1)
}
}
val textFuture = PrecomputedTextCompat.getTextFuture(
message ?: "",
m ?: "",
TextViewCompat.getTextMetricsParams(holder.messageView),
null)
holder.messageView.setTextFuture(textFuture)