Battery icon is too large

-sync layout from SystemUI

Bug: 141139595
Test: make -j42 RunSettingsRoboTests
Change-Id: I5e165e953682fcfdebf0d06475bb1abd171684d9
(cherry picked from commit c71f996da9)
Merged-In: I5e165e953682fcfdebf0d06475bb1abd171684d9
This commit is contained in:
timhypeng
2019-11-14 10:53:32 +08:00
committed by Tim Peng
parent ff9bcdbcd3
commit b6b29c1af0
4 changed files with 28 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ import java.util.Map;
public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop, OnDestroy, CachedBluetoothDevice.Callback {
private static final String TAG = "AdvancedBtHeaderCtrl";
private static final int LOW_BATTERY_LEVEL = 20;
@VisibleForTesting
LayoutPreference mLayoutPreference;
@@ -180,12 +181,18 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
Drawable createBtBatteryIcon(Context context, int level, boolean charging) {
final BatteryMeterView.BatteryMeterDrawable drawable =
new BatteryMeterView.BatteryMeterDrawable(context,
context.getColor(R.color.meter_background_color));
context.getColor(R.color.meter_background_color),
context.getResources().getDimensionPixelSize(
R.dimen.advanced_bluetooth_battery_meter_width),
context.getResources().getDimensionPixelSize(
R.dimen.advanced_bluetooth_battery_meter_height));
drawable.setBatteryLevel(level);
final int attr = level > LOW_BATTERY_LEVEL || charging
? android.R.attr.colorControlNormal
: android.R.attr.colorError;
drawable.setColorFilter(new PorterDuffColorFilter(
com.android.settings.Utils.getColorAttrDefaultColor(context,
android.R.attr.colorControlNormal),
PorterDuff.Mode.SRC_IN));
com.android.settings.Utils.getColorAttrDefaultColor(context, attr),
PorterDuff.Mode.SRC));
drawable.setCharging(charging);
return drawable;

View File

@@ -117,6 +117,13 @@ public class BatteryMeterView extends ImageView {
.getDimensionPixelSize(R.dimen.battery_meter_height);
}
public BatteryMeterDrawable(Context context, int frameColor, int width, int height) {
super(context, frameColor);
mIntrinsicWidth = width;
mIntrinsicHeight = height;
}
@Override
public int getIntrinsicWidth() {
return mIntrinsicWidth;