Merge "Make the battery icon more obvious when in powersave mode"

This commit is contained in:
TreeHugger Robot
2019-03-07 20:56:17 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 10 deletions

View File

@@ -3933,7 +3933,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

View File

@@ -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,12 +241,12 @@ 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)
}
c.drawPath(scaledPlus, fillColorStrokeProtection)
}
}