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

Commit b4f8a0be authored by jackqdyulei's avatar jackqdyulei
Browse files

Update the bt background color.

The previous cl pass in the resource id rather than real color.
This cl fix the bug.

Bug: 65397557
Test: RunSettingslibRoboTests
Change-Id: I9dafc8bef6adf48b37eba4deff7462f9ba83a695
parent 73e6ff19
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
        final Drawable deviceDrawable = context.getDrawable(resId);

        final BatteryMeterDrawable batteryDrawable = new BatteryMeterDrawable(context,
                R.color.meter_background_color, batteryLevel);
                context.getColor(R.color.meter_background_color), batteryLevel);
        final int pad = context.getResources().getDimensionPixelSize(R.dimen.bt_battery_padding);
        batteryDrawable.setPadding(pad, pad, pad, pad);

@@ -107,6 +107,8 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
    @VisibleForTesting
    static class BatteryMeterDrawable extends BatteryMeterDrawableBase {
        private final float mAspectRatio;
        @VisibleForTesting
        int mFrameColor;

        public BatteryMeterDrawable(Context context, int frameColor, int batteryLevel) {
            super(context, frameColor);
@@ -118,6 +120,7 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
            final int tintColor = Utils.getColorAttr(context, android.R.attr.colorControlNormal);
            setColorFilter(new PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_IN));
            setBatteryLevel(batteryLevel);
            mFrameColor = frameColor;
        }

        @Override
+11 −0
Original line number Diff line number Diff line
@@ -100,4 +100,15 @@ public class BluetoothDeviceLayerDrawableTest {
        assertThat(twinDrawable.getLayerInsetTop(1)).isEqualTo(
                drawable.getLayerInsetTop(1));
    }

    @Test
    public void testCreateLayerDrawable_bluetoothDrawable_hasCorrectFrameColor() {
        BluetoothDeviceLayerDrawable drawable = BluetoothDeviceLayerDrawable.createLayerDrawable(
                mContext, RES_ID, BATTERY_LEVEL);
        BluetoothDeviceLayerDrawable.BatteryMeterDrawable batteryMeterDrawable =
                (BluetoothDeviceLayerDrawable.BatteryMeterDrawable) drawable.getDrawable(1);

        assertThat(batteryMeterDrawable.mFrameColor).isEqualTo(
                mContext.getColor(R.color.meter_background_color));
    }
}