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

Commit cf94f530 authored by burakov's avatar burakov Committed by Danny Burakov
Browse files

[flexiglass] Show the battery estimate in collapsed view without cutout.

This aligns the implementation with the legacy shade
(QsBatteryModeController.getBatteryMode).

Fix: 414760909
Bug: 298525212
Test: Manually tested by opening the single shade on a device without a
 center cutout, and observing that the battery estimate is shown instead
 of percentage.
Flag: com.android.systemui.scene_container
Change-Id: Ibc50fced41090dbbc573f76e28e339f612b11ee3
parent 81ac1ee3
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -559,6 +559,8 @@ private fun BatteryIcon(
    val inverseColor =
        Utils.getColorAttrDefaultColor(themedContext, android.R.attr.textColorPrimaryInverse)

    val cutoutLocation = LocalDisplayCutout.current.location

    AndroidView(
        factory = { context ->
            val batteryIcon = BatteryMeterView(context, null)
@@ -577,10 +579,12 @@ private fun BatteryIcon(
            batteryIcon
        },
        update = { batteryIcon ->
            // TODO(b/298525212): use MODE_ESTIMATE in collapsed view when the screen
            //  has no center cutout. See [QsBatteryModeController.getBatteryMode]
            batteryIcon.setPercentShowMode(
                if (useExpandedFormat) BatteryMeterView.MODE_ESTIMATE else BatteryMeterView.MODE_ON
                if (useExpandedFormat || cutoutLocation != CutoutLocation.CENTER) {
                    BatteryMeterView.MODE_ESTIMATE
                } else {
                    BatteryMeterView.MODE_ON
                }
            )
            // TODO(b/397223606): Get the actual spec for this.
            batteryIcon.updateColors(