summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2018-04-12 15:42:28 -0400
committerJoel Fischer <joeljfischer@gmail.com>2018-04-12 15:42:28 -0400
commitf6cbbb64164ca81fdae656a1ef4f3330848e232e (patch)
tree5144e1231c51cfea93283b2af02ee1c9917eb49d
parentc1cb9ecabcaa0bcc90923b8dfa5413f12a827556 (diff)
downloadsdl_ios-f6cbbb64164ca81fdae656a1ef4f3330848e232e.tar.gz
Fix screen manager / menu manager integration
* Fix parent ID of add command from menu cell * Use menu manager in example app * Add description to cells
-rw-r--r--SmartDeviceLink/SDLMenuCell.m6
-rw-r--r--SmartDeviceLink/SDLMenuManager.m2
-rw-r--r--SmartDeviceLink/SDLScreenManager.m19
-rw-r--r--SmartDeviceLink/SDLVoiceCommand.m4
-rw-r--r--SmartDeviceLink/SmartDeviceLink.h6
-rw-r--r--SmartDeviceLink_Example/Classes/ProxyManager.m73
6 files changed, 49 insertions, 61 deletions
diff --git a/SmartDeviceLink/SDLMenuCell.m b/SmartDeviceLink/SDLMenuCell.m
index f83048702..29c17eab6 100644
--- a/SmartDeviceLink/SDLMenuCell.m
+++ b/SmartDeviceLink/SDLMenuCell.m
@@ -8,6 +8,8 @@
#import "SDLMenuCell.h"
+#import "SDLArtwork.h"
+
NS_ASSUME_NONNULL_BEGIN
@interface SDLMenuCell()
@@ -44,6 +46,10 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
+- (NSString *)description {
+ return [NSString stringWithFormat:@"SDLMenuCell: %u-\"%@\", artworkName: %@, voice commands: %lu, isSubcell: %@, hasSubcells: %@", (unsigned int)_cellId, _title, _icon.name, _voiceCommands.count, (_parentCellId != UINT32_MAX ? @"YES" : @"NO"), (_subCells.count > 0 ? @"YES" : @"NO")];
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLMenuManager.m b/SmartDeviceLink/SDLMenuManager.m
index a54bc5e78..910cb951b 100644
--- a/SmartDeviceLink/SDLMenuManager.m
+++ b/SmartDeviceLink/SDLMenuManager.m
@@ -362,7 +362,7 @@ UInt32 const ParentIdNotFound = UINT32_MAX;
SDLMenuParams *params = [[SDLMenuParams alloc] init];
params.menuName = cell.title;
- params.parentID = @(cell.parentCellId);
+ params.parentID = cell.parentCellId != UINT32_MAX ? @(cell.parentCellId) : nil;
command.menuParams = params;
command.vrCommands = cell.voiceCommands;
diff --git a/SmartDeviceLink/SDLScreenManager.m b/SmartDeviceLink/SDLScreenManager.m
index 85c5793e5..ec811efa6 100644
--- a/SmartDeviceLink/SDLScreenManager.m
+++ b/SmartDeviceLink/SDLScreenManager.m
@@ -9,6 +9,7 @@
#import "SDLScreenManager.h"
#import "SDLArtwork.h"
+#import "SDLMenuManager.h"
#import "SDLSoftButtonManager.h"
#import "SDLTextAndGraphicManager.h"
@@ -18,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) SDLTextAndGraphicManager *textAndGraphicManager;
@property (strong, nonatomic) SDLSoftButtonManager *softButtonManager;
+@property (strong, nonatomic) SDLMenuManager *menuManager;
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
@property (weak, nonatomic) SDLFileManager *fileManager;
@@ -35,6 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
_textAndGraphicManager = [[SDLTextAndGraphicManager alloc] initWithConnectionManager:connectionManager fileManager:fileManager];
_softButtonManager = [[SDLSoftButtonManager alloc] initWithConnectionManager:connectionManager fileManager:fileManager];
+ _menuManager = [[SDLMenuManager alloc] initWithConnectionManager:connectionManager fileManager:fileManager];
return self;
}
@@ -108,6 +111,14 @@ NS_ASSUME_NONNULL_BEGIN
self.softButtonManager.softButtonObjects = softButtonObjects;
}
+- (void)setMenu:(NSArray<SDLMenuCell *> *)menu {
+ self.menuManager.menuCells = menu;
+}
+
+- (void)setVoiceCommands:(NSArray<SDLVoiceCommand *> *)voiceCommands {
+ self.menuManager.voiceCommands = voiceCommands;
+}
+
#pragma mark - Getters
- (nullable NSString *)textField1 {
@@ -170,6 +181,14 @@ NS_ASSUME_NONNULL_BEGIN
return _softButtonManager.softButtonObjects;
}
+- (NSArray<SDLMenuCell *> *)menu {
+ return _menuManager.menuCells;
+}
+
+- (NSArray<SDLVoiceCommand *> *)voiceCommands {
+ return _menuManager.voiceCommands;
+}
+
#pragma mark - Begin / End Updates
- (void)beginUpdates {
diff --git a/SmartDeviceLink/SDLVoiceCommand.m b/SmartDeviceLink/SDLVoiceCommand.m
index bf92fac73..e9a619945 100644
--- a/SmartDeviceLink/SDLVoiceCommand.m
+++ b/SmartDeviceLink/SDLVoiceCommand.m
@@ -28,6 +28,10 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
+- (NSString *)description {
+ return [NSString stringWithFormat:@"SDLVoiceCommand: %u-\"%@\", voice commands: %lu", (unsigned int)_commandId, _voiceCommands.firstObject, _voiceCommands.count];
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h
index 339f23910..b50b01e7f 100644
--- a/SmartDeviceLink/SmartDeviceLink.h
+++ b/SmartDeviceLink/SmartDeviceLink.h
@@ -347,11 +347,15 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[];
#import "SDLPermissionConstants.h"
#import "SDLPermissionManager.h"
-// Show
+// Screen
#import "SDLScreenManager.h"
#import "SDLSoftButtonObject.h"
#import "SDLSoftButtonState.h"
+#import "SDLMenuManager.h"
+#import "SDLMenuCell.h"
+#import "SDLVoiceCommand.h"
+
// Touches
#import "SDLPinchGesture.h"
#import "SDLTouch.h"
diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m
index 5a54acc9d..ef1c0d94c 100644
--- a/SmartDeviceLink_Example/Classes/ProxyManager.m
+++ b/SmartDeviceLink_Example/Classes/ProxyManager.m
@@ -219,60 +219,6 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - RPC builders
-+ (SDLAddCommand *)sdlex_speakNameCommandWithManager:(SDLManager *)manager {
- NSString *commandName = @"Speak App Name";
-
- SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init];
- commandMenuParams.menuName = commandName;
-
- SDLAddCommand *speakNameCommand = [[SDLAddCommand alloc] init];
- speakNameCommand.vrCommands = @[commandName];
- speakNameCommand.menuParams = commandMenuParams;
- speakNameCommand.cmdID = @0;
-
- speakNameCommand.handler = ^void(SDLOnCommand *notification) {
- [manager sendRequest:[self.class sdlex_appNameSpeak]];
- };
-
- return speakNameCommand;
-}
-
-+ (SDLAddCommand *)sdlex_interactionSetCommandWithManager:(SDLManager *)manager {
- NSString *commandName = @"Perform Interaction";
-
- SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init];
- commandMenuParams.menuName = commandName;
-
- SDLAddCommand *performInteractionCommand = [[SDLAddCommand alloc] init];
- performInteractionCommand.vrCommands = @[commandName];
- performInteractionCommand.menuParams = commandMenuParams;
- performInteractionCommand.cmdID = @1;
-
- // NOTE: You may want to preload your interaction sets, because they can take a while for the remote system to process. We're going to ignore our own advice here.
- __weak typeof(self) weakSelf = self;
- performInteractionCommand.handler = ^void(SDLOnCommand *notification) {
- [weakSelf sdlex_sendPerformOnlyChoiceInteractionWithManager:manager];
- };
-
- return performInteractionCommand;
-}
-
-+ (SDLAddCommand *)sdlex_vehicleDataCommandWithManager:(SDLManager *)manager {
- SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init];
- commandMenuParams.menuName = @"Get Vehicle Data";
-
- SDLAddCommand *getVehicleDataCommand = [[SDLAddCommand alloc] init];
- getVehicleDataCommand.vrCommands = [NSMutableArray arrayWithObject:@"Get Vehicle Data"];
- getVehicleDataCommand.menuParams = commandMenuParams;
- getVehicleDataCommand.cmdID = @2;
-
- getVehicleDataCommand.handler = ^void(SDLOnCommand *notification) {
- [ProxyManager sdlex_sendGetVehicleDataWithManager:manager];
- };
-
- return getVehicleDataCommand;
-}
-
+ (SDLSpeak *)sdlex_appNameSpeak {
SDLSpeak *speak = [[SDLSpeak alloc] init];
speak.ttsChunks = [SDLTTSChunk textChunksFromString:@"S D L Example App"];
@@ -403,11 +349,20 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdlex_prepareRemoteSystem {
- [self.sdlManager sendRequests:@[[self.class sdlex_speakNameCommandWithManager:self.sdlManager], [self.class sdlex_interactionSetCommandWithManager:self.sdlManager], [self.class sdlex_vehicleDataCommandWithManager:self.sdlManager], [self.class sdlex_createOnlyChoiceInteractionSet]]
- progressHandler:^(__kindof SDLRPCRequest * _Nonnull request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error, float percentComplete) {
- NSLog(@"Commands sent updated, percent complete %f%%", percentComplete * 100);
- }
- completionHandler:nil];
+ __weak typeof(self) weakself = self;
+ SDLMenuCell *speakCell = [[SDLMenuCell alloc] initWithTitle:@"Speak" icon:nil voiceCommands:@[@"Speak"] handler:^{
+ [weakself.sdlManager sendRequest:[ProxyManager sdlex_appNameSpeak]];
+ }];
+
+ SDLMenuCell *interactionSetCell = [[SDLMenuCell alloc] initWithTitle:@"Perform Interaction" icon:nil voiceCommands:@[@"Perform Interaction"] handler:^{
+ [ProxyManager sdlex_sendPerformOnlyChoiceInteractionWithManager:weakself.sdlManager];
+ }];
+
+ SDLMenuCell *getVehicleDataCell = [[SDLMenuCell alloc] initWithTitle:@"Get Vehicle Data" icon:nil voiceCommands:@[@"Get Vehicle Data"] handler:^{
+ [ProxyManager sdlex_sendGetVehicleDataWithManager:weakself.sdlManager];
+ }];
+
+ self.sdlManager.screenManager.menu = @[speakCell, interactionSetCell, getVehicleDataCell];
}