forked from upstream-mirrors/quik
#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.content.Context
|
||||||
import android.util.AttributeSet
|
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) {
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
|
|
||||||
layout?.let {
|
// Get a non-null copy of the layout, if available. Then ensure we've got multiple lines
|
||||||
val maxLineWidth = (0 until layout.lineCount)
|
val layout = layout ?: return
|
||||||
.asSequence()
|
if (layout.lineCount <= 1) {
|
||||||
.map { layout.getLineMax(it) }
|
return
|
||||||
.max() ?: 0f
|
}
|
||||||
|
|
||||||
val width = (Math.ceil(maxLineWidth.toDouble()).toInt() + compoundPaddingLeft + compoundPaddingRight)
|
val maxLineWidth = (0 until layout.lineCount)
|
||||||
val height = measuredHeight
|
.map(layout::getLineWidth)
|
||||||
setMeasuredDimension(width, height)
|
.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