Define Utils.formatRelativeTime() and use it
Previously, relative times were formatted using formatElapsedTime() (appending translations of "ago" to them), sometimes resulting in grammatically hard-to-understand or unnatural localizations. Now we use ICU's RelativeDateTimeFormatter, which uses grammatically correct and natural localizations from CLDR data. Bug: 64507689 Bug: 64605781 Bug: 64556849 Bug: 64550172 Test: make -j RunSettingsRoboTests Change-Id: Ia2d098b190ab99e7748ef6f03b919f5c6174ba7d
This commit is contained in:
@@ -533,7 +533,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
updateScreenPreference();
|
||||
updateLastFullChargePreference(lastFullChargeTime);
|
||||
|
||||
final CharSequence timeSequence = Utils.formatElapsedTime(context, lastFullChargeTime,
|
||||
final CharSequence timeSequence = Utils.formatRelativeTime(context, lastFullChargeTime,
|
||||
false);
|
||||
final int resId = mShowAllApps ? R.string.power_usage_list_summary_device
|
||||
: R.string.power_usage_list_summary;
|
||||
@@ -682,10 +682,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
|
||||
@VisibleForTesting
|
||||
void updateLastFullChargePreference(long timeMs) {
|
||||
final CharSequence timeSequence = Utils.formatElapsedTime(getContext(), timeMs, false);
|
||||
mLastFullChargePref.setSubtitle(
|
||||
TextUtils.expandTemplate(getText(R.string.power_last_full_charge_summary),
|
||||
timeSequence));
|
||||
final CharSequence timeSequence = Utils.formatRelativeTime(getContext(), timeMs, false);
|
||||
mLastFullChargePref.setSubtitle(timeSequence);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
Reference in New Issue
Block a user