From c9fd978da60f76c0576150c55629a034e1fa19fb Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Fri, 9 Sep 2011 09:20:12 -0700 Subject: Bug 5281947: add to dictionnary option promoted in suggestions. When several SuggestionSpans are available at a given position, their content are merged, in creation time order. As a result, the IME's suggestions are picked before the spell check, and no add to dictionnary option is created. This CL modifies the comparator to make easy correction spans appear first (Voice IME), then misspelled words and then regular suggestions. Also avoids the creation of a new comparator and length hash map on every display. Change-Id: I1f9f031a6fdcbbc09f248a192b83051092765f8e --- core/java/android/text/TextPaint.java | 51 +++++------------------------------ 1 file changed, 6 insertions(+), 45 deletions(-) (limited to 'core/java/android/text/TextPaint.java') diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java index afd989256b88..044711711931 100644 --- a/core/java/android/text/TextPaint.java +++ b/core/java/android/text/TextPaint.java @@ -24,8 +24,6 @@ import android.graphics.Paint; */ public class TextPaint extends Paint { - private static final int DEFAULT_UNDERLINE_SIZE = 3; - // Special value 0 means no background paint public int bgColor; public int baselineShift; @@ -36,17 +34,12 @@ public class TextPaint extends Paint { * Special value 0 means no custom underline * @hide */ - public int[] underlineColors; + public int underlineColor = 0; /** * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness. * @hide */ - public float[] underlineThicknesses; - /** - * The number of underlines currently stored in the array. If 0, no underline is drawn. - * @hide - */ - public int underlineCount; + public float underlineThickness; public TextPaint() { super(); @@ -72,16 +65,8 @@ public class TextPaint extends Paint { linkColor = tp.linkColor; drawableState = tp.drawableState; density = tp.density; - - if (tp.underlineColors != null) { - if (underlineColors == null || underlineColors.length < tp.underlineCount) { - underlineColors = new int[tp.underlineCount]; - underlineThicknesses = new float[tp.underlineCount]; - } - System.arraycopy(tp.underlineColors, 0, underlineColors, 0, tp.underlineCount); - System.arraycopy(tp.underlineThicknesses, 0, underlineThicknesses, 0, tp.underlineCount); - } - underlineCount = tp.underlineCount; + underlineColor = tp.underlineColor; + underlineThickness = tp.underlineThickness; } /** @@ -91,31 +76,7 @@ public class TextPaint extends Paint { * @hide */ public void setUnderlineText(int color, float thickness) { - if (color == 0) { - // No underline - return; - } - - if (underlineCount == 0) { - underlineColors = new int[DEFAULT_UNDERLINE_SIZE]; - underlineThicknesses = new float[DEFAULT_UNDERLINE_SIZE]; - underlineColors[underlineCount] = color; - underlineThicknesses[underlineCount] = thickness; - underlineCount++; - } else { - if (underlineCount == underlineColors.length) { - int[] newColors = new int[underlineColors.length + DEFAULT_UNDERLINE_SIZE]; - float[] newThickness = new float[underlineThicknesses.length - + DEFAULT_UNDERLINE_SIZE]; - System.arraycopy(underlineColors, 0, newColors, 0, underlineColors.length); - System.arraycopy( - underlineThicknesses, 0, newThickness, 0, underlineThicknesses.length); - underlineColors = newColors; - underlineThicknesses = newThickness; - } - underlineColors[underlineCount] = color; - underlineThicknesses[underlineCount] = thickness; - underlineCount++; - } + underlineColor = color; + underlineThickness = thickness; } } -- cgit v1.2.3