Commit 99c2ed6b authored by Josiah K's avatar Josiah K Committed by Chromium LUCI CQ

[Switch Access] Prevent removal of last switch for Select action

Screenshot: https://screenshot.googleplex.com/8NAe4DWRAsTKipU
Design: go/switch-access-setup-ux-select-switch

AX-Relnotes: In Switch Access, disallow removal of select switch if it's the only one remaining, to prevent users from getting into a bad state.
Fixed: 1157268
Change-Id: I69358685f8cf389675875a1558c71591a6e6e921
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583150
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarJimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836048}
parent 2100969a
......@@ -1009,6 +1009,9 @@ Press an assigned switch to remove assignment.
<message name="IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_NOT_CONFIRMED_PROMPT" desc="A message warning the user that the switch key pressed during confirmation did not match the initial switch key pressed. 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.">
Keys do not match. “<ph name="unexpectedKey">$1<ex>enter</ex></ph>” was pressed. “<ph name="currentKey">$2<ex>backspace</ex></ph>” was pressed before. Press any key to exit.
</message>
<message name="IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH" desc="A message warning the user that they cannot remove the last switch for the Select action. The text for the 'Select' action should be the same as the text from IDS_SETTINGS_ASSIGN_SELECT_SWITCH_LABEL. 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.">
Couldn't remove the only switch assigned to Select. Press any key to exit.
</message>
<message name="IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_0_SWITCHES" desc="A sub-label for the link that brings up a dialog to assign a switch key to an action. Mentions zero switches assigned. 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.">
0 switches assigned
</message>
......
......@@ -21,6 +21,7 @@
WARN_NOT_CONFIRMED: 3,
WARN_ALREADY_ASSIGNED_ACTION: 4,
WARN_UNRECOGNIZED_KEY: 5,
WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH: 6,
};
/**
......@@ -174,6 +175,7 @@ Polymer({
case AssignmentState.WARN_NOT_CONFIRMED:
case AssignmentState.WARN_ALREADY_ASSIGNED_ACTION:
case AssignmentState.WARN_UNRECOGNIZED_KEY:
case AssignmentState.WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH:
this.$.switchAccessActionAssignmentDialog.close();
break;
}
......@@ -201,6 +203,12 @@ Polymer({
}
if (action === this.action) {
if (action === SwitchAccessCommand.SELECT &&
this.assignments_.length === 1) {
this.assignmentState_ =
AssignmentState.WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH;
return;
}
this.assignmentState_ = AssignmentState.WAIT_FOR_CONFIRMATION_REMOVAL;
} else {
this.alreadyAssignedAction_ = action;
......@@ -339,6 +347,9 @@ Polymer({
case AssignmentState.WARN_UNRECOGNIZED_KEY:
return this.i18n(
'switchAccessActionAssignmentDialogWarnUnrecognizedKeyPrompt');
case AssignmentState.WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH:
return this.i18n(
'switchAccessActionAssignmentDialogWarnCannotRemoveLastSelectSwitch');
default:
return '';
}
......
......@@ -525,6 +525,8 @@ void AccessibilitySection::AddLoadTimeData(
IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_CONFIRMATION_PROMPT},
{"switchAccessActionAssignmentDialogWaitForConfirmationRemovalPrompt",
IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_CONFIRMATION_REMOVAL_PROMPT},
{"switchAccessActionAssignmentDialogWarnCannotRemoveLastSelectSwitch",
IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH},
{"noSwitchesAssigned", IDS_SETTINGS_NO_SWITCHES_ASSIGNED},
{"switchAccessActionAssignmentDialogExit",
IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_EXIT},
......
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