Skip to content

Commit 453e8f2

Browse files
committed
SysUI: Fix coloring of battery drawables
The frame color is now correctly tinted based on background color set by setDarkIntensity() Battery bolt and percentage text have their alpha set to full opacity to increase visibility when drawn on a light colored status bar. Change-Id: I907101ed1465f99b92370332d4839b7f0aad13b2
1 parent e3ddac3 commit 453e8f2

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/SystemUI/res/drawable/ic_battery_circle_frame.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
android:viewportWidth="24"
2121
android:viewportHeight="24">
2222

23+
<!-- Path will be tinted based on dual tone color -->
2324
<path
2425
android:name="frame"
25-
android:strokeColor="@color/batterymeter_frame_color"
26+
android:strokeColor="#000000"
2627
android:strokeLineJoin="round"
2728
android:strokeWidth="3"
2829
android:pathData="@string/battery_circle_path"/>

packages/SystemUI/res/drawable/ic_battery_landscape_frame.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
android:name="mask"
2525
android:pathData="@string/battery_landscape_clip_path" />
2626

27+
<!-- Path will be tinted based on dual tone color -->
2728
<path
2829
android:name="frame"
29-
android:fillColor="@color/batterymeter_frame_color"
30+
android:fillColor="#000000"
3031
android:pathData="M 1 4 H 25 V 20 H 1 V 4 Z" />
3132
</vector>

packages/SystemUI/res/drawable/ic_battery_portrait_frame.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
android:name="mask"
2525
android:pathData="@string/battery_portrait_clip_path" />
2626

27+
<!-- Path will be tinted based on dual tone color -->
2728
<path
2829
android:name="frame"
29-
android:fillColor="@color/batterymeter_frame_color"
30+
android:fillColor="#000000"
3031
android:pathData="M19,2v19H5V2H19z" />
3132

3233
</vector>

packages/SystemUI/src/com/android/systemui/BatteryMeterView.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,9 @@ public void onDispose() {
537537
@Override
538538
public void setDarkIntensity(int backgroundColor, int fillColor) {
539539
mIconTint = fillColor;
540-
mBoltDrawable.setTint(fillColor);
540+
// make bolt drawable tint fully opaque so it stands out
541+
mBoltDrawable.setTint(0xff000000 | fillColor);
542+
mFrameDrawable.setTint(backgroundColor);
541543
updateBoltDrawableLayer(mBatteryDrawable, mBoltDrawable);
542544
invalidate();
543545
}
@@ -660,7 +662,8 @@ private void drawPercentageText(Canvas canvas, BatteryTracker tracker) {
660662
&& (mShowPercent && !(level == 100 && !SHOW_100_PERCENT))) {
661663
// draw the percentage text
662664
String pctText = String.valueOf(SINGLE_DIGIT_PERCENT ? (level/10) : level);
663-
mTextAndBoltPaint.setColor(getColorForLevel(level));
665+
// make paint color fully opaque so text stands out better
666+
mTextAndBoltPaint.setColor(0xff000000 | getColorForLevel(level));
664667
canvas.drawText(pctText, mTextX, mTextY, mTextAndBoltPaint);
665668
} else if (level <= mCriticalLevel) {
666669
// draw the warning text

0 commit comments

Comments
 (0)