Merge "Refine the IllustrationPreference." into sc-dev

This commit is contained in:
Stanley Wang
2021-06-16 09:22:00 +00:00
committed by Android (Google) Code Review
3 changed files with 7 additions and 23 deletions

View File

@@ -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>

View File

@@ -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;

View File

@@ -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