From a987d9af69ca5447a888a3d5b50f3511d4b8f0da Mon Sep 17 00:00:00 2001 From: Stefan Wysocki Date: Thu, 10 Oct 2013 12:07:11 +0200 Subject: Use parseColor instead of getHTMLColor getHTMLColor is not aware of ARGB color format which is commonly used in android xml files. This causes problem with coloring spans in resources. Instead of above it should be changed to parseColor() with supported formats: #RRGGBB #AARRGGBB Bug: https://code.google.com/p/android/issues/detail?id=58192 Change-Id: I16bdf4c5c2a3b5e216b44e5c1955cac0104b3e12 --- core/java/android/content/res/StringBlock.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java index 77b8a33..9652db7 100644 --- a/core/java/android/content/res/StringBlock.java +++ b/core/java/android/content/res/StringBlock.java @@ -311,13 +311,13 @@ final class StringBlock { * the color black is returned instead. * * @param color The color as a string. Can be a resource reference, - * HTML hexadecimal, octal or a name + * hexadecimal, octal or a name * @param foreground True if the color will be used as the foreground color, * false otherwise * * @return A CharacterStyle * - * @see Color#getHtmlColor(String) + * @see Color#parseColor(String) */ private static CharacterStyle getColor(String color, boolean foreground) { int c = 0xff000000; @@ -336,7 +336,11 @@ final class StringBlock { } } } else { - c = Color.getHtmlColor(color); + try { + c = Color.parseColor(color); + } catch (IllegalArgumentException e) { + c = Color.BLACK; + } } } -- cgit v1.1