diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-01-16 14:07:19 -0500 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-01-16 14:07:19 -0500 |
commit | a179b9f57655685c4fd41f5caa096ab23fbd1d1d (patch) | |
tree | 42860dfaa0082dea50c0b2bb988490182c11637f | |
parent | ab48824f2c8c6f4a7d70e5bf804220458a58fa06 (diff) | |
download | sdl_ios-feature/enhanceExampleApp.tar.gz |
Create template change example on example appsfeature/enhanceExampleApp
-rw-r--r-- | Example Apps/Example ObjC/MenuManager.m | 29 | ||||
-rw-r--r-- | Example Apps/Example Swift/MenuManager.swift | 35 | ||||
-rw-r--r-- | Example Apps/Shared/AppConstants.h | 1 | ||||
-rw-r--r-- | Example Apps/Shared/AppConstants.m | 1 |
4 files changed, 66 insertions, 0 deletions
diff --git a/Example Apps/Example ObjC/MenuManager.m b/Example Apps/Example ObjC/MenuManager.m index 083d368d8..c142225ae 100644 --- a/Example Apps/Example ObjC/MenuManager.m +++ b/Example Apps/Example ObjC/MenuManager.m @@ -25,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN [self sdlex_menuCellShowPerformInteractionWithManager:manager performManager:performManager], [self sdlex_menuCellRecordInCarMicrophoneAudioWithManager:manager], [self sdlex_menuCellDialNumberWithManager:manager], + [self sdlex_menuCellChangeTemplateWithManager:manager], [self sdlex_menuCellWithSubmenuWithManager:manager]]; } @@ -86,6 +87,34 @@ NS_ASSUME_NONNULL_BEGIN }]; } ++ (SDLMenuCell *)sdlex_menuCellChangeTemplateWithManager:(SDLManager *)manager { + NSMutableArray *submenuItems = [NSMutableArray array]; + + // Non - Media + SDLMenuCell *cell = [[SDLMenuCell alloc] initWithTitle:@"Non - Media (Default)" icon:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) { + SDLSetDisplayLayout* display = [[SDLSetDisplayLayout alloc] initWithPredefinedLayout:SDLPredefinedLayoutNonMedia]; + [manager sendRequest:display withResponseHandler:^(SDLRPCRequest *request, SDLRPCResponse *response, NSError *error) { + if ([response.resultCode isEqualToEnum:SDLResultSuccess]) { + // The template has been set successfully + } + }]; + }]; + [submenuItems addObject:cell]; + + // Graphic With Text + SDLMenuCell *cell2 = [[SDLMenuCell alloc] initWithTitle:@"Graphic With Text" icon:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) { + SDLSetDisplayLayout* display = [[SDLSetDisplayLayout alloc] initWithPredefinedLayout:SDLPredefinedLayoutGraphicWithText]; + [manager sendRequest:display withResponseHandler:^(SDLRPCRequest *request, SDLRPCResponse *response, NSError *error) { + if ([response.resultCode isEqualToEnum:SDLResultSuccess]) { + // The template has been set successfully + } + }]; + }]; + [submenuItems addObject:cell2]; + + return [[SDLMenuCell alloc] initWithTitle:ACSubmenuTemplateMenuName icon:nil subCells:[submenuItems copy]]; +} + + (SDLMenuCell *)sdlex_menuCellWithSubmenuWithManager:(SDLManager *)manager { NSMutableArray *submenuItems = [NSMutableArray array]; for (int i = 0; i < 75; i++) { diff --git a/Example Apps/Example Swift/MenuManager.swift b/Example Apps/Example Swift/MenuManager.swift index 959265a74..c7efc59a3 100644 --- a/Example Apps/Example Swift/MenuManager.swift +++ b/Example Apps/Example Swift/MenuManager.swift @@ -21,6 +21,7 @@ class MenuManager: NSObject { menuCellShowPerformInteraction(with: manager, choiceSetManager: choiceSetManager), menuCellRecordInCarMicrophoneAudio(with: manager), menuCellDialNumber(with: manager), + menuCellChangeTemplate(with: manager), menuCellWithSubmenu(with: manager)] } @@ -113,6 +114,40 @@ private extension MenuManager { VehicleDataManager.checkPhoneCallCapability(manager: manager, phoneNumber:"555-555-5555") }) } + + /// Menu item that changes the default template + /// + /// - Parameter manager: The SDL Manager + /// - Returns: A SDLMenuCell object + class func menuCellChangeTemplate(with manager: SDLManager) -> SDLMenuCell { + + /// Lets give an example of 2 templates + var submenuItems = [SDLMenuCell]() + + /// Non-Media + let submenuTitleNonMedia = "Non - Media (Default)" + submenuItems.append(SDLMenuCell(title: submenuTitleNonMedia, icon: nil, voiceCommands: nil, handler: { (triggerSource) in + let display = SDLSetDisplayLayout(predefinedLayout: .nonMedia) + manager.send(request: display) { (request, response, error) in + if response?.resultCode == .success { + // The template has been set successfully + } + } + })) + + /// Graphic with Text + let submenuTitleGraphicText = "Graphic With Text" + submenuItems.append(SDLMenuCell(title: submenuTitleGraphicText, icon: nil, voiceCommands: nil, handler: { (triggerSource) in + let display = SDLSetDisplayLayout(predefinedLayout: .graphicWithText) + manager.send(request: display) { (request, response, error) in + if response?.resultCode == .success { + // The template has been set successfully + } + } + })) + + return SDLMenuCell(title: ACSubmenuTemplateMenuName, icon: nil, subCells: submenuItems) + } /// Menu item that opens a submenu when selected /// diff --git a/Example Apps/Shared/AppConstants.h b/Example Apps/Shared/AppConstants.h index 4ec2851b1..1c557c969 100644 --- a/Example Apps/Shared/AppConstants.h +++ b/Example Apps/Shared/AppConstants.h @@ -73,6 +73,7 @@ extern NSString * const ACRecordInCarMicrophoneAudioMenuName; extern NSString * const ACDialPhoneNumberMenuName; extern NSString * const ACSubmenuMenuName; extern NSString * const ACSubmenuItemMenuName; +extern NSString * const ACSubmenuTemplateMenuName; extern NSString * const ACAccelerationPedalPositionMenuName; extern NSString * const ACAirbagStatusMenuName; diff --git a/Example Apps/Shared/AppConstants.m b/Example Apps/Shared/AppConstants.m index 016985ff2..c96464d63 100644 --- a/Example Apps/Shared/AppConstants.m +++ b/Example Apps/Shared/AppConstants.m @@ -71,6 +71,7 @@ NSString * const ACRecordInCarMicrophoneAudioMenuName = @"Record In-Car Micropho NSString * const ACDialPhoneNumberMenuName = @"Dial Phone Number"; NSString * const ACSubmenuMenuName = @"Submenu"; NSString * const ACSubmenuItemMenuName = @"Item"; +NSString * const ACSubmenuTemplateMenuName = @"Change Template"; NSString * const ACAccelerationPedalPositionMenuName = @"Acceleration Pedal Position"; NSString * const ACAirbagStatusMenuName = @"Airbag Status"; |