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

Commit 64e86d6d authored by Evan Laird's avatar Evan Laird
Browse files

Make the battery icon more obvious when in powersave mode

Draw the entire battery perimeter in colorError when in powersave, and
always draw the plus sign with the stroke protection around it so it's
obvious

Test: visual
Fixes: 127493241
Change-Id: Icccd06bfecf93d0dc92add9b36014d59af559ffe
parent 9a3c1f1d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3930,7 +3930,7 @@
        M5,17.5 V12 H3 L7,4.5 V10 h2 L5,17.5 z
    </string>
    <string name="config_batterymeterPowersavePath" translatable="false">
		M9,10l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z
		M9.75,10l-2.5,0l0,-2.5l-2.5,0l0,2.5l-2.5,0l0,2.5l2.5,0l0,2.5l2.5,0l0,-2.5l2.5,0z
    </string>

    <!-- A dual tone battery meter draws the perimeter path twice - once to define the shape
+15 −9
Original line number Diff line number Diff line
@@ -129,6 +129,14 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int)
        p.style = Paint.Style.FILL_AND_STROKE
    }

    private val errorPaint = Paint(Paint.ANTI_ALIAS_FLAG).also { p ->
        p.color = Utils.getColorErrorDefaultColor(context)
        p.alpha = 255
        p.isDither = true
        p.strokeWidth = 0f
        p.style = Paint.Style.FILL_AND_STROKE
    }

    // Only used if dualTone is set to true
    private val dualToneBackgroundFill = Paint(Paint.ANTI_ALIAS_FLAG).also { p ->
        p.color = frameColor
@@ -179,7 +187,7 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int)

        // The perimeter should never change
        unifiedPath.addPath(scaledPerimeter)
        // IF drawing dual tone, the level is used only to clip the whole drawable path
        // If drawing dual tone, the level is used only to clip the whole drawable path
        if (!dualTone) {
            unifiedPath.op(levelPath, Path.Op.UNION)
        }
@@ -196,9 +204,7 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int)
        } else if (powerSaveEnabled) {
            // Clip out the plus shape
            unifiedPath.op(scaledPlus, Path.Op.DIFFERENCE)
            if (!invertFillIcon) {
                c.drawPath(scaledPlus, fillPaint)
            }
            c.drawPath(scaledPlus, errorPaint)
        }

        if (dualTone) {
@@ -235,14 +241,14 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int)
                c.drawPath(scaledBolt, fillColorStrokeProtection)
            }
        } else if (powerSaveEnabled) {
            // If power save is enabled draw the perimeter path with colorError
            c.drawPath(scaledPerimeter, errorPaint)

            // But always put path protection around the plus sign
            c.clipOutPath(scaledPlus)
            if (invertFillIcon) {
                c.drawPath(scaledPlus, fillColorStrokePaint)
            } else {
            c.drawPath(scaledPlus, fillColorStrokeProtection)
        }
    }
    }

    private fun batteryColorForLevel(level: Int): Int {
        return when {