Skip to content

Commit e4bb406

Browse files
adithya2306Jayant-Deshmukh
authored andcommitted
BatteryMeterView: Set percent text color to red in battery saver for Text only battery style
@Jayant-Deshmukh - Adapt for LineageOS impl A15 QPR1 Signed-off-by: Jayant-Deshmukh <[email protected]>
1 parent a0a7a65 commit e4bb406

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import androidx.annotation.VisibleForTesting;
5050

5151
import com.android.app.animation.Interpolators;
52+
import com.android.settingslib.Utils;
5253
import com.android.settingslib.graph.CircleBatteryDrawable;
5354
import com.android.systemui.DualToneHandler;
5455
import com.android.systemui.battery.unified.BatteryColors;
@@ -334,6 +335,7 @@ void onPowerSaveChanged(boolean isPowerSave) {
334335
if (!newStatusBarIcons()) {
335336
mAccessorizedDrawable.setPowerSaveEnabled(isPowerSave);
336337
mCircleDrawable.setPowerSaveEnabled(isPowerSave);
338+
updateShowPercent();
337339
} else {
338340
setBatteryDrawableState(
339341
new BatteryDrawableState(
@@ -404,7 +406,6 @@ private void addPercentView(TextView inflatedPercentView) {
404406
}
405407
float fontHeight = mBatteryPercentView.getPaint().getFontMetricsInt(null);
406408
mBatteryPercentView.setLineHeight(TypedValue.COMPLEX_UNIT_PX, fontHeight);
407-
if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor);
408409
addView(mBatteryPercentView, new LayoutParams(
409410
LayoutParams.WRAP_CONTENT,
410411
(int) Math.ceil(fontHeight)));
@@ -546,6 +547,21 @@ private void updateContentDescription() {
546547
setContentDescription(contentDescription);
547548
}
548549

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+
549565
void updateShowPercent() {
550566
if (!newStatusBarIcons()) {
551567
updateShowPercentLegacy();
@@ -608,6 +624,7 @@ private void updateShowPercentLegacy() {
608624
}
609625
if (getBatteryStyle() == BATTERY_STYLE_TEXT) {
610626
mBatteryPercentView.setPaddingRelative(0, 0, 0, 0);
627+
updatePercentTextColor();
611628
} else {
612629
Resources res = getContext().getResources();
613630
mBatteryPercentView.setPaddingRelative(
@@ -805,9 +822,7 @@ public void updateColors(int foregroundColor, int backgroundColor, int singleTon
805822
mAccessorizedDrawable.setColors(foregroundColor, backgroundColor, singleToneColor);
806823
mCircleDrawable.setColors(foregroundColor, backgroundColor, singleToneColor);
807824
mTextColor = singleToneColor;
808-
if (mBatteryPercentView != null) {
809-
mBatteryPercentView.setTextColor(singleToneColor);
810-
}
825+
updatePercentTextColor();
811826

812827
if (mUnknownStateDrawable != null) {
813828
mUnknownStateDrawable.setTint(singleToneColor);

0 commit comments

Comments
 (0)