forked from upstream-mirrors/quik
Fix crash when displaying subject
This commit is contained in:
@@ -175,16 +175,19 @@ class MessagesAdapter @Inject constructor(
|
|||||||
view.body.text = when (message.isSms()) {
|
view.body.text = when (message.isSms()) {
|
||||||
true -> message.body
|
true -> message.body
|
||||||
false -> {
|
false -> {
|
||||||
val subject = message.getCleansedSubject()
|
val subject = SpannableStringBuilder(message.getCleansedSubject())
|
||||||
val sb = SpannableStringBuilder(message.parts
|
subject.setSpan(StyleSpan(Typeface.BOLD), 0, subject.length, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
|
||||||
.mapNotNull { it.text }
|
|
||||||
.apply { subject + this }
|
|
||||||
.filter { it.isNotBlank() }
|
|
||||||
.joinToString("\n") { text -> text })
|
|
||||||
|
|
||||||
val bss = StyleSpan(Typeface.BOLD)
|
val body = message.parts
|
||||||
sb.setSpan(bss, 0, subject.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
|
.mapNotNull { it.text }
|
||||||
sb.toString()
|
.filter { it.isNotBlank() }
|
||||||
|
.joinToString("\n") { text -> text }
|
||||||
|
|
||||||
|
when {
|
||||||
|
subject.isNotBlank() && body.isNotBlank() -> subject.append("\n$body")
|
||||||
|
subject.isNotBlank() -> subject
|
||||||
|
else -> body
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.body.setVisible(message.isSms() || view.body.text.isNotBlank())
|
view.body.setVisible(message.isSms() || view.body.text.isNotBlank())
|
||||||
|
|||||||
Reference in New Issue
Block a user