Skip to content

Commit 24c54be

Browse files
HeniganHenigan
authored andcommitted
Add uniqueness check back to ChoiceSetManager
1 parent 4b245c3 commit 24c54be

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,13 @@ boolean setUpChoiceSet(ChoiceSet choiceSet) {
590590
}
591591

592592
HashSet<String> uniqueVoiceCommands = new HashSet<>();
593+
HashSet<ChoiceCell> uniqueChoiceCells = new HashSet<>();
594+
593595
int allVoiceCommandsCount = 0;
594596
int choiceCellWithVoiceCommandCount = 0;
595597

596598
for (ChoiceCell cell : choices) {
599+
uniqueChoiceCells.add(cell);
597600
// Not using cloned cell here because we set the clone's VoiceCommands to null for visual check only
598601
if (cell.getVoiceCommands() != null) {
599602
uniqueVoiceCommands.addAll(cell.getVoiceCommands());
@@ -602,6 +605,11 @@ boolean setUpChoiceSet(ChoiceSet choiceSet) {
602605
}
603606
}
604607

608+
if (uniqueChoiceCells.size() != choices.size()) {
609+
DebugTool.logError(TAG, "Attempted to create a choice set with a duplicate cell. Cell must have a unique value other than its primary text. The choice set will not be set.");
610+
return false;
611+
}
612+
605613
// All or none of the choices MUST have VR Commands
606614
if (choiceCellWithVoiceCommandCount > 0 && choiceCellWithVoiceCommandCount < choices.size()) {
607615
DebugTool.logError(TAG, "If using voice recognition commands, all of the choice set cells must have unique VR commands. There are " + uniqueVoiceCommands.size() + " cells with unique voice commands and " + choices.size() + " total cells. The choice set will not be set.");

0 commit comments

Comments
 (0)