Commit 544e42ce authored by Sophie Yang's avatar Sophie Yang Committed by Commit Bot

[Switch Access] Create preference and slider for keyboard auto-scan time

Added a preference for the auto-scan speed specific to navigating
within the on-screen keyboard. Added a slider to the Switch Access
settings page to adjust this preference. The new preference and slider
are not yet connected to the behavior of Switch Access (so the auto-scan
time in the keyboard will not yet change to reflect the value of the
preference).

Test: With emulated Chrome OS on Linux and both the Switch Access and
text input command line flags enabled
(--enable-experimental-accessibility-switch-access and
--enable-experimental-accessibility-switch-access-text), manually
checked the slider for keyboard scanning speed in Switch Access
settings.

Screenshot of the change in chrome://settings:
https://screenshot.googleplex.com/yoxXvHa67F1.png
This change adds the slider for 'Keyboard Scanning Speed'
in the 'Auto-Scan' section.

Bug: 958081
Change-Id: I24550276bd6bfe360e9703ce677ab62c3a83b033
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728428Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Commit-Queue: Sophie Yang <sophyang@google.com>
Cr-Commit-Position: refs/heads/master@{#685306}
parent 46c6d4b1
......@@ -336,6 +336,9 @@ void AccessibilityControllerImpl::RegisterProfilePrefs(
registry->RegisterIntegerPref(
prefs::kAccessibilitySwitchAccessAutoScanSpeedMs,
kDefaultSwitchAccessAutoScanSpeed.InMilliseconds());
registry->RegisterIntegerPref(
prefs::kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs,
kDefaultSwitchAccessAutoScanSpeed.InMilliseconds());
registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled,
false);
registry->RegisterBooleanPref(
......
......@@ -109,6 +109,11 @@ const char kAccessibilitySwitchAccessAutoScanEnabled[] =
// scanning forward (when auto-scan is enabled).
const char kAccessibilitySwitchAccessAutoScanSpeedMs[] =
"settings.a11y.switch_access.auto_scan.speed_ms";
// An integer pref which determines time delay in ms before automatically
// scanning forward while navigating the keyboard (when auto-scan is
// enabled).
const char kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs[] =
"settings.a11y.switch_access.auto_scan.keyboard.speed_ms";
// A boolean pref which determines whether dictation is enabled.
const char kAccessibilityDictationEnabled[] = "settings.a11y.dictation";
// A boolean pref which determines whether the accessibility menu shows
......
......@@ -42,6 +42,8 @@ ASH_PUBLIC_EXPORT extern const char
ASH_PUBLIC_EXPORT extern const char kAccessibilitySwitchAccessPreviousSetting[];
ASH_PUBLIC_EXPORT extern const char kAccessibilitySwitchAccessAutoScanEnabled[];
ASH_PUBLIC_EXPORT extern const char kAccessibilitySwitchAccessAutoScanSpeedMs[];
ASH_PUBLIC_EXPORT extern const char
kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs[];
ASH_PUBLIC_EXPORT extern const char kAccessibilityDictationEnabled[];
ASH_PUBLIC_EXPORT extern const char kShouldAlwaysShowAccessibilityMenu[];
......
......@@ -307,6 +307,9 @@
<message name="IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_SPEED_LABEL" desc="Label for slider which sets the time interval for Switch Access to automatically scan to the next element.">
Scanning speed: <ph name="SPEED_WITH_UNITS">$1<ex>1.5s</ex></ph>
</message>
<message name="IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_KEYBOARD_SPEED_LABEL" desc="Label for slider which sets the time interval for Switch Access to automatically scan to the next element while navigating in the keyboard. Switch Access is an alternative input method designed for users with limited mobility, where the user has as little as one switch (for example, a button) to control the computer.">
Keyboard scanning speed
</message>
<message name="IDS_SETTINGS_DURATION_IN_SECONDS" desc="A duration in seconds. Should be short.">
<ph name="DURATION">$1<ex>1.5</ex></ph>s
</message>
......
......@@ -355,6 +355,10 @@ void Preferences::RegisterProfilePrefs(
ash::prefs::kAccessibilitySwitchAccessAutoScanSpeedMs,
ash::kDefaultSwitchAccessAutoScanSpeed.InMilliseconds(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF | PrefRegistry::PUBLIC);
registry->RegisterIntegerPref(
ash::prefs::kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs,
ash::kDefaultSwitchAccessAutoScanSpeed.InMilliseconds(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF | PrefRegistry::PUBLIC);
registry->RegisterBooleanPref(
ash::prefs::kShouldAlwaysShowAccessibilityMenu, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
......
......@@ -411,6 +411,9 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[ash::prefs::kAccessibilitySwitchAccessAutoScanSpeedMs] =
settings_api::PrefType::PREF_TYPE_NUMBER;
(*s_whitelist)
[ash::prefs::kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs] =
settings_api::PrefType::PREF_TYPE_NUMBER;
(*s_whitelist)[ash::prefs::kAccessibilityVirtualKeyboardEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[ash::prefs::kAccessibilityMonoAudioEnabled] =
......
......@@ -60,6 +60,7 @@ const char* const kPersistentPrefNames[] = {
ash::prefs::kAccessibilitySwitchAccessPreviousSetting,
ash::prefs::kAccessibilitySwitchAccessAutoScanEnabled,
ash::prefs::kAccessibilitySwitchAccessAutoScanSpeedMs,
ash::prefs::kAccessibilitySwitchAccessAutoScanKeyboardSpeedMs,
ash::prefs::kAccessibilityDictationEnabled,
ash::prefs::kDockedMagnifierEnabled,
ash::prefs::kDockedMagnifierScale,
......
......@@ -52,10 +52,12 @@ js_library("manage_a11y_page") {
js_library("switch_access_subpage") {
deps = [
"..:route",
"../prefs:prefs_behavior",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
externs_list = [ "$externs_path/settings_private.js" ]
}
js_library("tts_subpage") {
......
......@@ -6,6 +6,7 @@
<link rel="import" href="../controls/settings_slider.html">
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="settings-switch-access-subpage">
......@@ -61,7 +62,23 @@
</div>
<settings-slider id="scanSpeedSlider" aria-describedby="scanSpeed"
pref="{{prefs.switch_access.auto_scan.speed_ms}}"
ticks="[[autoScanSpeedValuesMs_]]"
ticks="[[autoScanSpeedRangeMs_]]"
min="[[minScanSpeedMs_]]"
max="[[maxScanSpeedMs_]]"
label-min="[[minScanSpeedLabelSec_]]"
label-max="[[maxScanSpeedLabelSec_]]">
</settings-dropdown-menu>
</div>
<div class="settings-box continuation list-item"
hidden$="[[!showKeyboardScanSettings_(
prefs.switch_access.auto_scan.enabled.value)]]">
<div class="start sub-item settings-box-text" id="keyboardScanSpeed">
$i18n{switchAccessAutoScanKeyboardSpeedLabel}
</div>
<settings-slider id="keyboardScanSpeedSlider"
aria-describedby="keyboardScanSpeed"
pref="{{prefs.switch_access.auto_scan.keyboard.speed_ms}}"
ticks="[[autoScanSpeedRangeMs_]]"
min="[[minScanSpeedMs_]]"
max="[[maxScanSpeedMs_]]"
label-min="[[minScanSpeedLabelSec_]]"
......
......@@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview 'switch-access-subpage' is the collapsible section containing
* Switch Access settings.
*/
(function() {
/**
* Available switch assignment values.
* @enum {number}
......@@ -13,14 +20,29 @@ const SwitchAccessAssignmentValue = {
ENTER: 2,
};
/** @type {!Array<number>} */
const AUTO_SCAN_SPEED_RANGE_MS = [
500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800,
2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000
];
/**
* @fileoverview 'switch-access-subpage' is the collapsible section containing
* Switch Access settings.
* @param {!Array<number>} ticksInMs
* @return {!Array<!cr_slider.SliderTick>}
*/
function ticksWithLabelsInSec(ticksInMs) {
// Dividing by 1000 to convert milliseconds to seconds for the label.
return ticksInMs.map(x => ({label: `${x / 1000}`, value: x}));
}
Polymer({
is: 'settings-switch-access-subpage',
behaviors: [I18nBehavior],
behaviors: [
I18nBehavior,
PrefsBehavior,
],
properties: {
/**
......@@ -32,15 +54,10 @@ Polymer({
},
/** @private {Array<number>} */
autoScanSpeedValuesMs_: {
autoScanSpeedRangeMs_: {
readOnly: true,
type: Array,
value: [
500, 600, 700, 800, 900, 1000, 1100, 1200, 1300,
1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200,
2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100,
3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000
]
value: ticksWithLabelsInSec(AUTO_SCAN_SPEED_RANGE_MS),
},
/** @private {Object} */
......@@ -122,6 +139,19 @@ Polymer({
return this.i18n('switchAccessAutoScanSpeedLabel', speedString);
},
/**
* @return {boolean} Whether to show settings for auto-scan within the
* keyboard.
* @private
*/
showKeyboardScanSettings_: function() {
const improvedTextInputEnabled = loadTimeData.getBoolean(
'showExperimentalAccessibilitySwitchAccessImprovedTextInput');
const autoScanEnabled = /** @type {boolean} */
(this.getPref('switch_access.auto_scan.enabled').value);
return improvedTextInputEnabled && autoScanEnabled;
},
/**
* @param {string} command
*/
......@@ -166,3 +196,4 @@ Polymer({
'durationInSeconds', this.formatter_.format(scanSpeedValueSec));
},
});
})();
......@@ -311,6 +311,8 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"switchAccessAutoScanLabel", IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_LABEL},
{"switchAccessAutoScanSpeedLabel",
IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_SPEED_LABEL},
{"switchAccessAutoScanKeyboardSpeedLabel",
IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_KEYBOARD_SPEED_LABEL},
{"durationInSeconds", IDS_SETTINGS_DURATION_IN_SECONDS},
{"manageAccessibilityFeatures",
IDS_SETTINGS_ACCESSIBILITY_MANAGE_ACCESSIBILITY_FEATURES},
......@@ -400,6 +402,11 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean(
"showExperimentalAccessibilitySwitchAccess",
cmd.HasSwitch(::switches::kEnableExperimentalAccessibilitySwitchAccess));
html_source->AddBoolean(
"showExperimentalAccessibilitySwitchAccessImprovedTextInput",
cmd.HasSwitch(
::switches::kEnableExperimentalAccessibilitySwitchAccessText));
#endif
}
......
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