Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Unified Diff: ash/system/chromeos/power/battery_notification.cc

Issue 1951493002: Fix i18n number formats in tray power displays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch unit test from Bengali to Persian for Android (and merge) Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/ash_chromeos_strings.grdp ('k') | ash/system/chromeos/power/power_status_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/power/battery_notification.cc
diff --git a/ash/system/chromeos/power/battery_notification.cc b/ash/system/chromeos/power/battery_notification.cc
index d35868bf1ef6d7bf5fa4ac61c2193f38bfa78996..ba52245372c9328ddb9c0ab7a2655faabfab4af3 100644
--- a/ash/system/chromeos/power/battery_notification.cc
+++ b/ash/system/chromeos/power/battery_notification.cc
@@ -6,7 +6,8 @@
#include "ash/system/chromeos/power/power_status.h"
#include "ash/system/system_notifier.h"
-#include "base/strings/string_number_conversions.h"
+#include "base/i18n/message_formatter.h"
+#include "base/i18n/time_formatting.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "grit/ash_resources.h"
@@ -47,9 +48,9 @@ std::unique_ptr<Notification> CreateNotification(
TrayPower::NotificationState notification_state) {
const PowerStatus& status = *PowerStatus::Get();
- base::string16 message = l10n_util::GetStringFUTF16(
- IDS_ASH_STATUS_TRAY_BATTERY_PERCENT,
- base::IntToString16(status.GetRoundedBatteryPercent()));
+ base::string16 message = base::i18n::MessageFormatter::FormatWithNumberedArgs(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_PERCENT),
+ static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0);
const base::TimeDelta time = status.IsBatteryCharging()
? status.GetBatteryTimeToFull()
@@ -60,17 +61,14 @@ std::unique_ptr<Notification> CreateNotification(
IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
} else if (PowerStatus::ShouldDisplayBatteryTime(time) &&
!status.IsBatteryDischargingOnLinePower()) {
- int hour = 0, min = 0;
- PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min);
if (status.IsBatteryCharging()) {
time_message = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
- base::IntToString16(hour), base::IntToString16(min));
+ TimeDurationFormat(time, base::DURATION_WIDTH_NARROW));
} else {
// This is a low battery warning prompting the user in minutes.
- time_message = ui::TimeFormat::Simple(
- ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_LONG,
- base::TimeDelta::FromMinutes(hour * 60 + min));
+ time_message = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING,
+ ui::TimeFormat::LENGTH_LONG, time);
}
}
« no previous file with comments | « ash/ash_chromeos_strings.grdp ('k') | ash/system/chromeos/power/power_status_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698