Loading packages/SettingsLib/src/com/android/settingslib/graph/CircleBatteryDrawable.kt +14 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra private val padding = Rect() private val frame = RectF() private val boltFrame = RectF() private val pathEffect = DashPathEffect(floatArrayOf(3f,2f),0f) private var chargeColor: Int private var iconTint = Color.WHITE Loading Loading @@ -81,6 +82,12 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra postInvalidate() } var usePathEffect = false set(value) { field = value postInvalidate() } // an approximation of View.postInvalidate() private fun postInvalidate() { unscheduleSelf { invalidateSelf() } Loading Loading @@ -158,6 +165,13 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra framePaint.style = Paint.Style.STROKE batteryPaint.strokeWidth = strokeWidth batteryPaint.style = Paint.Style.STROKE if (usePathEffect) { batteryPaint.pathEffect = pathEffect powerSavePaint.pathEffect = pathEffect } else { batteryPaint.pathEffect = null powerSavePaint.pathEffect = null } powerSavePaint.strokeWidth = strokeWidth frame[ strokeWidth / 2.0f + padding.left, strokeWidth / 2.0f, Loading packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java +6 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { protected static final int BATTERY_STYLE_PORTRAIT = 0; protected static final int BATTERY_STYLE_CIRCLE = 1; protected static final int BATTERY_STYLE_TEXT = 2; protected static final int BATTERY_STYLE_DOTTED_CIRCLE = 3; @Retention(SOURCE) @IntDef({MODE_DEFAULT, MODE_ON, MODE_OFF, MODE_ESTIMATE}) Loading Loading @@ -685,7 +686,9 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { float iconScaleFactor = typedValue.getFloat(); int batteryHeight = res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_height); int batteryWidth = getBatteryStyle() == BATTERY_STYLE_CIRCLE ? int batteryWidth = (getBatteryStyle() == BATTERY_STYLE_CIRCLE || getBatteryStyle() == BATTERY_STYLE_DOTTED_CIRCLE) ? res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_circle_width) : res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_width); float mainBatteryHeight = batteryHeight * iconScaleFactor; Loading Loading @@ -730,6 +733,8 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryIconView.setVisibility(View.VISIBLE); break; case BATTERY_STYLE_CIRCLE: case BATTERY_STYLE_DOTTED_CIRCLE: mCircleDrawable.setUsePathEffect(getBatteryStyle() == BATTERY_STYLE_DOTTED_CIRCLE); mBatteryIconView.setImageDrawable(mCircleDrawable); mBatteryIconView.setVisibility(View.VISIBLE); break; Loading Loading
packages/SettingsLib/src/com/android/settingslib/graph/CircleBatteryDrawable.kt +14 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra private val padding = Rect() private val frame = RectF() private val boltFrame = RectF() private val pathEffect = DashPathEffect(floatArrayOf(3f,2f),0f) private var chargeColor: Int private var iconTint = Color.WHITE Loading Loading @@ -81,6 +82,12 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra postInvalidate() } var usePathEffect = false set(value) { field = value postInvalidate() } // an approximation of View.postInvalidate() private fun postInvalidate() { unscheduleSelf { invalidateSelf() } Loading Loading @@ -158,6 +165,13 @@ class CircleBatteryDrawable(private val context: Context, frameColor: Int) : Dra framePaint.style = Paint.Style.STROKE batteryPaint.strokeWidth = strokeWidth batteryPaint.style = Paint.Style.STROKE if (usePathEffect) { batteryPaint.pathEffect = pathEffect powerSavePaint.pathEffect = pathEffect } else { batteryPaint.pathEffect = null powerSavePaint.pathEffect = null } powerSavePaint.strokeWidth = strokeWidth frame[ strokeWidth / 2.0f + padding.left, strokeWidth / 2.0f, Loading
packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java +6 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { protected static final int BATTERY_STYLE_PORTRAIT = 0; protected static final int BATTERY_STYLE_CIRCLE = 1; protected static final int BATTERY_STYLE_TEXT = 2; protected static final int BATTERY_STYLE_DOTTED_CIRCLE = 3; @Retention(SOURCE) @IntDef({MODE_DEFAULT, MODE_ON, MODE_OFF, MODE_ESTIMATE}) Loading Loading @@ -685,7 +686,9 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { float iconScaleFactor = typedValue.getFloat(); int batteryHeight = res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_height); int batteryWidth = getBatteryStyle() == BATTERY_STYLE_CIRCLE ? int batteryWidth = (getBatteryStyle() == BATTERY_STYLE_CIRCLE || getBatteryStyle() == BATTERY_STYLE_DOTTED_CIRCLE) ? res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_circle_width) : res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_width); float mainBatteryHeight = batteryHeight * iconScaleFactor; Loading Loading @@ -730,6 +733,8 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver { mBatteryIconView.setVisibility(View.VISIBLE); break; case BATTERY_STYLE_CIRCLE: case BATTERY_STYLE_DOTTED_CIRCLE: mCircleDrawable.setUsePathEffect(getBatteryStyle() == BATTERY_STYLE_DOTTED_CIRCLE); mBatteryIconView.setImageDrawable(mCircleDrawable); mBatteryIconView.setVisibility(View.VISIBLE); break; Loading