mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
#1251 - Fix messages containing RTL languages being clipped
This commit is contained in:
@@ -21,20 +21,28 @@ package com.moez.QKSMS.common.widget
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
|
||||
class TightTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : QkTextView(context, attrs) {
|
||||
class TightTextView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : QkTextView(context, attrs) {
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
layout?.let {
|
||||
val maxLineWidth = (0 until layout.lineCount)
|
||||
.asSequence()
|
||||
.map { layout.getLineMax(it) }
|
||||
.max() ?: 0f
|
||||
// Get a non-null copy of the layout, if available. Then ensure we've got multiple lines
|
||||
val layout = layout ?: return
|
||||
if (layout.lineCount <= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
val width = (Math.ceil(maxLineWidth.toDouble()).toInt() + compoundPaddingLeft + compoundPaddingRight)
|
||||
val height = measuredHeight
|
||||
setMeasuredDimension(width, height)
|
||||
val maxLineWidth = (0 until layout.lineCount)
|
||||
.map(layout::getLineWidth)
|
||||
.max() ?: 0f
|
||||
|
||||
val width = Math.ceil(maxLineWidth.toDouble()).toInt() + compoundPaddingLeft + compoundPaddingRight
|
||||
if (width < measuredWidth) {
|
||||
val widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.getMode(widthMeasureSpec))
|
||||
super.onMeasure(widthSpec, heightMeasureSpec)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user