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

Commit 09d0cbaf authored by Stanley Wang's avatar Stanley Wang Committed by Android (Google) Code Review
Browse files

Merge "Refine the IllustrationPreference." into sc-dev

parents 8f74aa34 4defdfae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,6 +18,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.settingslib.widget">

    <uses-sdk android:minSdkVersion="21" />
    <uses-sdk android:minSdkVersion="28" />

</manifest>
+0 −20
Original line number Diff line number Diff line
@@ -39,13 +39,6 @@ import java.util.HashMap;
public class ColorUtils {

    private static HashMap<String, Integer> sSysColors;
    static {
        sSysColors = new HashMap<>();
        sSysColors.put(".colorAccent", android.R.attr.colorAccent);
        sSysColors.put(".colorPrimary", android.R.attr.colorPrimary);
        sSysColors.put(".colorPrimaryDark", android.R.attr.colorPrimaryDark);
        sSysColors.put(".colorSecondary", android.R.attr.colorSecondary);
    }

    private static HashMap<String, Pair<Integer, Integer>> sFixedColors;
    static {
@@ -110,19 +103,6 @@ public class ColorUtils {
     * Apply the color of tags to the animation.
     */
    public static void applyDynamicColors(Context context, LottieAnimationView animationView) {
        for (String key : sSysColors.keySet()) {
            final int color = sSysColors.get(key);
            animationView.addValueCallback(
                    new KeyPath("**", key, "**"),
                    LottieProperty.COLOR_FILTER,
                    new SimpleLottieValueCallback<ColorFilter>() {
                        @Override
                        public ColorFilter getValue(LottieFrameInfo<ColorFilter> frameInfo) {
                            return new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
                        }
                    }
            );
        }
        for (String key : sFixedColors.keySet()) {
            final Pair<Integer, Integer> fixedColorPair = sFixedColors.get(key);
            final int color = isDarkMode(context) ? fixedColorPair.second : fixedColorPair.first;
+6 −2
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@ import com.airbnb.lottie.LottieAnimationView;
 */
public class IllustrationPreference extends Preference {

    static final String TAG = "IllustrationPreference";
    private static final String TAG = "IllustrationPreference";

    private static final boolean IS_ENABLED_LOTTIE_ADAPTIVE_COLOR = false;

    private int mAnimationId;
    private boolean mIsAutoScale;
@@ -70,7 +72,6 @@ public class IllustrationPreference extends Preference {
        mIllustrationView = (LottieAnimationView) holder.findViewById(R.id.lottie_view);
        mIllustrationView.setAnimation(mAnimationId);
        mIllustrationView.loop(true);
        ColorUtils.applyDynamicColors(getContext(), mIllustrationView);
        mIllustrationView.playAnimation();
        if (mIsAutoScale) {
            enableAnimationAutoScale(mIsAutoScale);
@@ -78,6 +79,9 @@ public class IllustrationPreference extends Preference {
        if (mMiddleGroundView != null) {
            enableMiddleGroundView();
        }
        if (IS_ENABLED_LOTTIE_ADAPTIVE_COLOR) {
            ColorUtils.applyDynamicColors(getContext(), mIllustrationView);
        }
    }

    @VisibleForTesting