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

Commit c6866a98 authored by Romain Guy's avatar Romain Guy Committed by android-build-merger
Browse files

Merge "Fix API feedback on Color" into oc-dev am: 03758701

am: 7700c2b2

Change-Id: I64f6dcabfd1722475947be3b3e3cc636b724dbed
parents f9eb4e87 7700c2b2
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ public class Color {
    /**
     * Returns the value of the alpha component in the range \([0..1]\).
     * Calling this method is equivalent to
     * <code>getComponent(getComponentCount())</code>.
     * <code>getComponent(getComponentCount() - 1)</code>.
     *
     * @see #red()
     * @see #green()
@@ -690,9 +690,8 @@ public class Color {
     * Returns the color space encoded in the specified color long.
     *
     * @param color The color long whose color space to extract
     * @return A non-null color space instance. If the color long encodes
     * an unknown or invalid color space, the {@link ColorSpace.Named#SRGB sRGB}
     * color space is returned
     * @return A non-null color space instance
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     *
     * @see #red(long)
     * @see #green(long)
@@ -787,6 +786,7 @@ public class Color {
     *
     * @param color The color to test
     * @return True if the color is in the sRGB color space, false otherwise
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     *
     * @see #isInColorSpace(long, ColorSpace)
     * @see #isWideGamut(long)
@@ -802,6 +802,7 @@ public class Color {
     *
     * @param color The color to test
     * @return True if the color is in a wide-gamut color space, false otherwise
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     *
     * @see #isInColorSpace(long, ColorSpace)
     * @see #isSrgb(long)
@@ -831,6 +832,7 @@ public class Color {
     * a color space conversion is applied if needed.
     *
     * @return An ARGB color in the sRGB color space
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     */
    @ColorInt
    public static int toArgb(@ColorLong long color) {
@@ -873,6 +875,7 @@ public class Color {
     *
     * @param color The color long to create a <code>Color</code> from
     * @return A non-null instance of {@link Color}
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     */
    @NonNull
    public static Color valueOf(@ColorLong long color) {
@@ -1100,6 +1103,7 @@ public class Color {
     * @param color The color long to convert
     * @param colorSpace The destination color space
     * @return A color long in the destination color space
     * @throws IllegalArgumentException If the encoded color space is invalid or unknown
     */
    @ColorLong
    public static long convert(@ColorLong long color, @NonNull ColorSpace colorSpace) {
@@ -1206,7 +1210,7 @@ public class Color {
     * @return A value between 0 (darkest black) and 1 (lightest white)
     *
     * @throws IllegalArgumentException If the specified color's color space
     * does not use the {@link ColorSpace.Model#RGB RGB} color model
     * is unknown or does not use the {@link ColorSpace.Model#RGB RGB} color model
     */
    public static float luminance(@ColorLong long color) {
        ColorSpace colorSpace = colorSpace(color);
+6 −4
Original line number Diff line number Diff line
@@ -1338,9 +1338,8 @@ public abstract class ColorSpace {
    }

    /**
     * <p>Returns an instance of {@link ColorSpace} whose ID matches the specified
     * ID. If the ID is < 0 or &gt; {@link #MAX_ID}, calling this method is equivalent
     * to calling <code>get(Named.SRGB)</code>.</p>
     * <p>Returns an instance of {@link ColorSpace} whose ID matches the
     * specified ID.</p>
     *
     * <p>This method always returns the same instance for a given ID.</p>
     *
@@ -1348,11 +1347,14 @@ public abstract class ColorSpace {
     *
     * @param index An integer ID between {@link #MIN_ID} and {@link #MAX_ID}
     * @return A non-null {@link ColorSpace} instance
     * @throws IllegalArgumentException If the ID does not match the ID of one of the
     *         {@link Named named color spaces}
     */
    @NonNull
    static ColorSpace get(@IntRange(from = MIN_ID, to = MAX_ID) int index) {
        if (index < 0 || index > Named.values().length) {
            return get(Named.SRGB);
            throw new IllegalArgumentException("Invalid ID, must be in the range [0.." +
                    Named.values().length + "]");
        }
        return sNamedColorSpaces[index];
    }