From f66516b887700d7c6ca72c71ee29bdaa6b1dd116 Mon Sep 17 00:00:00 2001 From: iusmac Date: Mon, 27 Apr 2026 17:10:50 +0200 Subject: [PATCH 1/3] SystemUI: DynamicBar: Stop charging bolt glow on lock screen when fully charged * Also, switch to Modifier.graphicsLayer runnable to do the alpha property adjustments entirely by the GPU. Signed-off-by: iusmac --- .../ui/compose/AxDynamicBarKeyguardChip.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt index dd70d0f668dc6..79191f5406ab6 100644 --- a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt +++ b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt @@ -68,6 +68,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.lerp import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.pointerInput @@ -549,7 +550,7 @@ private fun KeyguardBatteryChip( ) { if (info.isCharging) { - AnimatedChargingBoltIcon(contentColor, BatteryIconSize) + AnimatedChargingBoltIcon(info.level, contentColor, BatteryIconSize) } else { AnimatedBatteryFillIcon(info.level, contentColor, BatteryIconSize) } @@ -633,7 +634,11 @@ private fun KeyguardBatteryChip( } @Composable -private fun AnimatedChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSize) { +private fun AnimatedChargingBoltIcon(level: Int, color: Color, iconSize: Dp = BatteryIconSize) { + if (level == 100) { + ChargingBoltIcon(color, iconSize) + return + } val transition = rememberInfiniteTransition(label = "kg_bolt") val glow by transition.animateFloat( initialValue = 0.5f, @@ -644,8 +649,15 @@ private fun AnimatedChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSiz ), label = "kg_bolt_glow", ) + ChargingBoltIcon(color, iconSize, Modifier.graphicsLayer { + this.alpha = glow + }) +} + +@Composable +private fun ChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSize, modifier: Modifier = Modifier) { val boltPath = remember { Path() } - Canvas(modifier = Modifier.size(iconSize)) { + Canvas(modifier = modifier.size(iconSize)) { val w = size.width val h = size.height boltPath.rewind() @@ -656,7 +668,7 @@ private fun AnimatedChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSiz boltPath.lineTo(w * 0.75f, h * 0.42f) boltPath.lineTo(w * 0.55f, h * 0.42f) boltPath.close() - drawPath(boltPath, color.copy(alpha = glow)) + drawPath(boltPath, color) } } From afa7691a5cc74cb085be191cb628366edd8f245b Mon Sep 17 00:00:00 2001 From: iusmac Date: Tue, 28 Apr 2026 09:55:14 +0200 Subject: [PATCH 2/3] SystemUI: DynamicBar: Draw the battery level in the charging bolt on lock screen Signed-off-by: iusmac --- .../ui/compose/AxDynamicBarKeyguardChip.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt index 79191f5406ab6..e83962799b480 100644 --- a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt +++ b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt @@ -68,6 +68,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.lerp import androidx.compose.ui.input.pointer.PointerEventPass @@ -636,7 +637,7 @@ private fun KeyguardBatteryChip( @Composable private fun AnimatedChargingBoltIcon(level: Int, color: Color, iconSize: Dp = BatteryIconSize) { if (level == 100) { - ChargingBoltIcon(color, iconSize) + ChargingBoltIcon(level, color, iconSize) return } val transition = rememberInfiniteTransition(label = "kg_bolt") @@ -649,13 +650,13 @@ private fun AnimatedChargingBoltIcon(level: Int, color: Color, iconSize: Dp = Ba ), label = "kg_bolt_glow", ) - ChargingBoltIcon(color, iconSize, Modifier.graphicsLayer { + ChargingBoltIcon(level, color, iconSize, Modifier.graphicsLayer { this.alpha = glow }) } @Composable -private fun ChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSize, modifier: Modifier = Modifier) { +private fun ChargingBoltIcon(level: Int, color: Color, iconSize: Dp = BatteryIconSize, modifier: Modifier = Modifier) { val boltPath = remember { Path() } Canvas(modifier = modifier.size(iconSize)) { val w = size.width @@ -668,7 +669,16 @@ private fun ChargingBoltIcon(color: Color, iconSize: Dp = BatteryIconSize, modif boltPath.lineTo(w * 0.75f, h * 0.42f) boltPath.lineTo(w * 0.55f, h * 0.42f) boltPath.close() - drawPath(boltPath, color) + + // Draw the empty battery capacity + drawPath(boltPath, color.copy(alpha = AlphaSecondary)) + + // Draw the remaining battery capacity + clipRect( + top = h * (1f - (level / 100f).coerceIn(0f, 1f)) + ) { + drawPath(boltPath, color) + } } } From a2fa3db65787f15fcb45573ca049fea01f69032b Mon Sep 17 00:00:00 2001 From: iusmac Date: Tue, 28 Apr 2026 09:50:30 +0200 Subject: [PATCH 3/3] SystemUI: DynamicBar: Adjust charging bolt icon shape on lock screen * Scaled to fit the drawing size (better battery capacity view). * Made it perfectly symmetrical. Signed-off-by: iusmac --- .../ui/compose/AxDynamicBarKeyguardChip.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt index e83962799b480..f9122d569cc02 100644 --- a/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt +++ b/packages/SystemUI/src/com/android/systemui/axdynamicbar/ui/compose/AxDynamicBarKeyguardChip.kt @@ -662,12 +662,12 @@ private fun ChargingBoltIcon(level: Int, color: Color, iconSize: Dp = BatteryIco val w = size.width val h = size.height boltPath.rewind() - boltPath.moveTo(w * 0.55f, h * 0.05f) - boltPath.lineTo(w * 0.25f, h * 0.50f) - boltPath.lineTo(w * 0.45f, h * 0.50f) - boltPath.lineTo(w * 0.40f, h * 0.95f) - boltPath.lineTo(w * 0.75f, h * 0.42f) - boltPath.lineTo(w * 0.55f, h * 0.42f) + boltPath.moveTo(w * 0.55f, 0f) + boltPath.lineTo(w * 0.20f, h * 0.63f) + boltPath.lineTo(w * 0.45f, h * 0.63f) + boltPath.lineTo(w * 0.45f, h) + boltPath.lineTo(w * 0.80f, h * 0.47f) + boltPath.lineTo(w * 0.55f, h * 0.47f) boltPath.close() // Draw the empty battery capacity