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

Commit eef3bcbb authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Replace usages of deprecated Resources.getColor() and getColorStateList()"

parents f9eb4b90 4a357cd2
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -2870,7 +2870,7 @@ public class Notification implements Parcelable
                    contentView.setProgressBar(
                    contentView.setProgressBar(
                            R.id.progress, mProgressMax, mProgress, mProgressIndeterminate);
                            R.id.progress, mProgressMax, mProgress, mProgressIndeterminate);
                    contentView.setProgressBackgroundTintList(
                    contentView.setProgressBackgroundTintList(
                            R.id.progress, ColorStateList.valueOf(mContext.getResources().getColor(
                            R.id.progress, ColorStateList.valueOf(mContext.getColor(
                                    R.color.notification_progress_background_color)));
                                    R.color.notification_progress_background_color)));
                    if (mColor != COLOR_DEFAULT) {
                    if (mColor != COLOR_DEFAULT) {
                        ColorStateList colorStateList = ColorStateList.valueOf(mColor);
                        ColorStateList colorStateList = ColorStateList.valueOf(mColor);
@@ -3044,7 +3044,7 @@ public class Notification implements Parcelable
        private void processLegacyAction(Action action, RemoteViews button) {
        private void processLegacyAction(Action action, RemoteViews button) {
            if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, action.icon)) {
            if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, action.icon)) {
                button.setTextViewCompoundDrawablesRelativeColorFilter(R.id.action0, 0,
                button.setTextViewCompoundDrawablesRelativeColorFilter(R.id.action0, 0,
                        mContext.getResources().getColor(R.color.notification_action_color_filter),
                        mContext.getColor(R.color.notification_action_color_filter),
                        PorterDuff.Mode.MULTIPLY);
                        PorterDuff.Mode.MULTIPLY);
            }
            }
        }
        }
@@ -3142,7 +3142,7 @@ public class Notification implements Parcelable


        private int resolveColor() {
        private int resolveColor() {
            if (mColor == COLOR_DEFAULT) {
            if (mColor == COLOR_DEFAULT) {
                return mContext.getResources().getColor(R.color.notification_icon_bg_color);
                return mContext.getColor(R.color.notification_icon_bg_color);
            }
            }
            return mColor;
            return mColor;
        }
        }
@@ -4321,9 +4321,9 @@ public class Notification implements Parcelable
         * Applies the special text colors for media notifications to all text views.
         * Applies the special text colors for media notifications to all text views.
         */
         */
        private void styleText(RemoteViews contentView) {
        private void styleText(RemoteViews contentView) {
            int primaryColor = mBuilder.mContext.getResources().getColor(
            int primaryColor = mBuilder.mContext.getColor(
                    R.color.notification_media_primary_color);
                    R.color.notification_media_primary_color);
            int secondaryColor = mBuilder.mContext.getResources().getColor(
            int secondaryColor = mBuilder.mContext.getColor(
                    R.color.notification_media_secondary_color);
                    R.color.notification_media_secondary_color);
            contentView.setTextColor(R.id.title, primaryColor);
            contentView.setTextColor(R.id.title, primaryColor);
            if (mBuilder.showsTimeOrChronometer()) {
            if (mBuilder.showsTimeOrChronometer()) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -927,6 +927,7 @@ public class Resources {
     * @deprecated Use {@link #getColor(int, Theme)} instead.
     * @deprecated Use {@link #getColor(int, Theme)} instead.
     */
     */
    @ColorInt
    @ColorInt
    @Deprecated
    public int getColor(@ColorRes int id) throws NotFoundException {
    public int getColor(@ColorRes int id) throws NotFoundException {
        return getColor(id, null);
        return getColor(id, null);
    }
    }
@@ -996,6 +997,7 @@ public class Resources {
     * @deprecated Use {@link #getColorStateList(int, Theme)} instead.
     * @deprecated Use {@link #getColorStateList(int, Theme)} instead.
     */
     */
    @Nullable
    @Nullable
    @Deprecated
    public ColorStateList getColorStateList(@ColorRes int id) throws NotFoundException {
    public ColorStateList getColorStateList(@ColorRes int id) throws NotFoundException {
        final ColorStateList csl = getColorStateList(id, null);
        final ColorStateList csl = getColorStateList(id, null);
        if (csl != null && csl.canApplyTheme()) {
        if (csl != null && csl.canApplyTheme()) {
@@ -1049,8 +1051,6 @@ public class Resources {
        return res;
        return res;
    }
    }




    /**
    /**
     * Return a boolean associated with a particular resource ID.  This can be
     * Return a boolean associated with a particular resource ID.  This can be
     * used with any integral resource value, and will return true if it is
     * used with any integral resource value, and will return true if it is
+1 −1
Original line number Original line Diff line number Diff line
@@ -328,7 +328,7 @@ final class StringBlock {
                String name = color.substring(1);
                String name = color.substring(1);
                int colorRes = res.getIdentifier(name, "color", "android");
                int colorRes = res.getIdentifier(name, "color", "android");
                if (colorRes != 0) {
                if (colorRes != 0) {
                    ColorStateList colors = res.getColorStateList(colorRes);
                    ColorStateList colors = res.getColorStateList(colorRes, null);
                    if (foreground) {
                    if (foreground) {
                        return new TextAppearanceSpan(null, 0, 0, colors, null);
                        return new TextAppearanceSpan(null, 0, 0, colors, null);
                    } else {
                    } else {
+1 −1
Original line number Original line Diff line number Diff line
@@ -672,7 +672,7 @@ class HtmlToSpannedConverter implements ContentHandler {
                    String name = f.mColor.substring(1);
                    String name = f.mColor.substring(1);
                    int colorRes = res.getIdentifier(name, "color", "android");
                    int colorRes = res.getIdentifier(name, "color", "android");
                    if (colorRes != 0) {
                    if (colorRes != 0) {
                        ColorStateList colors = res.getColorStateList(colorRes);
                        ColorStateList colors = res.getColorStateList(colorRes, null);
                        text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null),
                        text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null),
                                where, len,
                                where, len,
                                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+4 −4
Original line number Original line Diff line number Diff line
@@ -2981,8 +2981,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {


                            if (mStatusGuard == null) {
                            if (mStatusGuard == null) {
                                mStatusGuard = new View(mContext);
                                mStatusGuard = new View(mContext);
                                mStatusGuard.setBackgroundColor(mContext.getResources()
                                mStatusGuard.setBackgroundColor(mContext.getColor(
                                        .getColor(R.color.input_method_navigation_guard));
                                        R.color.input_method_navigation_guard));
                                addView(mStatusGuard, indexOfChild(mStatusColorViewState.view),
                                addView(mStatusGuard, indexOfChild(mStatusColorViewState.view),
                                        new LayoutParams(LayoutParams.MATCH_PARENT,
                                        new LayoutParams(LayoutParams.MATCH_PARENT,
                                                mlp.topMargin, Gravity.START | Gravity.TOP));
                                                mlp.topMargin, Gravity.START | Gravity.TOP));
@@ -3041,8 +3041,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                // position the navigation guard view, creating it if necessary
                // position the navigation guard view, creating it if necessary
                if (mNavigationGuard == null) {
                if (mNavigationGuard == null) {
                    mNavigationGuard = new View(mContext);
                    mNavigationGuard = new View(mContext);
                    mNavigationGuard.setBackgroundColor(mContext.getResources()
                    mNavigationGuard.setBackgroundColor(mContext.getColor(
                            .getColor(R.color.input_method_navigation_guard));
                            R.color.input_method_navigation_guard));
                    addView(mNavigationGuard, indexOfChild(mNavigationColorViewState.view),
                    addView(mNavigationGuard, indexOfChild(mNavigationColorViewState.view),
                            new LayoutParams(LayoutParams.MATCH_PARENT,
                            new LayoutParams(LayoutParams.MATCH_PARENT,
                                    insets.getSystemWindowInsetBottom(),
                                    insets.getSystemWindowInsetBottom(),
Loading