diff --git a/vector/src/main/java/im/vector/app/features/html/MxReplyTagHandler.kt b/vector/src/main/java/im/vector/app/features/html/MxReplyTagHandler.kt index 391c5f9477..118369e3c8 100644 --- a/vector/src/main/java/im/vector/app/features/html/MxReplyTagHandler.kt +++ b/vector/src/main/java/im/vector/app/features/html/MxReplyTagHandler.kt @@ -17,28 +17,17 @@ package im.vector.app.features.html import io.noties.markwon.MarkwonVisitor -import io.noties.markwon.SpannableBuilder import io.noties.markwon.html.HtmlTag import io.noties.markwon.html.MarkwonHtmlRenderer import io.noties.markwon.html.TagHandler -import org.commonmark.node.BlockQuote class MxReplyTagHandler : TagHandler() { override fun supportedTags() = listOf("mx-reply") override fun handle(visitor: MarkwonVisitor, renderer: MarkwonHtmlRenderer, tag: HtmlTag) { - val configuration = visitor.configuration() - val factory = configuration.spansFactory().get(BlockQuote::class.java) - if (factory != null) { - SpannableBuilder.setSpans( - visitor.builder(), - factory.getSpans(configuration, visitor.renderProps()), - tag.start(), - tag.end() - ) - val replyText = visitor.builder().removeFromEnd(tag.end()) - visitor.builder().append("\n\n").append(replyText) - } + visitChildren(visitor, renderer, tag.asBlock) + val replyText = visitor.builder().removeFromEnd(tag.end()) + visitor.builder().append("\n\n").append(replyText) } } diff --git a/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt b/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt index c1040a8cc0..ff2e2a9cdb 100644 --- a/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt +++ b/vector/src/main/java/im/vector/app/features/html/PillImageSpan.kt @@ -65,10 +65,15 @@ class PillImageSpan(private val glideRequests: GlideRequests, fm: Paint.FontMetricsInt?): Int { val rect = pillDrawable.bounds if (fm != null) { - fm.ascent = -rect.bottom - fm.descent = 0 - fm.top = fm.ascent - fm.bottom = 0 + val fmPaint = paint.fontMetricsInt + val fontHeight = fmPaint.bottom - fmPaint.top + val drHeight = rect.bottom - rect.top + val top = drHeight / 2 - fontHeight / 4 + val bottom = drHeight / 2 + fontHeight / 4 + fm.ascent = -bottom + fm.top = -bottom + fm.bottom = top + fm.descent = top } return rect.right } @@ -82,7 +87,9 @@ class PillImageSpan(private val glideRequests: GlideRequests, bottom: Int, paint: Paint) { canvas.save() - val transY = bottom - pillDrawable.bounds.bottom + val fm = paint.fontMetricsInt + val transY: Int = y + (fm.descent + fm.ascent - pillDrawable.bounds.bottom) / 2 + canvas.save() canvas.translate(x, transY.toFloat()) pillDrawable.draw(canvas) canvas.restore()