Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 14720 3 1 x #4573

Merged
merged 2 commits into from
Aug 14, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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