Commit f73dbd74 authored by Max Li's avatar Max Li Committed by Commit Bot

Indicate device offline status in the multidevice setup dropdown

Offline devices are shown with grey text and "(offline)" next to their name.

Bug: 923594
Change-Id: Id66370c73c42dd16fa106b5c6a75ea6159533297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918293
Commit-Queue: Max Li <themaxli@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarJosh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716469}
parent e40c8591
...@@ -171,6 +171,10 @@ ...@@ -171,6 +171,10 @@
<message name="IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER" desc="Label appearing over a list of Android phones which this Chromebook can connect to."> <message name="IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER" desc="Label appearing over a list of Android phones which this Chromebook can connect to.">
Select a device Select a device
</message> </message>
<message name="IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_OFFLINE_DEVICE_OPTION" desc="Device name appearing in the list of Android phones indicating
the device is offline.">
<ph name="DEVICE_NAME">$1<ex>Pixel 2</ex></ph> (offline)
</message>
<message name="IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FEATURE_LIST_HEADER" desc="Header to introduce a list of the features that the user is agreeing to in the multi-device setup."> <message name="IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FEATURE_LIST_HEADER" desc="Header to introduce a list of the features that the user is agreeing to in the multi-device setup.">
When you connect your devices, you agree that your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> can: When you connect your devices, you agree that your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> can:
</message> </message>
......
...@@ -48,6 +48,8 @@ constexpr LocalizedString kLocalizedStringsWithoutPlaceholders[] = { ...@@ -48,6 +48,8 @@ constexpr LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER}, IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER},
{"startSetupPageSingleDeviceHeader", {"startSetupPageSingleDeviceHeader",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER}, IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER},
{"startSetupPageOfflineDeviceOption",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_OFFLINE_DEVICE_OPTION},
{"startSetupPageFeatureListInstallApps", {"startSetupPageFeatureListInstallApps",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION}, IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION},
{"startSetupPageFeatureListAddFeatures", {"startSetupPageFeatureListAddFeatures",
......
...@@ -45,7 +45,7 @@ cr.define('multidevice_setup', () => { ...@@ -45,7 +45,7 @@ cr.define('multidevice_setup', () => {
{ {
remoteDevice: {deviceName: 'Nexus 5', deviceId: '12345'}, remoteDevice: {deviceName: 'Nexus 5', deviceId: '12345'},
connectivityStatus: connectivityStatus:
chromeos.deviceSync.mojom.ConnectivityStatus.kOnline chromeos.deviceSync.mojom.ConnectivityStatus.kUnknownConnectivity
}, },
]; ];
...@@ -80,9 +80,8 @@ cr.define('multidevice_setup', () => { ...@@ -80,9 +80,8 @@ cr.define('multidevice_setup', () => {
}); });
test( test(
'selectedDeviceId changes when dropdown options are selected', 'selectedDeviceId changes when dropdown options are selected', () => {
() => { selectOptionByTextContent('Nexus 6P (offline)');
selectOptionByTextContent('Nexus 6P');
assertEquals(startSetupPageElement.selectedDeviceId, 'PpPpPp'); assertEquals(startSetupPageElement.selectedDeviceId, 'PpPpPp');
selectOptionByTextContent('Nexus 5'); selectOptionByTextContent('Nexus 5');
assertEquals(startSetupPageElement.selectedDeviceId, '12345'); assertEquals(startSetupPageElement.selectedDeviceId, '12345');
......
...@@ -63,7 +63,8 @@ struct FindEligibleDevicesResponse { ...@@ -63,7 +63,8 @@ struct FindEligibleDevicesResponse {
enum ConnectivityStatus { enum ConnectivityStatus {
kOnline, kOnline,
kOffline kOffline,
kUnknownConnectivity
}; };
struct DeviceActivityStatus { struct DeviceActivityStatus {
......
...@@ -14,7 +14,8 @@ chromeos::device_sync::mojom::ConnectivityStatus EnumTraits< ...@@ -14,7 +14,8 @@ chromeos::device_sync::mojom::ConnectivityStatus EnumTraits<
case cryptauthv2::ConnectivityStatus::ONLINE: case cryptauthv2::ConnectivityStatus::ONLINE:
return chromeos::device_sync::mojom::ConnectivityStatus::kOnline; return chromeos::device_sync::mojom::ConnectivityStatus::kOnline;
case cryptauthv2::ConnectivityStatus::UNKNOWN_CONNECTIVITY: case cryptauthv2::ConnectivityStatus::UNKNOWN_CONNECTIVITY:
FALLTHROUGH; return chromeos::device_sync::mojom::ConnectivityStatus::
kUnknownConnectivity;
case cryptauthv2::ConnectivityStatus::OFFLINE: case cryptauthv2::ConnectivityStatus::OFFLINE:
return chromeos::device_sync::mojom::ConnectivityStatus::kOffline; return chromeos::device_sync::mojom::ConnectivityStatus::kOffline;
case cryptauthv2::ConnectivityStatus:: case cryptauthv2::ConnectivityStatus::
...@@ -22,7 +23,8 @@ chromeos::device_sync::mojom::ConnectivityStatus EnumTraits< ...@@ -22,7 +23,8 @@ chromeos::device_sync::mojom::ConnectivityStatus EnumTraits<
case cryptauthv2::ConnectivityStatus:: case cryptauthv2::ConnectivityStatus::
ConnectivityStatus_INT_MAX_SENTINEL_DO_NOT_USE_: ConnectivityStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
NOTREACHED(); NOTREACHED();
return chromeos::device_sync::mojom::ConnectivityStatus::kOffline; return chromeos::device_sync::mojom::ConnectivityStatus::
kUnknownConnectivity;
} }
} }
...@@ -37,6 +39,9 @@ bool EnumTraits<chromeos::device_sync::mojom::ConnectivityStatus, ...@@ -37,6 +39,9 @@ bool EnumTraits<chromeos::device_sync::mojom::ConnectivityStatus,
case chromeos::device_sync::mojom::ConnectivityStatus::kOffline: case chromeos::device_sync::mojom::ConnectivityStatus::kOffline:
*out = cryptauthv2::ConnectivityStatus::OFFLINE; *out = cryptauthv2::ConnectivityStatus::OFFLINE;
return true; return true;
case chromeos::device_sync::mojom::ConnectivityStatus::kUnknownConnectivity:
*out = cryptauthv2::ConnectivityStatus::UNKNOWN_CONNECTIVITY;
return true;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
margin-top: 16px; margin-top: 16px;
} }
.offline-device-name {
color: var(--google-grey-600);
}
#page-icon-container { #page-icon-container {
@apply --layout-horizontal; @apply --layout-horizontal;
@apply --layout-center-justified; @apply --layout-center-justified;
...@@ -101,8 +105,10 @@ ...@@ -101,8 +105,10 @@
class="md-select" class="md-select"
on-change="onDeviceDropdownSelectionChanged_"> on-change="onDeviceDropdownSelectionChanged_">
<template is="dom-repeat" items="[[devices]]"> <template is="dom-repeat" items="[[devices]]">
<option value$="[[item.remoteDevice.deviceId]]"> <option
[[item.remoteDevice.deviceName]] class$="[[getDeviceOptionClass_(item.connectivityStatus)]]"
value$="[[item.remoteDevice.deviceId]]">
[[getDeviceNameWithConnectivityStatus_(item)]]
</option> </option>
</template> </template>
</select> </select>
......
...@@ -129,6 +129,32 @@ Polymer({ ...@@ -129,6 +129,32 @@ Polymer({
return devices[0] ? this.devices[0].remoteDevice.deviceName : ''; return devices[0] ? this.devices[0].remoteDevice.deviceName : '';
}, },
/**
* @param {!chromeos.deviceSync.mojom.ConnectivityStatus} connectivityStatus
* @return {string} The classes to bind to the device name option.
* @private
*/
getDeviceOptionClass_: function(connectivityStatus) {
return connectivityStatus ==
chromeos.deviceSync.mojom.ConnectivityStatus.kOffline ?
'offline-device-name' :
'';
},
/**
* @param {!chromeos.multideviceSetup.mojom.HostDevice} device
* @return {string} Name of the device, with connectivity status information.
* @private
*/
getDeviceNameWithConnectivityStatus_: function(device) {
return device.connectivityStatus ==
chromeos.deviceSync.mojom.ConnectivityStatus.kOffline ?
this.i18n(
'startSetupPageOfflineDeviceOption',
device.remoteDevice.deviceName) :
device.remoteDevice.deviceName;
},
/** @private */ /** @private */
devicesChanged_: function() { devicesChanged_: function() {
if (this.devices.length > 0) { if (this.devices.length > 0) {
......
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