|
49 | 49 | import androidx.annotation.VisibleForTesting; |
50 | 50 |
|
51 | 51 | import com.android.app.animation.Interpolators; |
| 52 | +import com.android.settingslib.Utils; |
52 | 53 | import com.android.settingslib.graph.CircleBatteryDrawable; |
53 | 54 | import com.android.systemui.DualToneHandler; |
54 | 55 | import com.android.systemui.battery.unified.BatteryColors; |
@@ -334,6 +335,7 @@ void onPowerSaveChanged(boolean isPowerSave) { |
334 | 335 | if (!newStatusBarIcons()) { |
335 | 336 | mAccessorizedDrawable.setPowerSaveEnabled(isPowerSave); |
336 | 337 | mCircleDrawable.setPowerSaveEnabled(isPowerSave); |
| 338 | + updateShowPercent(); |
337 | 339 | } else { |
338 | 340 | setBatteryDrawableState( |
339 | 341 | new BatteryDrawableState( |
@@ -404,7 +406,6 @@ private void addPercentView(TextView inflatedPercentView) { |
404 | 406 | } |
405 | 407 | float fontHeight = mBatteryPercentView.getPaint().getFontMetricsInt(null); |
406 | 408 | mBatteryPercentView.setLineHeight(TypedValue.COMPLEX_UNIT_PX, fontHeight); |
407 | | - if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor); |
408 | 409 | addView(mBatteryPercentView, new LayoutParams( |
409 | 410 | LayoutParams.WRAP_CONTENT, |
410 | 411 | (int) Math.ceil(fontHeight))); |
@@ -546,6 +547,21 @@ private void updateContentDescription() { |
546 | 547 | setContentDescription(contentDescription); |
547 | 548 | } |
548 | 549 |
|
| 550 | + private void updatePercentTextColor() { |
| 551 | + if (mBatteryPercentView == null) { |
| 552 | + return; |
| 553 | + } |
| 554 | + if (getBatteryStyle() == BATTERY_STYLE_TEXT && mPowerSaveEnabled) { |
| 555 | + // Use the error (red) color, same as battery saver icon |
| 556 | + mBatteryPercentView.setTextColor(Utils.getColorError(getContext())); |
| 557 | + } else if (mTextColor != 0) { |
| 558 | + mBatteryPercentView.setTextColor(mTextColor); |
| 559 | + } else { |
| 560 | + mBatteryPercentView.setTextColor(Utils.getColorAttr( |
| 561 | + getContext(), android.R.attr.textColorPrimary)); |
| 562 | + } |
| 563 | + } |
| 564 | + |
549 | 565 | void updateShowPercent() { |
550 | 566 | if (!newStatusBarIcons()) { |
551 | 567 | updateShowPercentLegacy(); |
@@ -608,6 +624,7 @@ private void updateShowPercentLegacy() { |
608 | 624 | } |
609 | 625 | if (getBatteryStyle() == BATTERY_STYLE_TEXT) { |
610 | 626 | mBatteryPercentView.setPaddingRelative(0, 0, 0, 0); |
| 627 | + updatePercentTextColor(); |
611 | 628 | } else { |
612 | 629 | Resources res = getContext().getResources(); |
613 | 630 | mBatteryPercentView.setPaddingRelative( |
@@ -805,9 +822,7 @@ public void updateColors(int foregroundColor, int backgroundColor, int singleTon |
805 | 822 | mAccessorizedDrawable.setColors(foregroundColor, backgroundColor, singleToneColor); |
806 | 823 | mCircleDrawable.setColors(foregroundColor, backgroundColor, singleToneColor); |
807 | 824 | mTextColor = singleToneColor; |
808 | | - if (mBatteryPercentView != null) { |
809 | | - mBatteryPercentView.setTextColor(singleToneColor); |
810 | | - } |
| 825 | + updatePercentTextColor(); |
811 | 826 |
|
812 | 827 | if (mUnknownStateDrawable != null) { |
813 | 828 | mUnknownStateDrawable.setTint(singleToneColor); |
|
0 commit comments