Skip to content

Commit

Permalink
Merge pull request #4573 from hieupham007/timob-14720-3_1_X
Browse files Browse the repository at this point in the history
Timob 14720 3 1 x
  • Loading branch information
pingwang2011 committed Aug 14, 2013
2 parents 5a7d49c + 81a0850 commit 5ceaff8
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
*/
package org.appcelerator.titanium.util;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.appcelerator.kroll.common.Log;

import android.graphics.Color;
import android.os.Build;

/**
* This class contain utility methods that converts a String color, like "red", into its corresponding RGB/RGBA representation.
Expand All @@ -25,6 +28,8 @@ public class TiColorHelper

private static final String TAG = "TiColorHelper";
private static HashMap<String, Integer> colorTable;
private static List<String> alphaMissingColors = Arrays.asList(new String[] {"aqua", "fuchsia", "lime", "maroon", "navy", "olive", "purple", "silver", "teal"});


/**
* Convert string representations of colors, like "red" into the corresponding RGB/RGBA representation.
Expand Down Expand Up @@ -66,7 +71,11 @@ public static int parseColor(String value) {
// add the alpha bits to them! This is a temporary workaround
// until they fix it. I've created a Google ticket for this:
// https://code.google.com/p/android/issues/detail?id=58352&thanks=58352
color = Color.parseColor(lowval) | 0xFF000000;
if (Build.VERSION.SDK_INT > 17 && alphaMissingColors.contains(lowval)) {
color = Color.parseColor(lowval) | 0xFF000000;
} else {
color = Color.parseColor(lowval);
}
} catch (IllegalArgumentException e) {
if (colorTable == null) {
buildColorTable();
Expand Down

0 comments on commit 5ceaff8

Please sign in to comment.