Fix ellipsis appearing in the middle of a message.

fork-5.53.8
Rashad Sookram 2022-03-15 12:48:10 -04:00 zatwierdzone przez Cody Henthorne
rodzic 6d41d1f6d2
commit 3ad7c96a3c
5 zmienionych plików z 12 dodań i 5 usunięć

Wyświetl plik

@ -149,7 +149,7 @@ public class EmojiTextView extends AppCompatTextView {
// Android fails to ellipsize spannable strings. (https://issuetracker.google.com/issues/36991688)
// We ellipsize them ourselves by manually truncating the appropriate section.
if (getText() != null && getText().length() > 0 && getEllipsize() == TextUtils.TruncateAt.END) {
if (getText() != null && getText().length() > 0 && isEllipsizedAtEnd()) {
if (maxLength > 0) {
ellipsizeAnyTextForMaxLength();
} else if (getMaxLines() > 0) {
@ -162,6 +162,17 @@ public class EmojiTextView extends AppCompatTextView {
}
}
/**
* Used to determine whether to apply custom ellipsizing logic without necessarily having the
* ellipsize property set. This allows us to work around implementations of Layout which apply an
* ellipsis even when maxLines is not set.
*/
private boolean isEllipsizedAtEnd() {
return getEllipsize() == TextUtils.TruncateAt.END ||
(getMaxLines() > 0 && getMaxLines() < Integer.MAX_VALUE) ||
maxLength > 0;
}
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = applyWidthMeasureRoundingFix(widthMeasureSpec);

Wyświetl plik

@ -183,7 +183,6 @@
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:ellipsize="end"
android:textColor="@color/signal_text_primary"
android:textColorLink="@color/signal_text_primary"
app:emoji_maxLength="1000"

Wyświetl plik

@ -113,7 +113,6 @@
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:ellipsize="end"
android:textColor="@color/signal_text_primary"
android:textColorLink="@color/signal_text_primary"
app:emoji_maxLength="1000"

Wyświetl plik

@ -124,7 +124,6 @@
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:ellipsize="end"
android:textColor="@color/conversation_item_sent_text_primary_color"
android:textColorLink="@color/conversation_item_sent_text_primary_color"
app:emoji_maxLength="1000"

Wyświetl plik

@ -55,7 +55,6 @@
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:ellipsize="end"
android:textColor="@color/conversation_item_sent_text_primary_color"
android:textColorLink="@color/conversation_item_sent_text_primary_color"
app:emoji_maxLength="1000"