Skip to content

Commit

Permalink
Merge pull request #1362 from smartdevicelink/bugfix/issue-1353-VR-PI…
Browse files Browse the repository at this point in the history
…CS-fails

Fix VR-only PICS failing in example apps
  • Loading branch information
joeljfischer committed Jul 30, 2019
2 parents d388eed + fa45e1b commit 272b151
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
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

0 comments on commit 272b151

Please sign in to comment.