Commit 3252db34 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Improve Bluetooth button labels.

This CL replaces UI strings of Bluetooth feature pod button in
UnifiedSystemTray. It also shows the connected device name, and if there
are multiple connected devices, it shows the number.

TEST=manual
BUG=813499

Change-Id: Ic4d840586f2ff490a9c72b19c6679bb3c5c674a6
Reviewed-on: https://chromium-review.googlesource.com/1102225Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567696}
parent cc7cca80
......@@ -320,6 +320,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED" desc="The label used in the tray popup to notify that bluetooth is disabled.">
Bluetooth disabled
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED_SHORT" desc="The short label used in the tray popup to notify that bluetooth is enabled.">
On
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED_SHORT" desc="The short label used in the tray popup to notify that bluetooth is disabled.">
Off
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING" desc="The label used in the tray popup to show bluetooth is discovering devices.">
Scanning for devices...
</message>
......@@ -332,6 +338,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_SETTINGS" desc="The label used in the tray pop up to open Bluetooth setting page.">
Bluetooth settings
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DEVICE_CONNECTED_LABEL" desc="The sub-header label to notify that one bluetooth device is connected.">
Connected
</message>
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_MULTIPLE_DEVICES_CONNECTED_LABEL" desc="The header label to notify that multiple bluetooth devices are connected.">
Devices
</message>
<message name="IDS_ASH_STATUS_TRAY_UPDATE" desc="The label used in the tray popup to notify that the user should restart to get system updates.">
Restart to update
......
......@@ -11,6 +11,7 @@
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "base/i18n/number_formatting.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
......@@ -57,9 +58,36 @@ void BluetoothFeaturePodController::UpdateButton() {
bool is_enabled =
Shell::Get()->tray_bluetooth_helper()->GetBluetoothEnabled();
button_->SetToggled(is_enabled);
button_->SetLabel(l10n_util::GetStringUTF16(
is_enabled ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED
: IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED));
if (!is_enabled) {
button_->SetLabel(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH));
button_->SetSubLabel(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED_SHORT));
return;
}
BluetoothDeviceList connected_devices;
for (const auto& device :
Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices()) {
if (device.connected)
connected_devices.push_back(device);
if (connected_devices.size() > 1)
break;
}
if (connected_devices.size() > 1) {
button_->SetLabel(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_BLUETOOTH_MULTIPLE_DEVICES_CONNECTED_LABEL));
button_->SetSubLabel(base::FormatNumber(connected_devices.size()));
} else if (connected_devices.size() == 1) {
button_->SetLabel(connected_devices.back().display_name);
button_->SetSubLabel(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_BLUETOOTH_DEVICE_CONNECTED_LABEL));
} else {
button_->SetLabel(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH));
button_->SetSubLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED_SHORT));
}
}
void BluetoothFeaturePodController::OnBluetoothRefresh() {
......
......@@ -285,7 +285,7 @@
"messages": [23520],
},
"ash/components/ash_components_strings.grd": {
"messages": [23950],
"messages": [24050],
},
"ash/components/resources/ash_components_resources.grd": {
"structures": [24250],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment