[CrOS Bluetooth] Fix Hid warning dialog string
This CL updates Hid Warning Dialog strings to match the mocks. It makes changes from the previous implementation that was reverted to use BulletedListView instead of using ASCII code for new line and bullets. Screenshot: https://screenshot.googleplex.com/f4vzuvR9agfcd3D.png https://screenshot.googleplex.com/A6aHLJXnxeHXc6e.png https://screenshot.googleplex.com/4x8h2hCkHcKt3y6.png Fixed: b/329396584, b/b/323890629 Test: Deployed to DUT, and ran CQ Change-Id: I87a5a593a8c911a293ca2da1183ed27e7dc64faf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5373925 Reviewed-by: James Cook <jamescook@chromium.org> Reviewed-by: Jason Zhang <jiajunz@google.com> Reviewed-by: Chad Duffin <chadduffin@chromium.org> Commit-Queue: Theo Johnson-kanu <tjohnsonkanu@google.com> Cr-Commit-Position: refs/heads/main@{#1274368}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
96d1cb0618
commit
bf579eebf2
ash
ash_strings.grd
ash_strings_grd
IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_MULTIPLE_DEVICES.png.sha1IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_ONE_DEVICE.png.sha1IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_TWO_DEVICES.png.sha1
constants
system
bluetooth
hid_preserving_controller
@ -3292,13 +3292,13 @@ Some features are limited to increase battery life.
|
||||
Keep on
|
||||
</message>
|
||||
<message name="IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_ONE_DEVICE" desc="Bluetooth pairing message shown to indicate a Bluetooth device will disconnect when Bluetooth is turned off.">
|
||||
When you turn off Bluetooth, "<ph name="DEVICE_NAME">$1<ex>Dell RGB Keyboard</ex></ph>" will disconnect from your Chromebook.
|
||||
When you turn off Bluetooth, this external device will disconnect from your <ph name="DEVICE_TYPE">$1<ex>Chromebox</ex></ph>:
|
||||
</message>
|
||||
<message name="IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_TWO_DEVICES" desc="Bluetooth pairing message shown to indicate that two Bluetooth devices will disconnect when Bluetooth is turned off.">
|
||||
When you turn off Bluetooth, "<ph name="DEVICE_NAME_1">$1<ex>Logitech SmartMouse</ex></ph>" and "<ph name="DEVICE_NAME_2">$2<ex>Dell RGB Keyboard</ex></ph>" will disconnect from your Chromebook.
|
||||
When you turn off Bluetooth, these external devices will disconnect from your <ph name="DEVICE_TYPE">$1<ex>Chromebox</ex></ph>:
|
||||
</message>
|
||||
<message name="IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_MULTIPLE_DEVICES" desc="Bluetooth pairing message shown to indicate that multiple Bluetooth devices will disconnect when Bluetooth is turned off.">
|
||||
When you turn off Bluetooth, "<ph name="DEVICE_NAME_1">$1<ex>Logitech SmartMouse</ex></ph>", "<ph name="DEVICE_NAME_2">$2<ex>Dell RGB Keyboard</ex></ph>" and <ph name="DEVICE_COUNT">$3<ex>3</ex></ph> other devices will disconnect from your Chromebook.
|
||||
When you turn off Bluetooth, <ph name="DEVICE_COUNT">$1<ex>2</ex></ph> external devices will disconnect from your <ph name="DEVICE_TYPE">$2<ex>Chromebox</ex></ph>, including:
|
||||
</message>
|
||||
|
||||
<!-- Ash multi-user warning dialog -->
|
||||
|
@ -1 +1 @@
|
||||
533b9663aa5f0e762b7d5d669352fadd6e3554c8
|
||||
a01afd1a94bdf20c0410c8d55d60d894d4669f02
|
@ -1 +1 @@
|
||||
533b9663aa5f0e762b7d5d669352fadd6e3554c8
|
||||
639cd38d8617e79435f3c3fab7c0eac8ccc1ca98
|
@ -1 +1 @@
|
||||
533b9663aa5f0e762b7d5d669352fadd6e3554c8
|
||||
2fe6e9fae2f5dffe4ad05c517d0ffd64c356aca7
|
@ -14,30 +14,35 @@
|
||||
#include "chromeos/constants/devicetype.h"
|
||||
|
||||
namespace ash {
|
||||
namespace {
|
||||
constexpr char kDefaultDeviceTypeName[] = "Chromebook";
|
||||
} // namespace
|
||||
|
||||
std::string GetDeviceBluetoothName(const std::string& bluetooth_address) {
|
||||
const char* name = "Chromebook";
|
||||
switch (chromeos::GetDeviceType()) {
|
||||
case chromeos::DeviceType::kChromebase:
|
||||
name = "Chromebase";
|
||||
break;
|
||||
case chromeos::DeviceType::kChromebit:
|
||||
name = "Chromebit";
|
||||
break;
|
||||
case chromeos::DeviceType::kChromebook:
|
||||
name = "Chromebook";
|
||||
break;
|
||||
case chromeos::DeviceType::kChromebox:
|
||||
name = "Chromebox";
|
||||
break;
|
||||
case chromeos::DeviceType::kUnknown:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const std::string device_name = DeviceTypeToString(chromeos::GetDeviceType());
|
||||
|
||||
// Take the lower 2 bytes of hashed |bluetooth_address| and combine it with
|
||||
// the device type to create a more identifiable device name.
|
||||
return base::StringPrintf("%s_%04X", name,
|
||||
base::PersistentHash(bluetooth_address) & 0xFFFF);
|
||||
return base::StringPrintf(
|
||||
"%s_%04X",
|
||||
device_name.empty() ? kDefaultDeviceTypeName : device_name.c_str(),
|
||||
base::PersistentHash(bluetooth_address) & 0xFFFF);
|
||||
}
|
||||
|
||||
std::string DeviceTypeToString(chromeos::DeviceType device_type) {
|
||||
switch (device_type) {
|
||||
case chromeos::DeviceType::kChromebase:
|
||||
return "Chromebase";
|
||||
case chromeos::DeviceType::kChromebit:
|
||||
return "Chromebit";
|
||||
case chromeos::DeviceType::kChromebook:
|
||||
return "Chromebook";
|
||||
case chromeos::DeviceType::kChromebox:
|
||||
return "Chromebox";
|
||||
case chromeos::DeviceType::kUnknown:
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool IsGoogleBrandedDevice() {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "chromeos/constants/devicetype.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
@ -17,6 +18,10 @@ namespace ash {
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS)
|
||||
std::string GetDeviceBluetoothName(const std::string& bluetooth_address);
|
||||
|
||||
// Returns the name of the provided Chrome device type.
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS)
|
||||
std::string DeviceTypeToString(chromeos::DeviceType device_type);
|
||||
|
||||
// Returns true if the device is Google branded.
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) bool IsGoogleBrandedDevice();
|
||||
|
||||
|
@ -4,17 +4,27 @@
|
||||
|
||||
#include "ash/system/bluetooth/hid_preserving_controller/disable_bluetooth_dialog_controller_impl.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ash/accessibility/accessibility_controller.h"
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/constants/devicetype.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/bluetooth/hid_preserving_controller/disable_bluetooth_dialog_controller.h"
|
||||
#include "chromeos/constants/devicetype.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/views/controls/bulleted_label_list/bulleted_label_list_view.h"
|
||||
#include "ui/views/controls/image_view.h"
|
||||
#include "ui/views/layout/layout_provider.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
constexpr char kUnknownDeviceTypeName[] = "ChromeOS device";
|
||||
} // namespace
|
||||
|
||||
DisableBluetoothDialogControllerImpl::DisableBluetoothDialogControllerImpl() {
|
||||
CHECK(features::IsBluetoothDisconnectWarningEnabled());
|
||||
}
|
||||
@ -34,21 +44,25 @@ void DisableBluetoothDialogControllerImpl::ShowDialog(
|
||||
DCHECK_EQ(dialog_widget_, nullptr);
|
||||
CHECK(!devices.empty());
|
||||
|
||||
std::string device_type = DeviceTypeToString(chromeos::GetDeviceType());
|
||||
if (device_type.empty()) {
|
||||
device_type = kUnknownDeviceTypeName;
|
||||
}
|
||||
|
||||
std::u16string dialog_description;
|
||||
|
||||
if (devices.size() == 1) {
|
||||
dialog_description = l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_ONE_DEVICE,
|
||||
base::UTF8ToUTF16(devices[0]));
|
||||
base::UTF8ToUTF16(device_type));
|
||||
} else if (devices.size() == 2) {
|
||||
dialog_description = l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_TWO_DEVICES,
|
||||
base::UTF8ToUTF16(devices[0]), base::UTF8ToUTF16(devices[1]));
|
||||
base::UTF8ToUTF16(device_type));
|
||||
} else {
|
||||
dialog_description = l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_DISCONNECT_BLUETOOTH_WARNING_DIALOG_DESCRIPTION_MULTIPLE_DEVICES,
|
||||
base::UTF8ToUTF16(devices[0]), base::UTF8ToUTF16(devices[1]),
|
||||
base::NumberToString16(devices.size() - 2));
|
||||
base::NumberToString16(devices.size()), base::UTF8ToUTF16(device_type));
|
||||
}
|
||||
|
||||
auto dialog = views::Builder<SystemDialogDelegateView>()
|
||||
@ -67,8 +81,20 @@ void DisableBluetoothDialogControllerImpl::ShowDialog(
|
||||
weak_ptr_factory_.GetWeakPtr()))
|
||||
.Build();
|
||||
|
||||
// TODO(b/330161794): Fix bulleted list text color to match mocks.
|
||||
std::unique_ptr<views::BulletedLabelListView> list_view =
|
||||
std::make_unique<views::BulletedLabelListView>();
|
||||
|
||||
int count = std::min((int)devices.size(), 3);
|
||||
// Intentionally limit the number of devices shown in the UI.
|
||||
for (int i = 0; i < count; i++) {
|
||||
list_view->AddLabel(base::UTF8ToUTF16(devices[i]));
|
||||
}
|
||||
|
||||
dialog->SetModalType(ui::MODAL_TYPE_SYSTEM);
|
||||
dialog->SetShowCloseButton(false);
|
||||
dialog->SetMiddleContentView(std::move(list_view));
|
||||
dialog->SetMiddleContentAlignment(views::LayoutAlignment::kStart);
|
||||
|
||||
views::Widget::InitParams params;
|
||||
params.context = Shell::GetPrimaryRootWindow();
|
||||
|
Reference in New Issue
Block a user