0

Update battery status notifications

Updated battery notifications to always include titles.
Moved battery notification strings together in ash_strings.grd

Bug: 1316576
Change-Id: Ie28869c600db2430bf8748564a2e69b81ad3bd54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656548
Reviewed-by: Andre Le <leandre@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1007566}
This commit is contained in:
Ahmed Mehfooz
2022-05-25 21:14:36 +00:00
committed by Chromium LUCI CQ
parent 6f4820d55e
commit 93b0386d19
8 changed files with 88 additions and 63 deletions

@ -2025,7 +2025,62 @@ This file contains the strings for ash.
<message name="IDS_ASH_POWER_SOURCE_PORT_UNKNOWN" desc="The text referring to the device to charge from, when its port location cannot be determined.">
USB-C device
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_TITLE" desc="The title in the generic notificiation for battery being charged.">Battery Charging</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_FULL" desc="The label in the tray dialog to indicate that the battery is full.">
Battery full
</message>
<message name="IDS_ASH_STATUS_TRAY_CRITICAL_BATTERY_TITLE" desc="The title for the notification displayed when device battery level is critically low.">Device will power down soon</message>
<message name="IDS_ASH_STATUS_TRAY_LOW_BATTERY_TITLE" desc="The title for the notification displayed when device battery level is low.">Low Battery</message>
<message name="IDS_ASH_STATUS_TRAY_LOW_BATTERY_MESSAGE" desc="The label in the tray dialog to show the remaining battery power as a percent.">
About <ph name="time_left">$1<ex>40 minutes</ex></ph> left (<ph name="percentage">$2<ex>56%</ex></ph>%).
Connect your device to power.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_TITLE" desc="The title displayed in a battery status notification.">Battery status</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT" desc="The label in the tray dialog to show the remaining battery power as a percent.">
<ph name="percentage">{0,number,percent}<ex>56%</ex></ph> remaining
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL" desc="The label in the tray dialog to show a time estimate until the battery is fully charged.">
<ph name="time">$1<ex>2h 53m</ex></ph> until full
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING" desc="The label in the tray dialog indicating that the time to charge or discharge the battery is being calculated.">
Calculating...
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT" desc="The label in the tray bubble settings row to show a time estimate until the battery is empty.">
<ph name="time">$1<ex>2:53</ex></ph> left
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT" desc="The label in the tray bubble settings row to show a time estimate until the battery is fully charged.">
<ph name="time">$1<ex>2:53</ex></ph> until full
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE" desc="The label in the tray dialog to indicate that battery charging is unreliable.">
Battery charging may be unreliable.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE" desc="The message used by accessibility to show battery is fully charged.">
Battery is full.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ACCESSIBLE" desc="The message used by accessibility to show battery is discharging.">
Battery at <ph name="percentage">$1<ex>56</ex></ph> percent.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_CHARGING_ACCESSIBLE" desc="The message used by accessibility to show battery is being charged.">
Battery at <ph name="percentage">$1<ex>56</ex></ph>% and charging.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_ACCESSIBLE" desc="The message used by accessibility to show battery is calculating its time in short message.">
Calculating battery time.
</message>
<message name= "IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_ACCESSIBLE" desc="The message used by accessibility to read remaining battery time until empty.">
<ph name="time_left">$1<ex>1 hour and 15 minutes</ex></ph> until battery is empty.
</message>
<message name= "IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_ACCESSIBLE" desc="The message used by accessibility to read the estimated time until full.">
<ph name="time_remaining">$1<ex>1 hour and 15 minutes</ex></ph> remaining until battery is fully charged.
</message>
<message name = "IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE" desc="The message used by accessibility to read battery time, which includes both non-zero hours and minutes.">
<ph name="hour">$1<ex> 1 hour</ex></ph> and <ph name="minute">$2<ex>15 minutes</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE_ACCESSIBLE" desc="The message used by accessibility to indicate that battery charging is unreliable.">
Plugged in to a low-power charger. Battery charging may not be reliable.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_STATUS_SEPARATOR" desc="The separator symbol between battery percentage string and battery remaining time string">
''' - '''
</message>
<!-- Status Tray Network strings -->
<message name="IDS_ASH_STATUS_TRAY_NETWORK" desc="The label used in the network dialog header. [CHAR_LIMIT=18]">
Network
@ -2479,54 +2534,6 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH" desc="The message shown on a bubble when caps lock is turned on.">
Press Search or Shift to cancel.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_FULL" desc="The label in the tray dialog to indicate that the battery is full.">
Battery full
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT" desc="The label in the tray dialog to show the remaining battery power as a percent.">
<ph name="percentage">{0,number,percent}<ex>56%</ex></ph> remaining
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL" desc="The label in the tray dialog to show a time estimate until the battery is fully charged.">
<ph name="time">$1<ex>2h 53m</ex></ph> until full
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING" desc="The label in the tray dialog indicating that the time to charge or discharge the battery is being calculated.">
Calculating...
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT" desc="The label in the tray bubble settings row to show a time estimate until the battery is empty.">
<ph name="time">$1<ex>2:53</ex></ph> left
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT" desc="The label in the tray bubble settings row to show a time estimate until the battery is fully charged.">
<ph name="time">$1<ex>2:53</ex></ph> until full
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE" desc="The label in the tray dialog to indicate that battery charging is unreliable.">
Low-power charger
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE" desc="The message used by accessibility to show battery is fully charged.">
Battery is full.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ACCESSIBLE" desc="The message used by accessibility to show battery is discharging.">
Battery at <ph name="percentage">$1<ex>56</ex></ph> percent.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_CHARGING_ACCESSIBLE" desc="The message used by accessibility to show battery is being charged.">
Battery at <ph name="percentage">$1<ex>56</ex></ph>% and charging.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_ACCESSIBLE" desc="The message used by accessibility to show battery is calculating its time in short message.">
Calculating battery time.
</message>
<message name= "IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_ACCESSIBLE" desc="The message used by accessibility to read remaining battery time until empty.">
<ph name="time_left">$1<ex>1 hour and 15 minutes</ex></ph> until battery is empty.
</message>
<message name= "IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_ACCESSIBLE" desc="The message used by accessibility to read the estimated time until full.">
<ph name="time_remaining">$1<ex>1 hour and 15 minutes</ex></ph> remaining until battery is fully charged.
</message>
<message name = "IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE" desc="The message used by accessibility to read battery time, which includes both non-zero hours and minutes.">
<ph name="hour">$1<ex> 1 hour</ex></ph> and <ph name="minute">$2<ex>15 minutes</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE_ACCESSIBLE" desc="The message used by accessibility to indicate that battery charging is unreliable.">
Plugged in to a low-power charger. Battery charging may not be reliable.
</message>
<message name="IDS_ASH_STATUS_TRAY_BATTERY_STATUS_SEPARATOR" desc="The separator symbol between battery percentage string and battery remaining time string">
''' - '''
</message>
<message name="IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT" desc="Tray bubble item shown to inform the user that the session length is limited.">
Session ends in <ph name="session_time_remaining">$1<ex>4 minutes 23 seconds</ex></ph>.
</message>

@ -0,0 +1 @@
762568325a0c906c91952643c4a7c197c06213a2

@ -0,0 +1 @@
002816934503fb9fad6a52a1f9803b5575f52c42

@ -0,0 +1 @@
6b519b6900281e527777d75183d677daa156210b

@ -0,0 +1 @@
f3606b063090620eaa1d3ec0b1d1739b43cb8ecb

@ -0,0 +1 @@
a49dc078917a132fb15c05fd1a2c974f2284fdc4

@ -0,0 +1 @@
a49dc078917a132fb15c05fd1a2c974f2284fdc4

@ -64,41 +64,53 @@ message_center::SystemNotificationWarningLevel GetWarningLevelMD(
std::unique_ptr<Notification> CreateNotification(
PowerNotificationController::NotificationState notification_state) {
notification_state = PowerNotificationController::NOTIFICATION_LOW_POWER;
const PowerStatus& status = *PowerStatus::Get();
const double battery_percentage = status.GetRoundedBatteryPercent();
std::u16string title =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_TITLE);
std::u16string message = base::i18n::MessageFormatter::FormatWithNumberedArgs(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_PERCENT),
static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0);
battery_percentage / 100.0);
const absl::optional<base::TimeDelta> time =
status.IsBatteryCharging() ? status.GetBatteryTimeToFull()
: status.GetBatteryTimeToEmpty();
std::u16string time_message;
if (status.IsUsbChargerConnected()) {
time_message = l10n_util::GetStringUTF16(
title =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_TITLE);
message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
} else if (time && power_utils::ShouldDisplayBatteryTime(*time) &&
!status.IsBatteryDischargingOnLinePower()) {
std::u16string duration = ui::TimeFormat::Simple(
ui::TimeFormat::FORMAT_DURATION, ui::TimeFormat::LENGTH_LONG, *time);
if (status.IsBatteryCharging()) {
std::u16string duration;
if (!TimeDurationFormat(*time, base::DURATION_WIDTH_NARROW, &duration))
LOG(ERROR) << "Failed to format duration " << *time;
time_message = l10n_util::GetStringFUTF16(
title =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_TITLE);
message = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, duration);
} 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, *time);
title = notification_state ==
PowerNotificationController::NOTIFICATION_CRITICAL
? l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CRITICAL_BATTERY_TITLE)
: l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_LOW_BATTERY_TITLE);
message = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_LOW_BATTERY_MESSAGE, duration,
base::NumberToString16(battery_percentage));
}
}
if (!time_message.empty())
message = message + u"\n" + time_message;
std::unique_ptr<Notification> notification = ash::CreateSystemNotification(
message_center::NOTIFICATION_TYPE_SIMPLE,
BatteryNotification::kNotificationId, std::u16string(), message,
std::u16string(), GURL(),
BatteryNotification::kNotificationId, title, message, std::u16string(),
GURL(),
message_center::NotifierId(message_center::NotifierType::SYSTEM_COMPONENT,
kNotifierBattery,
NotificationCatalogName::kBatteryNotifier),