From cb332649e44db86ff8b4e7f006db4bbfd82fed55 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Fri, 23 Sep 2011 19:08:04 -0700 Subject: Fix bug #5366547 TruncateAt.MARQUEE should be replaces with "two dot" ellipsis on hardware that dont support MARQUEE - introduce TruncateAt.END_SMALL - code refactoring for suppressing use of hardcoded constants Change-Id: I70e24857cd5d6bd012a743cbc0ba46fbd06d5457 --- core/java/android/text/StaticLayout.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core/java/android/text/StaticLayout.java') diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index e8b2045ef828..583cbe615fa4 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -763,7 +763,8 @@ public class StaticLayout extends Layout { return; } - float ellipsisWidth = paint.measureText(HORIZONTAL_ELLIPSIS); + float ellipsisWidth = paint.measureText( + (where == TextUtils.TruncateAt.END_SMALL) ? ELLIPSIS_TWO_DOTS : ELLIPSIS_NORMAL); int ellipsisStart = 0; int ellipsisCount = 0; int len = lineEnd - lineStart; @@ -791,7 +792,8 @@ public class StaticLayout extends Layout { Log.w(TAG, "Start Ellipsis only supported with one line"); } } - } else if (where == TextUtils.TruncateAt.END || where == TextUtils.TruncateAt.MARQUEE) { + } else if (where == TextUtils.TruncateAt.END || where == TextUtils.TruncateAt.MARQUEE || + where == TextUtils.TruncateAt.END_SMALL) { float sum = 0; int i; @@ -1001,7 +1003,9 @@ public class StaticLayout extends Layout { private static final char CHAR_HYPHEN = '-'; private static final double EXTRA_ROUNDING = 0.5; - private static final String HORIZONTAL_ELLIPSIS = "\u2026"; // this is "..." + + private static final String ELLIPSIS_NORMAL = "\u2026"; // this is "..." + private static final String ELLIPSIS_TWO_DOTS = "\u2025"; // this is ".." private static final int CHAR_FIRST_HIGH_SURROGATE = 0xD800; private static final int CHAR_LAST_LOW_SURROGATE = 0xDFFF; -- cgit v1.2.3