Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dde48feb authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge "Remove @hide from android.graphics.Color"

parents f1c4cfa8 1a05b72c
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.text.style.TypefaceSpan;
import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;

import com.android.internal.util.XmlUtils;

import org.ccil.cowan.tagsoup.HTMLSchema;
import org.ccil.cowan.tagsoup.Parser;
import org.xml.sax.Attributes;
@@ -1188,7 +1190,25 @@ class HtmlToSpannedConverter implements ContentHandler {
                return i;
            }
        }
        return Color.getHtmlColor(color);

        // If |color| is the name of a color, pass it to Color to convert it. Otherwise,
        // it may start with "#", "0", "0x", "+", or a digit. All of these cases are
        // handled below by XmlUtils. (Note that parseColor accepts colors starting
        // with "#", but it treats them differently from XmlUtils.)
        if (Character.isLetter(color.charAt(0))) {
            try {
                return Color.parseColor(color);
            } catch (IllegalArgumentException e) {
                return -1;
            }
        }

        try {
            return XmlUtils.convertValueToInt(color, -1);
        } catch (NumberFormatException nfe) {
            return -1;
        }

    }

    public void setDocumentLocator(Locator locator) {
+0 −24
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.annotation.Nullable;
import android.annotation.Size;
import android.annotation.SuppressAutoDoc;
import android.util.Half;
import com.android.internal.util.XmlUtils;

import java.util.Arrays;
import java.util.HashMap;
@@ -1476,29 +1475,6 @@ public class Color {
    private static native void nativeRGBToHSV(int red, int greed, int blue, float hsv[]);
    private static native int nativeHSVToColor(int alpha, float hsv[]);

    /**
     * Converts an HTML color (named or numeric) to an integer RGB value.
     *
     * @param color Non-null color string.
     *
     * @return A color value, or {@code -1} if the color string could not be interpreted.
     *
     * @hide
     */
    @ColorInt
    public static int getHtmlColor(@NonNull String color) {
        Integer i = sColorNameMap.get(color.toLowerCase(Locale.ROOT));
        if (i != null) {
            return i;
        } else {
            try {
                return XmlUtils.convertValueToInt(color, -1);
            } catch (NumberFormatException nfe) {
                return -1;
            }
        }
    }

    private static final HashMap<String, Integer> sColorNameMap;
    static {
        sColorNameMap = new HashMap<>();