mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Autoscale story text so all content fits in viewer.
This commit is contained in:
committed by
Greyson Parrelli
parent
b6db7e7af6
commit
a0172ddb2f
@@ -9,6 +9,7 @@ import android.widget.TextView
|
||||
import org.signal.core.util.BreakIteratorCompat
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.signal.core.util.EditTextUtil
|
||||
import org.thoughtcrime.securesms.util.doOnEachLayout
|
||||
|
||||
class TextStoryTextWatcher private constructor(private val textView: TextView) : TextWatcher {
|
||||
|
||||
@@ -45,6 +46,14 @@ class TextStoryTextWatcher private constructor(private val textView: TextView) :
|
||||
|
||||
if (textView is EditText) {
|
||||
EditTextUtil.addGraphemeClusterLimitFilter(textView, 700)
|
||||
} else {
|
||||
textView.doOnEachLayout {
|
||||
val contentHeight = textView.height - textView.paddingTop - textView.paddingBottom
|
||||
if (textView.layout != null && textView.layout.height > contentHeight) {
|
||||
val percentShown = contentHeight / textView.layout.height.toFloat()
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, DimensionUnit.DP.toPixels(18f * percentShown))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textView.addTextChangedListener(watcher)
|
||||
|
||||
Reference in New Issue
Block a user