-
Notifications
You must be signed in to change notification settings - Fork 103
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
Implement SDL 0157 - Choice Set Manager #975
Changes from 53 commits
e8323e1
8bf60fa
46ac2b7
02617d1
4efba03
9bc4833
9c6d211
6b85bc6
5690738
1685ffc
a7b8e94
d0ccfcc
f4a5d3f
217f63d
8cf5116
f8cce42
0967ada
fb485f2
2b33f9f
c630ea6
444d02a
a8910ce
e5bd3d0
cc14fda
79d5891
7f9d9d5
4c4efd2
dfd1fbb
e658b77
792bb0e
3b5b7c0
3a8ae4f
4d1f0b0
8660fec
7674b44
6c35b87
ef0b79f
ca1477f
c8bdf93
32394ee
ef4dd7b
470c320
650f235
c47a662
133faf4
9e316bf
786eedf
0ef0b3a
7092424
607f7ce
a664564
bfe4754
1b046de
aa39378
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// SDLCheckChoiceVROptionalOperation.h | ||
// SmartDeviceLink | ||
// | ||
// Created by Joel Fischer on 5/24/18. | ||
// Copyright © 2018 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import "SDLAsynchronousOperation.h" | ||
|
||
@protocol SDLConnectionManagerType; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
|
||
@interface SDLCheckChoiceVROptionalOperation : SDLAsynchronousOperation | ||
|
||
@property (assign, nonatomic, getter=isVROptional) BOOL vrOptional; | ||
|
||
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// SDLCheckChoiceVROptionalOperation.m | ||
// SmartDeviceLink | ||
// | ||
// Created by Joel Fischer on 5/24/18. | ||
// Copyright © 2018 smartdevicelink. All rights reserved. | ||
// | ||
|
||
#import "SDLCheckChoiceVROptionalOperation.h" | ||
|
||
#import "SDLChoice.h" | ||
#import "SDLCreateInteractionChoiceSet.h" | ||
#import "SDLConnectionManagerType.h" | ||
#import "SDLLogMacros.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SDLCheckChoiceVROptionalOperation() | ||
|
||
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager; | ||
@property (copy, nonatomic, nullable) NSError *internalError; | ||
|
||
@end | ||
|
||
@implementation SDLCheckChoiceVROptionalOperation | ||
|
||
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager { | ||
self = [super init]; | ||
if (!self) { return nil; } | ||
|
||
_connectionManager = connectionManager; | ||
|
||
return self; | ||
} | ||
|
||
- (void)start { | ||
[super start]; | ||
|
||
[self sdl_sendTestChoices]; | ||
} | ||
|
||
- (void)sdl_sendTestChoices { | ||
__weak typeof(self) weakself = self; | ||
[self.connectionManager sendConnectionManagerRequest:[self.class sdl_testCellWithVR:NO] withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { | ||
if (error == nil) { | ||
SDLLogD(@"Connected head unit supports choice cells without voice commands. Cells without voice will be sent without voice from now on (no placeholder voice)."); | ||
|
||
weakself.vrOptional = YES; | ||
weakself.internalError = nil; | ||
[weakself finishOperation]; | ||
return; | ||
} | ||
|
||
// Check for choice sets with VR | ||
[self.connectionManager sendConnectionManagerRequest:[self.class sdl_testCellWithVR:YES] withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { | ||
if (error == nil) { | ||
SDLLogW(@"Connected head unit does not support choice cells without voice commands. Cells without voice will be sent with placeholder voices from now on."); | ||
|
||
weakself.vrOptional = NO; | ||
weakself.internalError = nil; | ||
[weakself finishOperation]; | ||
return; | ||
} | ||
|
||
SDLLogE(@"Connected head unit has rejected all choice cells, choice manager disabled. Error: %@, Response: %@", error, response); | ||
weakself.vrOptional = NO; | ||
weakself.internalError = error; | ||
[weakself finishOperation]; | ||
}]; | ||
}]; | ||
} | ||
|
||
+ (SDLCreateInteractionChoiceSet *)sdl_testCellWithVR:(BOOL)hasVR { | ||
SDLChoice *choice = [[SDLChoice alloc] init]; | ||
choice.choiceID = @0; | ||
choice.menuName = @"Test Cell"; | ||
choice.vrCommands = hasVR ? @[@"Test VR"] : nil; | ||
|
||
SDLCreateInteractionChoiceSet *choiceSet = [[SDLCreateInteractionChoiceSet alloc] initWithId:0 choiceSet:@[choice]]; | ||
|
||
return choiceSet; | ||
} | ||
|
||
#pragma mark - Property Overrides | ||
|
||
- (nullable NSString *)name { | ||
return @"com.sdl.choicesetmanager.checkVROptional"; | ||
} | ||
|
||
- (NSOperationQueuePriority)queuePriority { | ||
return NSOperationQueuePriorityVeryHigh; | ||
} | ||
|
||
- (nullable NSError *)error { | ||
return self.internalError; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// SDLChoiceCell.h | ||
// SmartDeviceLink | ||
// | ||
// Created by Joel Fischer on 5/21/18. | ||
// Copyright © 2018 Livio. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class SDLArtwork; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SDLChoiceCell: NSObject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be handy to have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with blocks is that we'd have to store all of them...and there could be a lot. For now, I've added a row index to the delegate callback, which should be sufficient. If we want to go to blocks, we can do so in a later release. |
||
|
||
/** | ||
Maps to Choice.menuName. The primary text of the cell. Duplicates within an `SDLChoiceSet` are not permitted and will result in the `SDLChoiceSet` failing to initialize. | ||
*/ | ||
@property (copy, nonatomic, readonly) NSString *text; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add to documentation that duplicate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
/** | ||
Maps to Choice.secondaryText. Optional secondary text of the cell, if available. Duplicates within an `SDLChoiceSet` are permitted. | ||
*/ | ||
@property (copy, nonatomic, readonly, nullable) NSString *secondaryText; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add to documentation that duplicate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
/** | ||
Maps to Choice.tertiaryText. Optional tertitary text of the cell, if available. Duplicates within an `SDLChoiceSet` are permitted. | ||
*/ | ||
@property (copy, nonatomic, readonly, nullable) NSString *tertiaryText; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add to documentation that duplicate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
/** | ||
Maps to Choice.vrCommands. Optional voice commands the user can speak to activate the cell. If not set and the head unit requires it, this will be set to the number in the list that this item appears. However, this would be a very poor experience for a user if the choice set is presented as a voice only interaction or both interaction mode. Therefore, consider not setting this only when you know the choice set will be presented as a touch only interaction. | ||
*/ | ||
@property (copy, nonatomic, readonly, nullable) NSArray<NSString *> *voiceCommands; | ||
|
||
/** | ||
Maps to Choice.image. Optional image for the cell. This will be uploaded before the cell is used when the cell is preloaded or presented for the first time. | ||
*/ | ||
@property (strong, nonatomic, readonly, nullable) SDLArtwork *artwork; | ||
|
||
/** | ||
Maps to Choice.secondaryImage. Optional secondary image for the cell. This will be uploaded before the cell is used when the cell is preloaded or presented for the first time. | ||
*/ | ||
@property (strong, nonatomic, readonly, nullable) SDLArtwork *secondaryArtwork; | ||
|
||
/** | ||
Initialize the cell with nothing. This is unavailable | ||
|
||
@return A crash, probably | ||
*/ | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
/** | ||
Initialize the cell with text and nothing else. | ||
|
||
@param text The primary text of the cell. | ||
@return The cell | ||
*/ | ||
- (instancetype)initWithText:(NSString *)text; | ||
|
||
/** | ||
Initialize the cell with text, optional artwork, and optional voice commands | ||
|
||
@param text The primary text of the cell | ||
@param artwork The primary artwork of the cell | ||
@param voiceCommands Strings that can be spoken by the user to activate this cell in a voice or both interaction mode | ||
@return The cell | ||
*/ | ||
- (instancetype)initWithText:(NSString *)text artwork:(nullable SDLArtwork *)artwork voiceCommands:(nullable NSArray<NSString *> *)voiceCommands; | ||
|
||
/** | ||
Initialize the cell with all optional items | ||
|
||
@param text The primary text | ||
@param secondaryText The secondary text | ||
@param tertiaryText The tertiary text | ||
@param voiceCommands Strings that can be spoken by the user to activate this cell in a voice or both interaction mode | ||
@param artwork The primary artwork | ||
@param secondaryArtwork The secondary artwork | ||
@return The cell | ||
*/ | ||
- (instancetype)initWithText:(NSString *)text secondaryText:(nullable NSString *)secondaryText tertiaryText:(nullable NSString *)tertiaryText voiceCommands:(nullable NSArray<NSString *> *)voiceCommands artwork:(nullable SDLArtwork *)artwork secondaryArtwork:(nullable SDLArtwork *)secondaryArtwork; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows up on Manticore's Voice tab. Could be confusing for developers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, that's unavoidable. This has to have a VR command to be valid, and it's used for the keyboard.