Fix ellipsis bug in group names with emoji.

The bug was that system emoji and emoji from `EmojiSpan` had different
sizes. The `View` was being measured based off the `EmojiSpan`
(smaller), but ellipsizing was based off the size of system emoji.

Fixes #11772
This commit is contained in:
Rashad Sookram 2021-12-16 13:02:28 -05:00 committed by Greyson Parrelli
parent dbce4be31d
commit dd79688f48

View file

@ -27,20 +27,20 @@ open class SimpleEmojiTextView @JvmOverloads constructor(
val endDrawableSize: Int = compoundDrawables[1]?.let { it.intrinsicWidth + compoundDrawablePadding } ?: 0
val adjustedWidth: Int = width - startDrawableSize - endDrawableSize
val newContent = if (width == 0 || maxLines == -1) {
val newCandidates = if (isInEditMode) null else EmojiProvider.getCandidates(text)
val newText = if (newCandidates == null || newCandidates.size() == 0) {
text
} else {
TextUtils.ellipsize(text, paint, (adjustedWidth * maxLines).toFloat(), TextUtils.TruncateAt.END, false, null)
EmojiProvider.emojify(newCandidates, text, this)
}
val newCandidates = if (isInEditMode) null else EmojiProvider.getCandidates(newContent)
val newText = if (newCandidates == null || newCandidates.size() == 0) {
newContent
val newContent = if (width == 0 || maxLines == -1) {
newText
} else {
EmojiProvider.emojify(newCandidates, newContent, this)
TextUtils.ellipsize(newText, paint, (adjustedWidth * maxLines).toFloat(), TextUtils.TruncateAt.END, false, null)
}
bufferType = BufferType.SPANNABLE
super.setText(newText, type)
super.setText(newContent, type)
}
}