kopia lustrzana https://github.com/ryukoposting/Signal-Android
Autoscale story text so all content fits in viewer.
rodzic
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)
|
||||
|
|
|
@ -168,10 +168,6 @@ public final class MultiShareArgs implements Parcelable {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Util.isEmpty(getDraftText()) && getDraftText().split("\n").length > Stories.MAX_TEXT_STORY_LINE_COUNT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Util.isEmpty(getDraftText())) {
|
||||
BreakIteratorCompat breakIteratorCompat = BreakIteratorCompat.getInstance();
|
||||
breakIteratorCompat.setText(getDraftText());
|
||||
|
|
|
@ -4,11 +4,9 @@ import android.content.Context
|
|||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.Px
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.doOnNextLayout
|
||||
|
@ -85,10 +83,6 @@ class StoryTextPostView @JvmOverloads constructor(
|
|||
textView.text = text
|
||||
}
|
||||
|
||||
private fun setTextSize(@Px textSize: Float) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
}
|
||||
|
||||
private fun setTextGravity(textAlignment: TextAlignment) {
|
||||
textView.gravity = textAlignment.gravity
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue