Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89435ebe authored by Valentin Iftime's avatar Valentin Iftime
Browse files

Ellipsize text only if needed

 Only add ellipsis in TextUtils.makeSafeForPresentation when getSystemFontMap is empty
  if the text needs trimming. Fixes NotificationAccessConfirmationActivityTest#start_showsDialog.

Test: atest com.android.settings.notification.NotificationAccessConfirmationActivityTest#start_showsDialog
Test: atest MakeSafeForPresentationTest
Bug: 300157932
Change-Id: I8e9d2305bbb34755b57d37771fba4984e29ff520
parent 03021851
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2495,8 +2495,14 @@ public class TextUtils {

                // Even if the argument name is `ellipsizeDip`, the unit of this argument is pixels.
                final int charCount = (int) ((ellipsizeDip + 0.5f) / assumedCharWidthInPx);
                return TextUtils.trimToSize(gettingCleaned.toString(), charCount)

                final String text = gettingCleaned.toString();
                if (TextUtils.isEmpty(text) || text.length() <= charCount) {
                    return text;
                } else {
                    return TextUtils.trimToSize(text, charCount)
                            + getEllipsisString(TruncateAt.END);
                }
            } else {
                // Truncate
                final TextPaint paint = new TextPaint();