Fix percentage formatting throughout Settings.
Bug: 15476051 Change-Id: Ic64e7c36d0e2732d3e0e79fec2b79de42decf77d
This commit is contained in:
@@ -335,8 +335,7 @@ public final class Utils {
|
||||
|
||||
/** Formats a double from 0.0..1.0 as a percentage. */
|
||||
private static String formatPercentage(double percentage) {
|
||||
BidiFormatter bf = BidiFormatter.getInstance();
|
||||
return bf.unicodeWrap(NumberFormat.getPercentInstance().format(percentage));
|
||||
return NumberFormat.getPercentInstance().format(percentage);
|
||||
}
|
||||
|
||||
public static boolean isBatteryPresent(Intent batteryChangedIntent) {
|
||||
|
@@ -494,6 +494,7 @@ public class BatteryHistoryChart extends View {
|
||||
mMinPercentLabelString = Utils.formatPercentage(0);
|
||||
|
||||
mBatteryLevel = com.android.settings.Utils.getBatteryLevel(mBatteryBroadcast);
|
||||
String batteryPercentString = Utils.formatPercentage(mBatteryLevel);
|
||||
long remainingTimeUs = 0;
|
||||
mDischarging = true;
|
||||
if (mBatteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) == 0) {
|
||||
@@ -503,9 +504,9 @@ public class BatteryHistoryChart extends View {
|
||||
String timeString = Formatter.formatShortElapsedTime(getContext(),
|
||||
drainTime / 1000);
|
||||
mChargeLabelString = getContext().getResources().getString(
|
||||
R.string.power_discharging_duration, mBatteryLevel, timeString);
|
||||
R.string.power_discharging_duration, batteryPercentString, timeString);
|
||||
} else {
|
||||
mChargeLabelString = Utils.formatPercentage(mBatteryLevel);
|
||||
mChargeLabelString = batteryPercentString;
|
||||
}
|
||||
} else {
|
||||
final long chargeTime = mStats.computeChargeTimeRemaining(elapsedRealtimeUs);
|
||||
@@ -530,10 +531,10 @@ public class BatteryHistoryChart extends View {
|
||||
resId = R.string.power_charging_duration;
|
||||
}
|
||||
mChargeLabelString = getContext().getResources().getString(
|
||||
resId, mBatteryLevel, timeString);
|
||||
resId, batteryPercentString, timeString);
|
||||
} else {
|
||||
mChargeLabelString = getContext().getResources().getString(
|
||||
R.string.power_charging, mBatteryLevel, statusLabel);
|
||||
R.string.power_charging, batteryPercentString, statusLabel);
|
||||
}
|
||||
}
|
||||
mDrainString = "";
|
||||
|
@@ -37,6 +37,7 @@ import android.widget.Switch;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.notification.SettingPref;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
@@ -78,7 +79,8 @@ public class BatterySaverSettings extends SettingsPreferenceFragment
|
||||
@Override
|
||||
protected String getCaption(Resources res, int value) {
|
||||
if (value > 0 && value < 100) {
|
||||
return res.getString(R.string.battery_saver_turn_on_automatically_pct, value);
|
||||
return res.getString(R.string.battery_saver_turn_on_automatically_pct,
|
||||
Utils.formatPercentage(value));
|
||||
}
|
||||
return res.getString(R.string.battery_saver_turn_on_automatically_never);
|
||||
}
|
||||
|
Reference in New Issue
Block a user