Commit 4ae9e6e5 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Open settings on first launch

Currently, when a user launches Switch Access, they cannot control it
because they have to configure their switches. This change has Switch
Access check if the configured settings allow for navigation, and if
not opens the Switch Access settings page.

Bug: 996387
Change-Id: I7c85841e7511eb96726187a4db8b127d6f4820bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902233
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715168}
parent 1a028f30
...@@ -71,10 +71,15 @@ class SwitchAccessPreferences { ...@@ -71,10 +71,15 @@ class SwitchAccessPreferences {
* @private * @private
*/ */
init_(onReady) { init_(onReady) {
let readyFunction = function(onReady) { let readyFunction = () => {
this.isReady_ = true; this.isReady_ = true;
onReady(); onReady();
}.bind(this, onReady);
if (!this.settingsAreConfigured()) {
chrome.accessibilityPrivate.openSettingsSubpage(
'manageAccessibility/switchAccess');
}
};
chrome.settingsPrivate.onPrefsChanged.addListener( chrome.settingsPrivate.onPrefsChanged.addListener(
this.updateFromSettings_.bind(this)); this.updateFromSettings_.bind(this));
...@@ -168,5 +173,31 @@ class SwitchAccessPreferences { ...@@ -168,5 +173,31 @@ class SwitchAccessPreferences {
} }
return null; return null;
} }
/**
* Whether the current settings configuration is reasonably usable;
* specifically, whether there is a way to select and a way to navigate.
* @return {boolean}
*/
settingsAreConfigured() {
const selectSetting = this.getNumberPreferenceIfDefined(
SAConstants.Preference.SELECT_SETTING);
const nextSetting =
this.getNumberPreferenceIfDefined(SAConstants.Preference.NEXT_SETTING);
const previousSetting = this.getNumberPreferenceIfDefined(
SAConstants.Preference.PREVIOUS_SETTING);
const autoScanEnabled =
this.getBooleanPreference(SAConstants.Preference.AUTO_SCAN_ENABLED);
if (!selectSetting) {
return false;
}
if (nextSetting || previousSetting) {
return true;
}
return autoScanEnabled;
}
} }
...@@ -107,7 +107,10 @@ SAConstants.Preference = { ...@@ -107,7 +107,10 @@ SAConstants.Preference = {
AUTO_SCAN_ENABLED: 'settings.a11y.switch_access.auto_scan.enabled', AUTO_SCAN_ENABLED: 'settings.a11y.switch_access.auto_scan.enabled',
AUTO_SCAN_TIME: 'settings.a11y.switch_access.auto_scan.speed_ms', AUTO_SCAN_TIME: 'settings.a11y.switch_access.auto_scan.speed_ms',
AUTO_SCAN_KEYBOARD_TIME: AUTO_SCAN_KEYBOARD_TIME:
'settings.a11y.switch_access.auto_scan.keyboard.speed_ms' 'settings.a11y.switch_access.auto_scan.keyboard.speed_ms',
NEXT_SETTING: 'settings.a11y.switch_access.next.setting',
PREVIOUS_SETTING: 'settings.a11y.switch_access.previous.setting',
SELECT_SETTING: 'settings.a11y.switch_access.select.setting',
}; };
/** /**
......
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