Use ThemedBatteryDrawable in settings

Changed out BatteryMeterDrawable to inherit from ThemedBatteryDrawable
instead of BatteryMeterDrawableBase. Also removed warning text paint
because it seemed unused and simplified the interface.

Bug: 123705805
Test: visual
Change-Id: I30496e3d8881803d9d3d8a316c10387482a8f610
This commit is contained in:
Evan Laird
2019-02-15 14:55:30 -05:00
parent b87dfdc189
commit 35e35622d9
3 changed files with 12 additions and 26 deletions

View File

@@ -29,7 +29,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.graph.BatteryMeterDrawableBase;
import com.android.settingslib.graph.ThemedBatteryDrawable;
public class BatteryMeterView extends ImageView {
@VisibleForTesting
@@ -54,29 +54,27 @@ public class BatteryMeterView extends ImageView {
final int frameColor = context.getColor(R.color.meter_background_color);
mAccentColorFilter = new PorterDuffColorFilter(
Utils.getColorAttrDefaultColor(context, android.R.attr.colorAccent),
PorterDuff.Mode.SRC_IN);
PorterDuff.Mode.SRC);
mErrorColorFilter = new PorterDuffColorFilter(
context.getColor(R.color.battery_icon_color_error), PorterDuff.Mode.SRC_IN);
mDrawable = new BatteryMeterDrawable(context, frameColor);
mDrawable.setShowPercent(false);
mDrawable.setBatteryColorFilter(mAccentColorFilter);
mDrawable.setWarningColorFilter(
new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN));
mDrawable.setColorFilter(mAccentColorFilter);
setImageDrawable(mDrawable);
setLayerType(LAYER_TYPE_SOFTWARE, null);
}
public void setBatteryLevel(int level) {
mDrawable.setBatteryLevel(level);
if (level < mDrawable.getCriticalLevel()) {
mDrawable.setBatteryColorFilter(mErrorColorFilter);
mDrawable.setColorFilter(mErrorColorFilter);
} else {
mDrawable.setBatteryColorFilter(mAccentColorFilter);
mDrawable.setColorFilter(mAccentColorFilter);
}
}
public void setPowerSave(boolean powerSave) {
mDrawable.setPowerSave(powerSave);
mDrawable.setPowerSaveEnabled(powerSave);
mPowerSaveEnabled = powerSave;
}
@@ -85,7 +83,7 @@ public class BatteryMeterView extends ImageView {
}
public int getBatteryLevel() {
return mDrawable.getBatteryLevel();
return mDrawable.getLevel();
}
public void setCharging(boolean charging) {
@@ -97,7 +95,7 @@ public class BatteryMeterView extends ImageView {
return mDrawable.getCharging();
}
public static class BatteryMeterDrawable extends BatteryMeterDrawableBase {
public static class BatteryMeterDrawable extends ThemedBatteryDrawable {
private final int mIntrinsicWidth;
private final int mIntrinsicHeight;
@@ -119,16 +117,5 @@ public class BatteryMeterView extends ImageView {
public int getIntrinsicHeight() {
return mIntrinsicHeight;
}
public void setWarningColorFilter(@Nullable ColorFilter colorFilter) {
mWarningTextPaint.setColorFilter(colorFilter);
}
public void setBatteryColorFilter(@Nullable ColorFilter colorFilter) {
mFramePaint.setColorFilter(colorFilter);
mBatteryPaint.setColorFilter(colorFilter);
mBoltPaint.setColorFilter(colorFilter);
}
}
}