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

Commit 80756e38 authored by Tor Norbye's avatar Tor Norbye
Browse files

Annotate ARGB integer parameters with @ColorInt

Change-Id: I307f72a382272cf18ddb6b07d9fcb81228568d9a
parent cb59f2af
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;

/**
 * Denotes that the annotated element represents a packed color
 * int, {@code AARRGGBB}.
 * int, {@code AARRGGBB}. If applied to an int array, every element
 * in the array represents a color integer.
 * <p>
 *  public abstract void setTextColor(&#64;ColorInt int color);
 * }</pre>
+8 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.SdkConstant;
@@ -338,6 +339,7 @@ public class Notification implements Parcelable
     * @see #FLAG_SHOW_LIGHTS
     * @see #flags
     */
    @ColorInt
    public int ledARGB;

    /**
@@ -520,12 +522,14 @@ public class Notification implements Parcelable
     * {@link #icon} image (stenciled in white) atop a field of this color. Alpha components are
     * ignored.
     */
    @ColorInt
    public int color = COLOR_DEFAULT;

    /**
     * Special value of {@link #color} telling the system not to decorate this notification with
     * any special color but instead use default colors when presenting this notification.
     */
    @ColorInt
    public static final int COLOR_DEFAULT = 0; // AKA Color.TRANSPARENT

    /**
@@ -2388,7 +2392,7 @@ public class Notification implements Parcelable
         * @see Notification#ledOnMS
         * @see Notification#ledOffMS
         */
        public Builder setLights(int argb, int onMs, int offMs) {
        public Builder setLights(@ColorInt int argb, int onMs, int offMs) {
            mLedArgb = argb;
            mLedOnMs = onMs;
            mLedOffMs = offMs;
@@ -2712,7 +2716,7 @@ public class Notification implements Parcelable
         *
         * @return The same Builder.
         */
        public Builder setColor(int argb) {
        public Builder setColor(@ColorInt int argb) {
            mColor = argb;
            return this;
        }
@@ -5160,7 +5164,7 @@ public class Notification implements Parcelable
         * automotive setting. This method can be used to override the color provided in the
         * notification in such a situation.
         */
        public CarExtender setColor(int color) {
        public CarExtender setColor(@ColorInt int color) {
            mColor = color;
            return this;
        }
@@ -5170,6 +5174,7 @@ public class Notification implements Parcelable
         *
         * @see setColor
         */
        @ColorInt
        public int getColor() {
            return mColor;
        }
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content.res;

import android.annotation.ColorInt;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.Resources.Theme;
@@ -91,7 +92,7 @@ public class ColorStateList implements Parcelable {
     * Creates a ColorStateList that returns the specified mapping from
     * states to colors.
     */
    public ColorStateList(int[][] states, int[] colors) {
    public ColorStateList(int[][] states, @ColorInt int[] colors) {
        mStateSpecs = states;
        mColors = colors;

@@ -102,7 +103,7 @@ public class ColorStateList implements Parcelable {
     * @return A ColorStateList containing a single color.
     */
    @NonNull
    public static ColorStateList valueOf(int color) {
    public static ColorStateList valueOf(@ColorInt int color) {
        synchronized (sCache) {
            final int index = sCache.indexOfKey(color);
            if (index >= 0) {
@@ -436,6 +437,7 @@ public class ColorStateList implements Parcelable {
     *
     * @return the default color in this {@link ColorStateList}.
     */
    @ColorInt
    public int getDefaultColor() {
        return mDefaultColor;
    }
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content.res;

import android.annotation.ColorInt;
import com.android.internal.util.XmlUtils;

import org.xmlpull.v1.XmlPullParser;
@@ -925,6 +926,7 @@ public class Resources {
     * @return A single color value in the form 0xAARRGGBB.
     * @deprecated Use {@link #getColor(int, Theme)} instead.
     */
    @ColorInt
    public int getColor(@ColorRes int id) throws NotFoundException {
        return getColor(id, null);
    }
@@ -945,6 +947,7 @@ public class Resources {
     *
     * @return A single color value in the form 0xAARRGGBB.
     */
    @ColorInt
    public int getColor(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
        TypedValue value;
        synchronized (mAccessLock) {
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.res;

import android.annotation.AnyRes;
import android.annotation.ColorInt;
import android.annotation.Nullable;
import android.graphics.drawable.Drawable;
import android.os.StrictMode;
@@ -420,7 +421,8 @@ public class TypedArray {
     * @throws UnsupportedOperationException if the attribute is defined but is
     *         not an integer color or color state list.
     */
    public int getColor(int index, int defValue) {
    @ColorInt
    public int getColor(int index, @ColorInt int defValue) {
        if (mRecycled) {
            throw new RuntimeException("Cannot make calls to a recycled instance!");
        }
Loading