kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix truncation calculation by accounting for compound drawables.
rodzic
204fff1b9b
commit
d01a52c5a8
|
@ -21,10 +21,14 @@ open class SimpleEmojiTextView @JvmOverloads constructor(
|
||||||
if (SignalStore.settings().isPreferSystemEmoji || candidates == null || candidates.size() == 0) {
|
if (SignalStore.settings().isPreferSystemEmoji || candidates == null || candidates.size() == 0) {
|
||||||
super.setText(Optional.fromNullable(text).or(""), type)
|
super.setText(Optional.fromNullable(text).or(""), type)
|
||||||
} else {
|
} else {
|
||||||
|
val startDrawableSize: Int = compoundDrawables[0]?.let { it.intrinsicWidth + compoundDrawablePadding } ?: 0
|
||||||
|
val endDrawableSize: Int = compoundDrawables[1]?.let { it.intrinsicWidth + compoundDrawablePadding } ?: 0
|
||||||
|
val adjustedWidth: Int = width - startDrawableSize - endDrawableSize
|
||||||
|
|
||||||
val newContent = if (width == 0 || maxLines == -1) {
|
val newContent = if (width == 0 || maxLines == -1) {
|
||||||
text
|
text
|
||||||
} else {
|
} else {
|
||||||
TextUtils.ellipsize(text, paint, (width * maxLines).toFloat(), TextUtils.TruncateAt.END, false, null)
|
TextUtils.ellipsize(text, paint, (adjustedWidth * maxLines).toFloat(), TextUtils.TruncateAt.END, false, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val newCandidates = if (isInEditMode) null else EmojiProvider.getCandidates(newContent)
|
val newCandidates = if (isInEditMode) null else EmojiProvider.getCandidates(newContent)
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
android:layout_toEndOf="@id/contact_photo_container"
|
android:layout_toEndOf="@id/contact_photo_container"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
<org.thoughtcrime.securesms.components.FromTextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
style="@style/TextSecure.TitleTextStyle"
|
style="@style/TextSecure.TitleTextStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Ładowanie…
Reference in New Issue