Skip to content

Commit

Permalink
CrOS Settings: Update strings for Device Power subpage
Browse files Browse the repository at this point in the history
This CL updates the strings for the Device Power subpage when the
feature OsSettingsRevampWayfinding is enabled. After the update, the `When idle` row only shows up when battery status is not present. The minimum height of the row is updated from 48px to 64px.

Feature enabled: https://screenshot.googleplex.com/7LwUPBjm2EKrqPf
Feature disabled: https://screenshot.googleplex.com/BWPf2sFweD4JTXH

Bug: b/293896466
Change-Id: I2ef1589595072f63aa02cc77b24a1a19753c616b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4811036
Commit-Queue: Connie Xu <conniekxu@chromium.org>
Reviewed-by: Wes Okuhara <wesokuhara@google.com>
Cr-Commit-Position: refs/heads/main@{#1188548}
  • Loading branch information
conniekxu authored and Chromium LUCI CQ committed Aug 25, 2023
1 parent ebb9a24 commit 476153f
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 33 deletions.
6 changes: 6 additions & 0 deletions chrome/app/os_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -4896,12 +4896,18 @@ Press an assigned switch or key to remove assignment.
<message name="IDS_SETTINGS_POWER_IDLE_WHILE_CHARGING_LABEL" desc="In Device Settings > Power, label for behavior when device is idle.">
While charging
</message>
<message name="IDS_OS_SETTINGS_REVAMP_POWER_INACTIVE_WHILE_PLUGGED_IN_LABEL" desc="In Device Settings > Power, label for behavior when device is inactive and plugged in.">
While inactive and plugged in
</message>
<message name="IDS_SETTINGS_POWER_IDLE_WHILE_CHARGING_ARIA_LABEL" desc="In Device Settings > Power, aria label for behavior when device is idle.">
Idle action while charging
</message>
<message name="IDS_SETTINGS_POWER_IDLE_WHILE_ON_BATTERY_LABEL" desc="In Device Settings > Power, label for behavior when device is idle.">
While on battery
</message>
<message name="IDS_OS_SETTINGS_REVAMP_POWER_INACTIVE_WHILE_ON_BATTERY_LABEL" desc="In Device Settings > Power, label for behavior when device is inactive and on battery.">
While inactive and on battery
</message>
<message name="IDS_SETTINGS_POWER_IDLE_WHILE_ON_BATTERY_ARIA_LABEL" desc="In Device Settings > Power, aria label for behavior when device is idle.">
Idle action while on battery
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f94333382244aeb0a11b971fc5fffcbf9eddf9bf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
185c1045b9a308b767f7fd7139eb57f5b23d9805
79 changes: 57 additions & 22 deletions chrome/browser/resources/ash/settings/device_page/power.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
cr-policy-indicator {
padding-inline-end: 8px;
}
.dropdown-row {
--cr-section-min-height: 64px;
}
</style>
<div id="powerSourceRow" class="cr-row first"
hidden$="[[!batteryStatus_.present]]">
Expand Down Expand Up @@ -37,6 +40,7 @@
</div>

<settings-toggle-button id="batterySaverToggle"
class$="[[getClassForRow_(batteryStatus_.present, 'batterySaver')]]"
hidden$="[[batterySaverHidden_]]"
pref="{{prefs.power.cros_battery_saver_active}}"
label="$i18n{powerBatterySaverLabel}"
Expand All @@ -45,23 +49,51 @@
deep-link-focus-id$="[[Setting.kBatterySaver]]">
</settings-toggle-button>

<settings-toggle-button hidden$="[[!adaptiveChargingEnabled_]]"
class$="[[getClassForRow_(batteryStatus_.present, 'adaptiveCharging')]]"
id="adaptiveChargingToggle"
pref="[[adaptiveChargingPref_]]"
label="$i18n{powerAdaptiveChargingLabel}"
sub-label="$i18n{powerAdaptiveChargingSubtext}"
learn-more-url="$i18n{powerAdaptiveChargingLearnMoreUrl}"
on-settings-boolean-control-change="onAdaptiveChargingToggleChange_"
deep-link-focus-id$="[[Setting.kAdaptiveCharging]]"
no-set-pref>
<settings-toggle-button id="adaptiveChargingToggle"
class$="[[getClassForRow_(batteryStatus_.present, 'adaptiveCharging')]]"
hidden$="[[!adaptiveChargingEnabled_]]"
pref="[[adaptiveChargingPref_]]"
label="$i18n{powerAdaptiveChargingLabel}"
sub-label="$i18n{powerAdaptiveChargingSubtext}"
learn-more-url="$i18n{powerAdaptiveChargingLearnMoreUrl}"
on-settings-boolean-control-change="onAdaptiveChargingToggleChange_"
deep-link-focus-id$="[[Setting.kAdaptiveCharging]]"
no-set-pref>
</settings-toggle-button>

<div class$="[[getClassForRow_(batteryStatus_.present, 'idle')]]">
<div id="powerIdleLabel" class="flex" aria-label="true">
$i18n{powerIdleLabel}
<template is="dom-if" if="[[!isRevampWayfindingEnabled_]]">
<div class$="[[getClassForRow_(batteryStatus_.present, 'idle')]]">
<div id="powerIdleLabel" class="flex" aria-label="true">
$i18n{powerIdleLabel}
</div>
<template is="dom-if" if="[[!batteryStatus_.present]]" restamp>
<template is="dom-if" if="[[acIdleManaged_]]" restamp>
<cr-policy-indicator id="noBatteryAcIdleManagedIndicator"
indicator-type="devicePolicy"
icon-aria-label="$i18n{powerIdleWhileChargingAriaLabel}">
</cr-policy-indicator>
</template>
<select id="noBatteryAcIdleSelect" class="md-select"
on-change="onAcIdleSelectChange_"
disabled="[[shouldAcIdleSelectBeDisabled_]]"
aria-label="$i18n{powerIdleWhileChargingAriaLabel}"
deep-link-focus-id$="[[Setting.kPowerIdleBehaviorWhileCharging]]">
<template is="dom-repeat" items="[[acIdleOptions_]]">
<option value="[[item.value]]" selected="[[item.selected]]">
[[item.name]]
</option>
</template>
</select>
</template>
</div>
<template is="dom-if" if="[[!batteryStatus_.present]]" restamp>
</template>

<template is="dom-if" if="[[isRevampWayfindingEnabled_]]">
<div class$="[[getClassForRow_(batteryStatus_.present, 'idle')]]"
hidden="[[batteryStatus_.present]]">
<div id="powerIdleLabel" class="flex" aria-label="true">
$i18n{powerIdleLabel}
</div>
<template is="dom-if" if="[[acIdleManaged_]]" restamp>
<cr-policy-indicator id="noBatteryAcIdleManagedIndicator"
indicator-type="devicePolicy"
Expand All @@ -79,13 +111,14 @@
</option>
</template>
</select>
</template>
</div>
</div>
</template>

<template is="dom-if" if="[[batteryStatus_.present]]" restamp>
<div id="acIdleSettingBox" class="cr-row indented first">
<div id="acIdleSettingBox"
class$="[[getClassForRow_(batteryStatus_.present, 'acIdle')]]">
<div class="flex" aria-hidden="true">
$i18n{powerIdleWhileChargingLabel}
$i18n{powerInactiveWhilePluggedInLabel}
</div>
<template is="dom-if" if="[[acIdleManaged_]]" restamp>
<cr-policy-indicator id="acIdleManagedIndicator"
Expand All @@ -106,9 +139,10 @@
</select>
</div>

<div id="batteryIdleSettingBox" class="cr-row indented">
<div id="batteryIdleSettingBox"
class$="[[getClassForRow_(batteryStatus_.present, 'batteryIdle')]]">
<div class="flex" aria-hidden="true">
$i18n{powerIdleWhileOnBatteryLabel}
$i18n{powerInactiveWhileOnBatteryLabel}
</div>
<template is="dom-if" if="[[batteryIdleManaged_]]" restamp>
<cr-policy-indicator id="batteryIdleManagedIndicator"
Expand All @@ -130,8 +164,9 @@
</div>
</template>

<settings-toggle-button hidden$="[[!hasLid_]]" id="lidClosedToggle"
pref="[[lidClosedPref_]]" label="[[lidClosedLabel_]]"
<settings-toggle-button id="lidClosedToggle"
class$="[[getClassForRow_(batteryStatus_.present, 'lidClosed')]]"
hidden$="[[!hasLid_]]" pref="[[lidClosedPref_]]" label="[[lidClosedLabel_]]"
on-settings-boolean-control-change="onLidClosedToggleChange_" no-set-pref
deep-link-focus-id$="[[Setting.kSleepWhenLaptopLidClosed]]">
</settings-toggle-button>
53 changes: 47 additions & 6 deletions chrome/browser/resources/ash/settings/device_page/power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {assertNotReached} from 'chrome://resources/js/assert_ts.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.js';
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {isRevampWayfindingEnabled} from '../common/load_time_booleans.js';
import {DeepLinkingMixin} from '../deep_linking_mixin.js';
import {recordSettingChange} from '../metrics_recorder.js';
import {Setting} from '../mojom-webui/setting.mojom-webui.js';
Expand Down Expand Up @@ -179,6 +180,13 @@ class SettingsPowerElement extends SettingsPowerElementBase {
'computeBatterySaverToggleDisabled_(powerSources_, lowPowerCharger_)',
},

isRevampWayfindingEnabled_: {
type: Boolean,
value: () => {
return isRevampWayfindingEnabled();
},
},

/**
* Used by DeepLinkingMixin to focus this page's deep links.
*/
Expand All @@ -204,9 +212,11 @@ class SettingsPowerElement extends SettingsPowerElementBase {
private adaptiveChargingPref_: chrome.settingsPrivate.PrefObject<boolean>;
private batteryIdleManaged_: boolean;
private batteryIdleOptions_: IdleOption[];
private batterySaverHidden_: boolean;
private batteryStatus_: BatteryStatus|undefined;
private browserProxy_: DevicePageBrowserProxy;
private hasLid_: boolean;
private isRevampWayfindingEnabled_: boolean;
private lidClosedLabel_: string;
private lidClosedPref_: chrome.settingsPrivate.PrefObject<boolean>;
private lowPowerCharger_: boolean;
Expand Down Expand Up @@ -499,22 +509,53 @@ class SettingsPowerElement extends SettingsPowerElementBase {
* @return the class for the given row
*/
private getClassForRow_(batteryPresent: boolean, element: string): string {
let c = 'cr-row';
const classes = ['cr-row'];

switch (element) {
case 'adaptiveCharging':
case 'batterySaver':
if (!batteryPresent) {
c += ' first';
classes.push('first');
}
break;
case 'adaptiveCharging':
if (!batteryPresent && this.batterySaverHidden_) {
classes.push('first');
}
break;
case 'idle':
if (!batteryPresent && !this.adaptiveChargingEnabled_) {
c += ' first';
if (!batteryPresent && this.batterySaverHidden_ &&
!this.adaptiveChargingEnabled_) {
classes.push('first');
}
break;
case 'acIdle':
if (!batteryPresent && this.batterySaverHidden_ &&
!this.adaptiveChargingEnabled_) {
classes.push('first');
}
if (this.isRevampWayfindingEnabled_) {
classes.push('dropdown-row');
} else {
classes.push('indented');
}
break;
case 'batteryIdle':
if (this.isRevampWayfindingEnabled_) {
classes.push('dropdown-row');
} else {
classes.push('indented');
}
break;
case 'lidClosed':
if (this.isRevampWayfindingEnabled_) {
classes.push('dropdown-row');
} else {
classes.push('first');
}
break;
}

return c;
return classes.join(' ');
}

private isEqual_(lhs: string, rhs: string): boolean {
Expand Down
17 changes: 12 additions & 5 deletions chrome/browser/ui/webui/settings/ash/device_section.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,10 @@ void AddDeviceAudioStrings(content::WebUIDataSource* html_source) {
}

void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kPowerStrings[] = {
const bool kIsRevampEnabled =
ash::features::IsOsSettingsRevampWayfindingEnabled();

webui::LocalizedString kPowerStrings[] = {
{"calculatingPower", IDS_SETTINGS_POWER_SOURCE_CALCULATING},
{"powerAdaptiveChargingLabel",
IDS_SETTINGS_POWER_ADAPTIVE_CHARGING_LABEL},
Expand All @@ -1083,12 +1086,16 @@ void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
{"powerIdleLabel", IDS_SETTINGS_POWER_IDLE_LABEL},
{"powerIdleWhileChargingAriaLabel",
IDS_SETTINGS_POWER_IDLE_WHILE_CHARGING_ARIA_LABEL},
{"powerIdleWhileChargingLabel",
IDS_SETTINGS_POWER_IDLE_WHILE_CHARGING_LABEL},
{"powerInactiveWhilePluggedInLabel",
kIsRevampEnabled
? IDS_OS_SETTINGS_REVAMP_POWER_INACTIVE_WHILE_PLUGGED_IN_LABEL
: IDS_SETTINGS_POWER_IDLE_WHILE_CHARGING_LABEL},
{"powerIdleWhileOnBatteryAriaLabel",
IDS_SETTINGS_POWER_IDLE_WHILE_ON_BATTERY_ARIA_LABEL},
{"powerIdleWhileOnBatteryLabel",
IDS_SETTINGS_POWER_IDLE_WHILE_ON_BATTERY_LABEL},
{"powerInactiveWhileOnBatteryLabel",
kIsRevampEnabled
? IDS_OS_SETTINGS_REVAMP_POWER_INACTIVE_WHILE_ON_BATTERY_LABEL
: IDS_SETTINGS_POWER_IDLE_WHILE_ON_BATTERY_LABEL},
{"powerLidShutDownLabel", IDS_SETTINGS_POWER_LID_CLOSED_SHUT_DOWN_LABEL},
{"powerLidSignOutLabel", IDS_SETTINGS_POWER_LID_CLOSED_SIGN_OUT_LABEL},
{"powerLidSleepLabel", IDS_SETTINGS_POWER_LID_CLOSED_SLEEP_LABEL},
Expand Down

0 comments on commit 476153f

Please sign in to comment.