Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VR-only PICS failing in example apps #1362

Merged
merged 3 commits into from Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions Example Apps/Example ObjC/PerformInteractionManager.m
Expand Up @@ -20,6 +20,7 @@ @interface PerformInteractionManager() <SDLChoiceSetDelegate, SDLKeyboardDelegat

@property (strong, nonatomic, readonly) SDLChoiceSet *choiceSet;
@property (copy, nonatomic, readonly) NSArray<SDLChoiceCell *> *cells;
@property (copy, nonatomic, readonly) NSArray<SDLVRHelpItem *> *vrHelpList;

@end

Expand All @@ -39,17 +40,25 @@ - (void)showWithTriggerSource:(SDLTriggerSource)source {
}

- (SDLChoiceSet *)choiceSet {
return [[SDLChoiceSet alloc] initWithTitle:PICSInitialPrompt delegate:self layout:SDLChoiceSetLayoutList timeout:10 initialPromptString:PICSInitialPrompt timeoutPromptString:PICSTimeoutPrompt helpPromptString:PICSHelpPrompt vrHelpList:nil choices:self.cells];
return [[SDLChoiceSet alloc] initWithTitle:PICSInitialPrompt delegate:self layout:SDLChoiceSetLayoutList timeout:10 initialPromptString:PICSInitialPrompt timeoutPromptString:PICSTimeoutPrompt helpPromptString:PICSHelpPrompt vrHelpList:self.vrHelpList choices:self.cells];
}

- (NSArray<SDLChoiceCell *> *)cells {
SDLChoiceCell *firstChoice = [[SDLChoiceCell alloc] initWithText:PICSFirstChoice artwork:[SDLArtwork artworkWithStaticIcon:SDLStaticIconNameKey] voiceCommands:nil];
SDLChoiceCell *secondChoice = [[SDLChoiceCell alloc] initWithText:PICSSecondChoice];
SDLChoiceCell *thirdChoice = [[SDLChoiceCell alloc] initWithText:PICSThirdChoice];
SDLChoiceCell *firstChoice = [[SDLChoiceCell alloc] initWithText:PICSFirstChoice artwork:[SDLArtwork artworkWithStaticIcon:SDLStaticIconNameKey] voiceCommands:@[VCPICSFirstChoice]];
SDLChoiceCell *secondChoice = [[SDLChoiceCell alloc] initWithText:PICSSecondChoice artwork:[SDLArtwork artworkWithStaticIcon:SDLStaticIconNameMicrophone] voiceCommands:@[VCPICSecondChoice]];
SDLChoiceCell *thirdChoice = [[SDLChoiceCell alloc] initWithText:PICSThirdChoice artwork:[SDLArtwork artworkWithStaticIcon:SDLStaticIconNameKey] voiceCommands:@[VCPICSThirdChoice]];

return @[firstChoice, secondChoice, thirdChoice];
}

- (NSArray<SDLVRHelpItem *> *)vrHelpList {
SDLVRHelpItem *vrHelpListFirst = [[SDLVRHelpItem alloc] initWithText:VCPICSFirstChoice image:nil];
SDLVRHelpItem *vrHelpListSecond = [[SDLVRHelpItem alloc] initWithText:VCPICSecondChoice image:nil];
SDLVRHelpItem *vrHelpListThird = [[SDLVRHelpItem alloc] initWithText:VCPICSThirdChoice image:nil];

return @[vrHelpListFirst, vrHelpListSecond, vrHelpListThird];
}

- (SDLInteractionMode)modeForTriggerSource:(SDLTriggerSource)source {
return ([source isEqualToEnum:SDLTriggerSourceMenu] ? SDLInteractionModeManualOnly : SDLInteractionModeVoiceRecognitionOnly);
}
Expand Down
16 changes: 12 additions & 4 deletions Example Apps/Example Swift/PerformInteractionManager.swift
Expand Up @@ -30,15 +30,23 @@ class PerformInteractionManager: NSObject {
private extension PerformInteractionManager {
/// The PICS menu items
var choiceCells: [SDLChoiceCell] {
let firstChoice = SDLChoiceCell(text: PICSFirstChoice, artwork: SDLArtwork(staticIcon: .key), voiceCommands: nil)
let secondChoice = SDLChoiceCell(text: PICSSecondChoice)
let thirdChoice = SDLChoiceCell(text: PICSThirdChoice)
let firstChoice = SDLChoiceCell(text: PICSFirstChoice, artwork: SDLArtwork(staticIcon: .key), voiceCommands: [VCPICSFirstChoice])
let secondChoice = SDLChoiceCell(text: PICSSecondChoice, artwork: SDLArtwork(staticIcon: .microphone), voiceCommands: [VCPICSecondChoice])
let thirdChoice = SDLChoiceCell(text: PICSThirdChoice, artwork: SDLArtwork(staticIcon: .key), voiceCommands: [VCPICSThirdChoice])
return [firstChoice, secondChoice, thirdChoice]
}

var vrHelpList: [SDLVRHelpItem] {
let vrHelpListFirst = SDLVRHelpItem(text: VCPICSFirstChoice, image: nil)
let vrHelpListSecond = SDLVRHelpItem(text: VCPICSecondChoice, image: nil)
let vrHelpListThird = SDLVRHelpItem(text: VCPICSThirdChoice, image: nil)

return [vrHelpListFirst, vrHelpListSecond, vrHelpListThird]
}

/// Creates a PICS with three menu items and customized voice commands
var choiceSet: SDLChoiceSet {
return SDLChoiceSet(title: PICSInitialPrompt, delegate: self, layout: .list, timeout: 10, initialPromptString: PICSInitialPrompt, timeoutPromptString: PICSTimeoutPrompt, helpPromptString: PICSHelpPrompt, vrHelpList: nil, choices: choiceCells)
return SDLChoiceSet(title: PICSInitialPrompt, delegate: self, layout: .list, timeout: 10, initialPromptString: PICSInitialPrompt, timeoutPromptString: PICSTimeoutPrompt, helpPromptString: PICSHelpPrompt, vrHelpList: vrHelpList, choices: choiceCells)
}

func interactionMode(for triggerSource: SDLTriggerSource) -> SDLInteractionMode {
Expand Down
5 changes: 5 additions & 0 deletions Example Apps/Shared/AppConstants.h
Expand Up @@ -64,6 +64,11 @@ extern NSString * const PICSFirstChoice;
extern NSString * const PICSSecondChoice;
extern NSString * const PICSThirdChoice;

#pragma mark - SDL Perform Interaction Choice Set Menu VR Commands
extern NSString * const VCPICSFirstChoice;
extern NSString * const VCPICSecondChoice;
extern NSString * const VCPICSThirdChoice;

#pragma mark - SDL Add Command Menu
extern NSString * const ACSpeakAppNameMenuName;
extern NSString * const ACShowChoiceSetMenuName;
Expand Down
5 changes: 5 additions & 0 deletions Example Apps/Shared/AppConstants.m
Expand Up @@ -61,6 +61,11 @@
NSString * const PICSSecondChoice = @"Second Choice";
NSString * const PICSThirdChoice = @"Third Choice";

#pragma mark - SDL Perform Interaction Choice Set Menu VR Commands
NSString * const VCPICSFirstChoice = @"First";
NSString * const VCPICSecondChoice = @"Second";
NSString * const VCPICSThirdChoice = @"Third";

#pragma mark - SDL Add Command Menu
NSString * const ACSpeakAppNameMenuName = @"Speak App Name";
NSString * const ACShowChoiceSetMenuName = @"Show Perform Interaction Choice Set";
Expand Down