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

Commit a3caf751 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use the new ColorResources.createWithOverlay API" into main

parents 141940f3 8b63d6a9
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.appwidget;

import static android.appwidget.flags.Flags.FLAG_ENGAGEMENT_METRICS;
import static android.appwidget.flags.Flags.engagementMetrics;
import static android.content.res.Flags.selfTargetingAndroidResourceFrro;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
@@ -961,17 +962,23 @@ public class AppWidgetHostView extends FrameLayout implements AppWidgetHost.AppW
     *
     * Calling this method will trigger a full re-inflation of the App Widget.
     *
     * The color resources that can be overloaded are the ones whose name is prefixed with
     * {@code system_neutral} or {@code system_accent}, for example
     * {@link android.R.color#system_neutral1_500}.
     * If flag {@code android.content.res.self_targeting_android_resource_frro} is set, any colors
     * in {@code colorMapping} will be overloaded, otherwise the color resources that can
     * be overloaded are the ones whose name is prefixed with {@code system_neutral} or
     * {@code system_accent}, for example {@link android.R.color#system_neutral1_500}.
     */
    public void setColorResources(@NonNull SparseIntArray colorMapping) {
        if (mColorResources != null
                && isSameColorMapping(mColorResources.getColorMapping(), colorMapping)) {
            return;
        }
        if (selfTargetingAndroidResourceFrro()) {
            setColorResources(
                    RemoteViews.ColorResources.createWithOverlay(mContext, colorMapping));
        } else {
            setColorResources(RemoteViews.ColorResources.create(mContext, colorMapping));
        }
    }

    private void setColorResourcesStates(RemoteViews.ColorResources colorResources) {
        mColorResources = colorResources;