[Battery Usage] Make the timestamp slot info text format localizable.

(1) Some languages could localize the hephen to "~" or "to".
(2) Both 12hr format and 24hr format will have spaces around the hyphen.

Bug: 267185303
Bug: 266839251
Bug: 267349989
Bug: 267572852
Bug: 267595534
Test: manual
Change-Id: I62ff37d9ab20292621ee29ee3080cea7f8fd0fdb
This commit is contained in:
Zaiyue Xue
2023-02-08 14:19:25 +08:00
parent cb099dfc5e
commit d4aa8d764d
2 changed files with 8 additions and 3 deletions

View File

@@ -5301,6 +5301,10 @@
<string name="battery_usage_screen_footer_empty">Battery usage data will be available in a few hours once fully charged</string>
<!-- [CHAR_LIMIT=NONE] Battery chart label for the current time. -->
<string name="battery_usage_chart_label_now">now</string>
<!-- [CHAR_LIMIT=NONE] A hyphen for two timestamps. For example, "6 AM - 8 AM", which means "from 6 AM to 8 AM". Please notice the spaces around the hyphen -->
<string name="battery_usage_timestamps_hyphen"><xliff:g id="from_timestamp">%1$s</xliff:g> - <xliff:g id="to_timestamp">%2$s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] The first slot is a week day (e.g. "Monday"); the second slot is a hourly time span (e.g. "6 AM - 8 AM"). -->
<string name="battery_usage_day_and_hour"><xliff:g id="day">%1$s</xliff:g> <xliff:g id="hour">%2$s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] Accessibility content description for battery chart view. -->
<string name="battery_usage_chart">Battery usage chart</string>
<!-- [CHAR_LIMIT=NONE] Accessibility content description for daily battery chart view. -->

View File

@@ -440,7 +440,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
return selectedHourText;
}
return String.format("%s %s", selectedDayText, selectedHourText);
return mContext.getString(
R.string.battery_usage_day_and_hour, selectedDayText, selectedHourText);
}
private String getAccessibilityAnnounceMessage() {
@@ -666,8 +667,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
}
return index == timestamps.size() - 1
? generateText(timestamps, index)
: String.format("%s%s%s", generateText(timestamps, index),
mIs24HourFormat ? "-" : " - ", generateText(timestamps, index + 1));
: mContext.getString(R.string.battery_usage_timestamps_hyphen,
generateText(timestamps, index), generateText(timestamps, index + 1));
}
public HourlyChartLabelTextGenerator setLatestTimestamp(Long latestTimestamp) {