Merge "Use ColorMatrixColorFilter in batterymeterview"

This commit is contained in:
TreeHugger Robot
2020-10-28 20:35:02 +00:00
committed by Android (Google) Code Review

View File

@@ -19,8 +19,6 @@ package com.android.settings.fuelgauge;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.Context; import android.content.Context;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.ImageView; import android.widget.ImageView;
@@ -52,14 +50,12 @@ public class BatteryMeterView extends ImageView {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
final int frameColor = context.getColor(R.color.meter_background_color); final int frameColor = context.getColor(R.color.meter_background_color);
mAccentColorFilter = new PorterDuffColorFilter( mAccentColorFilter = Utils.getAlphaInvariantColorFilterForColor(
Utils.getColorAttrDefaultColor(context, android.R.attr.colorAccent), Utils.getColorAttrDefaultColor(context, android.R.attr.colorAccent));
PorterDuff.Mode.SRC); mErrorColorFilter = Utils.getAlphaInvariantColorFilterForColor(
mErrorColorFilter = new PorterDuffColorFilter( context.getColor(R.color.battery_icon_color_error));
context.getColor(R.color.battery_icon_color_error), PorterDuff.Mode.SRC_IN); mForegroundColorFilter = Utils.getAlphaInvariantColorFilterForColor(
mForegroundColorFilter =new PorterDuffColorFilter( Utils.getColorAttrDefaultColor(context, android.R.attr.colorForeground));
Utils.getColorAttrDefaultColor(context, android.R.attr.colorForeground),
PorterDuff.Mode.SRC);
mDrawable = new BatteryMeterDrawable(context, frameColor); mDrawable = new BatteryMeterDrawable(context, frameColor);
mDrawable.setColorFilter(mAccentColorFilter); mDrawable.setColorFilter(mAccentColorFilter);
setImageDrawable(mDrawable); setImageDrawable(mDrawable);