Update string for all defenders

Test: Unit test passed
Bug: 262508668
Change-Id: Ia0126f9761caa43d0746962a9bb77173e9f45ad1
This commit is contained in:
Zhenwei Chen
2022-12-14 18:33:12 +08:00
parent e8e2d9c68f
commit 1eea27ae82
5 changed files with 20 additions and 51 deletions

View File

@@ -42,8 +42,6 @@ import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.StringUtil;
import java.text.NumberFormat;
public class BatteryInfo {
private static final String TAG = "BatteryInfo";
@@ -305,13 +303,9 @@ public class BatteryInfo {
timeString);
info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
} else if (dockDefenderMode == BatteryUtils.DockDefenderMode.FUTURE_BYPASS) {
// Dock defender will be triggered in the future, charging will be paused at 90%.
final int extraValue = context.getResources().getInteger(
R.integer.config_battery_extra_tip_value);
final String extraPercentage = NumberFormat.getPercentInstance().format(
extraValue * 0.01f);
// Dock defender will be triggered in the future, charging will be optimized.
info.chargeLabel = context.getString(R.string.power_charging_future_paused,
info.batteryPercentString, extraPercentage);
info.batteryPercentString);
} else {
final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast,
compactStatus);

View File

@@ -32,8 +32,6 @@ import com.android.settings.widget.CardPreference;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import java.text.NumberFormat;
/**
* Tip to show dock defender status
*/
@@ -58,8 +56,7 @@ public class DockDefenderTip extends BatteryTip {
public CharSequence getTitle(Context context) {
switch (mMode) {
case DockDefenderMode.FUTURE_BYPASS:
return context.getString(R.string.battery_tip_dock_defender_future_bypass_title,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_future_bypass_title);
case DockDefenderMode.ACTIVE:
return context.getString(R.string.battery_tip_dock_defender_active_title);
case DockDefenderMode.TEMPORARILY_BYPASSED:
@@ -74,15 +71,12 @@ public class DockDefenderTip extends BatteryTip {
public CharSequence getSummary(Context context) {
switch (mMode) {
case DockDefenderMode.FUTURE_BYPASS:
return context.getString(R.string.battery_tip_dock_defender_future_bypass_summary,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_future_bypass_summary);
case DockDefenderMode.ACTIVE:
return context.getString(R.string.battery_tip_dock_defender_active_summary,
getExtraPercentage(context));
return context.getString(R.string.battery_tip_dock_defender_active_summary);
case DockDefenderMode.TEMPORARILY_BYPASSED:
return context.getString(
R.string.battery_tip_dock_defender_temporarily_bypassed_summary,
getExtraPercentage(context));
R.string.battery_tip_dock_defender_temporarily_bypassed_summary);
default:
return null;
}
@@ -174,13 +168,6 @@ public class DockDefenderTip extends BatteryTip {
Log.i(TAG, "send resume charging broadcast intent=" + intent);
}
private String getExtraPercentage(Context context) {
final int extraValue = context.getResources()
.getInteger(R.integer.config_battery_extra_tip_value);
return NumberFormat.getPercentInstance()
.format(extraValue * 0.01f);
}
public static final Creator CREATOR = new Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new DockDefenderTip(in);