mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-16 03:08:58 +03:00
Fix rendering pills when markdown nests some spans inside
Fixes https://github.com/SchildiChat/SchildiChat-android/issues/156 Also improves the fix for https://github.com/SchildiChat/SchildiChat-android/issues/148, since pills are rendered again and the content is discarded, as per https://spec.matrix.org/v1.3/client-server-api/#user-and-room-mentions : "Clients should display mentions differently from other elements" Change-Id: I9d05fba4110737aacdd9939480b6f78d23bd4298
This commit is contained in:
parent
b531fb523c
commit
23a96329d6
1 changed files with 6 additions and 3 deletions
|
@ -85,9 +85,12 @@ class PillsPostProcessor @AssistedInject constructor(
|
|||
val startSpan = renderedText.getSpanStart(linkSpan)
|
||||
val endSpan = renderedText.getSpanEnd(linkSpan)
|
||||
// GlideImagesPlugin causes duplicated pills if we have a nested image: https://github.com/SchildiChat/SchildiChat-android/issues/148
|
||||
// -> do not add pills if we have a nested image
|
||||
if (renderedText.getSpans(startSpan, endSpan, AsyncDrawableSpan::class.java).isNotEmpty()) {
|
||||
return@forEach
|
||||
// Same can happen for other spans: https://github.com/SchildiChat/SchildiChat-android/issues/156
|
||||
// -> Remove all spans from pill content before rendering
|
||||
renderedText.getSpans(startSpan, endSpan, Any::class.java).forEach {
|
||||
if (it !is LinkSpan) {
|
||||
renderedText.removeSpan(it)
|
||||
}
|
||||
}
|
||||
addPillSpan(renderedText, pillSpan, startSpan, endSpan)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue