diff options
author | Justin Beharry <justin.beharry@livio.io> | 2022-08-08 10:52:05 -0400 |
---|---|---|
committer | Justin Beharry <justin.beharry@livio.io> | 2022-08-08 10:52:05 -0400 |
commit | 4084464334f7cf2ee61f43d04fb97f422387a2d2 (patch) | |
tree | 0174bfc37972f9d2e7b49ba3d9cb10b0edb07078 | |
parent | 710984db69ff33a4399daae5ea7296874f8aead1 (diff) | |
download | sdl_ios-4084464334f7cf2ee61f43d04fb97f422387a2d2.tar.gz |
Remove set climate button and add back to home button
-Initialize Remote Control Manager with init soft buttons
-Add reset soft button to climate controller
-rw-r--r-- | Example Apps/Example ObjC/MenuManager.m | 11 | ||||
-rw-r--r-- | Example Apps/Example ObjC/ProxyManager.m | 2 | ||||
-rw-r--r-- | Example Apps/Example ObjC/RemoteControlManager.h | 3 | ||||
-rw-r--r-- | Example Apps/Example ObjC/RemoteControlManager.m | 19 | ||||
-rw-r--r-- | Example Apps/Example Swift/MenuManager.swift | 10 | ||||
-rw-r--r-- | Example Apps/Example Swift/ProxyManager.swift | 2 | ||||
-rw-r--r-- | Example Apps/Example Swift/RemoteControlManager.swift | 49 | ||||
-rw-r--r-- | Example Apps/Shared/Images.xcassets/remote_control.imageset/Contents.json | 2 | ||||
-rw-r--r-- | Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-1.png | bin | 2146 -> 0 bytes | |||
-rw-r--r-- | Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-2.png | bin | 2146 -> 0 bytes |
10 files changed, 43 insertions, 55 deletions
diff --git a/Example Apps/Example ObjC/MenuManager.m b/Example Apps/Example ObjC/MenuManager.m index be76c1d4b..83894fd89 100644 --- a/Example Apps/Example ObjC/MenuManager.m +++ b/Example Apps/Example ObjC/MenuManager.m @@ -7,6 +7,7 @@ // #import "MenuManager.h" + #import "AlertManager.h" #import "AudioManager.h" #import "AppConstants.h" @@ -93,7 +94,7 @@ NS_ASSUME_NONNULL_BEGIN + (SDLMenuCell *)sdlex_menuCellChangeTemplateWithManager:(SDLManager *)manager { - /// Lets give an example of 2 templates + // Lets give an example of 2 templates NSMutableArray *submenuItems = [NSMutableArray array]; NSString *errorMessage = @"Changing the template failed"; @@ -136,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN return [[SDLMenuCell alloc] initWithTitle:ACSliderMenuName secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:@[ACSliderMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) { SDLSlider *sliderRPC = [[SDLSlider alloc] initWithNumTicks:3 position:1 sliderHeader:@"Select a letter" sliderFooters:@[@"A", @"B", @"C"] timeout:10000]; [manager sendRequest:sliderRPC withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - if(![response.resultCode isEqualToEnum:SDLResultSuccess]) { + if (![response.resultCode isEqualToEnum:SDLResultSuccess]) { if ([response.resultCode isEqualToEnum:SDLResultTimedOut]) { [AlertManager sendAlertWithManager:manager image:nil textField1:AlertSliderTimedOutWarningText textField2:nil]; } else if ([response.resultCode isEqualToEnum:SDLResultAborted]) { @@ -153,7 +154,7 @@ NS_ASSUME_NONNULL_BEGIN return [[SDLMenuCell alloc] initWithTitle:ACScrollableMessageMenuName secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:@[ACScrollableMessageMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) { SDLScrollableMessage *messageRPC = [[SDLScrollableMessage alloc] initWithMessage:@"This is a scrollable message\nIt can contain many lines"]; [manager sendRequest:messageRPC withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - if(![response.resultCode isEqualToEnum:SDLResultSuccess]) { + if (![response.resultCode isEqualToEnum:SDLResultSuccess]) { if ([response.resultCode isEqualToEnum:SDLResultTimedOut]) { [AlertManager sendAlertWithManager:manager image:nil textField1:AlertScrollableMessageTimedOutWarningText textField2:nil]; } else if ([response.resultCode isEqualToEnum:SDLResultAborted]) { @@ -172,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *errorMessage = @"Changing the template failed"; // Climate Control - SDLMenuCell *climateControlCell = [[SDLMenuCell alloc] initWithTitle:ACRemoteControlClimateMenuName secondaryText:nil tertiaryText:nil icon:[SDLArtwork artworkWithImage:[[UIImage imageNamed:RemoteControlIconName] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] asImageFormat:SDLArtworkImageFormatPNG] secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) { + SDLMenuCell *climateControlCell = [[SDLMenuCell alloc] initWithTitle:ACRemoteControlClimateMenuName secondaryText:nil tertiaryText:nil icon: nil secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) { [manager.screenManager changeLayout:[[SDLTemplateConfiguration alloc] initWithPredefinedLayout:SDLPredefinedLayoutTilesOnly] withCompletionHandler:^(NSError * _Nullable error) { if (error != nil) { [AlertManager sendAlertWithManager:manager image:nil textField1:errorMessage textField2:nil]; @@ -198,7 +199,7 @@ NS_ASSUME_NONNULL_BEGIN }]; [submenuItems addObject:viewClimateCell]; - return [[SDLMenuCell alloc] initWithTitle:ACRemoteMenuName secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil submenuLayout:SDLMenuLayoutList subCells:[submenuItems copy]]; + return [[SDLMenuCell alloc] initWithTitle:ACRemoteMenuName secondaryText:nil tertiaryText:nil icon:[SDLArtwork artworkWithImage:[[UIImage imageNamed:RemoteControlIconName] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] asImageFormat:SDLArtworkImageFormatPNG] secondaryArtwork:nil submenuLayout:SDLMenuLayoutList subCells:[submenuItems copy]]; } #pragma mark - Voice Commands diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m index 079215c55..0c8db3b33 100644 --- a/Example Apps/Example ObjC/ProxyManager.m +++ b/Example Apps/Example ObjC/ProxyManager.m @@ -67,11 +67,11 @@ NS_ASSUME_NONNULL_BEGIN return; } - self.remoteControlManager = [[RemoteControlManager alloc] initWithManager:self.sdlManager]; self.vehicleDataManager = [[VehicleDataManager alloc] initWithManager:self.sdlManager refreshUIHandler:self.refreshUIHandler]; self.performManager = [[PerformInteractionManager alloc] initWithManager:self.sdlManager]; self.buttonManager = [[ButtonManager alloc] initWithManager:self.sdlManager refreshUIHandler:self.refreshUIHandler]; self.subscribeButtonManager = [[SubscribeButtonManager alloc] initWithManager:self.sdlManager]; + self.remoteControlManager = [[RemoteControlManager alloc] initWithManager:self.sdlManager andButtons:[self.buttonManager allScreenSoftButtons]]; [weakSelf sdlex_updateProxyState:ProxyStateConnected]; [RPCPermissionsManager setupPermissionsCallbacksWithManager:weakSelf.sdlManager]; diff --git a/Example Apps/Example ObjC/RemoteControlManager.h b/Example Apps/Example ObjC/RemoteControlManager.h index 6b6d6af50..382b19bcd 100644 --- a/Example Apps/Example ObjC/RemoteControlManager.h +++ b/Example Apps/Example ObjC/RemoteControlManager.h @@ -9,6 +9,7 @@ #import <Foundation/Foundation.h> @class SDLManager; +@class SDLSoftButtonObject; NS_ASSUME_NONNULL_BEGIN @@ -17,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @property (copy, nonatomic, readonly) NSString *climateDataString; - (instancetype)init NS_UNAVAILABLE; -- (instancetype)initWithManager:(SDLManager *)manager; +- (instancetype)initWithManager:(SDLManager *)manager andButtons:(NSArray<SDLSoftButtonObject *> *)buttons; - (void)start; - (void)showClimateControl; diff --git a/Example Apps/Example ObjC/RemoteControlManager.m b/Example Apps/Example ObjC/RemoteControlManager.m index 9ddc6e1e5..212bb2cc7 100644 --- a/Example Apps/Example ObjC/RemoteControlManager.m +++ b/Example Apps/Example ObjC/RemoteControlManager.m @@ -14,6 +14,7 @@ @interface RemoteControlManager() @property (strong, nonatomic) SDLManager *sdlManager; +@property (strong, nonatomic) NSArray<SDLSoftButtonObject *> *homeButtons; @property (strong, nonatomic) SDLRemoteControlCapabilities *remoteControlCapabilities; @property (strong, nonatomic) NSString *climateModuleId; @property (strong, nonatomic) NSNumber<SDLBool> *hasConsent; @@ -25,12 +26,13 @@ @implementation RemoteControlManager -- (instancetype)initWithManager:(SDLManager *)manager { +- (instancetype)initWithManager:(SDLManager *)manager andButtons:(NSArray<SDLSoftButtonObject *> *)buttons { self = [super init]; if (!self) { return nil; } _sdlManager = manager; + _homeButtons = buttons; return self; } @@ -83,6 +85,7 @@ "Defrost Zone: %@\n" "Desired Temperature: %@\n" "Dual Mode: %@\n" + "Fan Speed: %@\n" "Heated Mirrors: %@\n" "Heated Rears Window: %@\n" "Heated Steering: %@\n" @@ -97,6 +100,7 @@ self.climateData.defrostZone, self.climateData.desiredTemperature, self.climateData.dualModeEnable.boolValue ? @"On" : @"Off", + self.climateData.fanSpeed, self.climateData.heatedMirrorsEnable.boolValue ? @"On" : @"Off", self.climateData.heatedRearWindowEnable.boolValue ? @"On" : @"Off", self.climateData.heatedSteeringWheelEnable.boolValue ? @"On" : @"Off", @@ -154,7 +158,7 @@ SDLSetInteriorVehicleData *setInteriorVehicleData = [[SDLSetInteriorVehicleData alloc] initWithModuleData:moduleData]; [self.sdlManager sendRequest:setInteriorVehicleData withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - if(!response.success) { + if (!response.success) { SDLLogE(@"SDL errored trying to turn off climate AC: %@", error); return; } @@ -170,7 +174,7 @@ SDLSetInteriorVehicleData *setInteriorVehicleData = [[SDLSetInteriorVehicleData alloc] initWithModuleData:moduleData]; [self.sdlManager sendRequest:setInteriorVehicleData withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - if(!response.success) { + if (!response.success) { SDLLogE(@"SDL errored trying to set climate temperature to 73 degrees: %@", error); return; } @@ -205,7 +209,7 @@ SDLButtonPress *buttonTouch = [[SDLButtonPress alloc] initWithButtonName:SDLButtonNameTempDown moduleType:SDLModuleTypeClimate moduleId:self.climateModuleId buttonPressMode:SDLButtonPressModeShort]; [self.sdlManager sendRequest:buttonTouch withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - if(!response.success) { + if (!response.success) { SDLLogE(@"SDL errored decreasing target climate temperature with remote button: %@", error); return; } @@ -224,12 +228,13 @@ }]; }]; - SDLSoftButtonObject *setClimateButton = [[SDLSoftButtonObject alloc] initWithName:@"Set Climate" text:@"Set 73 degrees" artwork:nil handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) { + SDLSoftButtonObject *backToHomeButton = [[SDLSoftButtonObject alloc] initWithName:@"Home" text:@"Back to Home" artwork:nil handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) { if (buttonPress == nil) { return; } - [self sdlex_setClimateTemperature]; + self.sdlManager.screenManager.softButtonObjects = self.homeButtons; + [self.sdlManager.screenManager changeLayout:[[SDLTemplateConfiguration alloc] initWithPredefinedLayout:SDLPredefinedLayoutNonMedia] withCompletionHandler:nil]; }]; - return @[acOnButton, acOffButton, acMaxToggle, temperatureDecreaseButton, temperatureIncreaseButton, setClimateButton]; + return @[acOnButton, acOffButton, acMaxToggle, temperatureDecreaseButton, temperatureIncreaseButton, backToHomeButton]; } @end diff --git a/Example Apps/Example Swift/MenuManager.swift b/Example Apps/Example Swift/MenuManager.swift index b5009c521..6cb0a76d1 100644 --- a/Example Apps/Example Swift/MenuManager.swift +++ b/Example Apps/Example Swift/MenuManager.swift @@ -118,11 +118,11 @@ private extension MenuManager { /// - Returns: A SDLMenuCell object class func menuCellChangeTemplate(with manager: SDLManager) -> SDLMenuCell { - /// Lets give an example of 2 templates + // Lets give an example of 2 templates var submenuItems = [SDLMenuCell]() let errorMessage = "Changing the template failed" - /// Non-Media + // Non-Media let submenuTitleNonMedia = "Non - Media (Default)" submenuItems.append(SDLMenuCell(title: submenuTitleNonMedia, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in manager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .nonMedia)) { err in @@ -133,7 +133,7 @@ private extension MenuManager { } })) - /// Graphic with Text + // Graphic with Text let submenuTitleGraphicText = "Graphic With Text" submenuItems.append(SDLMenuCell(title: submenuTitleGraphicText, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in manager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .graphicWithText)) { err in @@ -216,7 +216,7 @@ private extension MenuManager { var submenuItems = [SDLMenuCell]() // Climate Control Menu - submenuItems.append(SDLMenuCell(title: ACRemoteControlClimateMenuName, secondaryText: nil, tertiaryText: nil, icon: SDLArtwork(image: UIImage(named: RemoteControlIconName)!.withRenderingMode(.alwaysTemplate), persistent: true, as: .PNG), secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in + submenuItems.append(SDLMenuCell(title: ACRemoteControlClimateMenuName, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in manager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .tilesOnly)) { err in if let error = err { AlertManager.sendAlert(textField1: error.localizedDescription, sdlManager: manager) @@ -244,7 +244,7 @@ private extension MenuManager { }) })) - return SDLMenuCell(title: ACRemoteMenuName, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, submenuLayout: .list, subCells: submenuItems) + return SDLMenuCell(title: ACRemoteMenuName, secondaryText: nil, tertiaryText: nil, icon: SDLArtwork(image: UIImage(named: RemoteControlIconName)!.withRenderingMode(.alwaysTemplate), persistent: true, as: .PNG), secondaryArtwork: nil, submenuLayout: .list, subCells: submenuItems) } } diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift index 7bdc2c6ee..45ebcd88e 100644 --- a/Example Apps/Example Swift/ProxyManager.swift +++ b/Example Apps/Example Swift/ProxyManager.swift @@ -138,7 +138,7 @@ private extension ProxyManager { self.subscribeButtonManager = SubscribeButtonManager(sdlManager: self.sdlManager) self.vehicleDataManager = VehicleDataManager(sdlManager: self.sdlManager, refreshUIHandler: self.refreshUIHandler) self.performInteractionManager = PerformInteractionManager(sdlManager: self.sdlManager) - self.remoteControlManager = RemoteControlManager(sdlManager: self.sdlManager) + self.remoteControlManager = RemoteControlManager(sdlManager: self.sdlManager, homeButtons: self.buttonManager.allScreenSoftButtons()) RPCPermissionsManager.setupPermissionsCallbacks(with: self.sdlManager) diff --git a/Example Apps/Example Swift/RemoteControlManager.swift b/Example Apps/Example Swift/RemoteControlManager.swift index 85002166c..98f3e0cc7 100644 --- a/Example Apps/Example Swift/RemoteControlManager.swift +++ b/Example Apps/Example Swift/RemoteControlManager.swift @@ -12,6 +12,7 @@ import SmartDeviceLinkSwift class RemoteControlManager { private let sdlManager: SDLManager + private let homeButtons: [SDLSoftButtonObject] private var remoteControlCapabilities: SDLRemoteControlCapabilities? private var climateModuleId: String? private var hasConsent: Bool? @@ -35,18 +36,20 @@ class RemoteControlManager { Heated Windshield: \(optionalNumberBoolToString(climateData?.heatedWindshieldEnable)) Ventilation: \(optionalSDLEnumToString(climateData?.ventilationMode?.rawValue)) """ - } } - /// Creates and returns the menu items + /// Initialize the RemoteControlManager Object /// - /// - Parameter sdlManager: The SDL Manager - init(sdlManager: SDLManager) { + /// - Parameters: + /// - sdlManager: The SDL Manager. + /// - homeButton: An array of SDLSoftButtonObjects that remote control manager can reset to. + init(sdlManager: SDLManager, homeButtons: [SDLSoftButtonObject]) { self.sdlManager = sdlManager + self.homeButtons = homeButtons } func start() { - /// Retrieve remote control information and store module ids + // Retrieve remote control information and store module ids self.sdlManager.systemCapabilityManager.subscribe(capabilityType: .remoteControl) { (capability, subscribed, error) in guard capability?.remoteControlCapability != nil else { SDLLog.e("SDL errored getting remote control module information: \(String(describing: error))") @@ -58,7 +61,7 @@ class RemoteControlManager { let moduleId = firstClimateModule?.moduleInfo?.moduleId self.climateModuleId = moduleId - /// Get Consent to control module + // Get Consent to control module let getInteriorVehicleDataConsent = SDLGetInteriorVehicleDataConsent(moduleType: .climate, moduleIds: [self.climateModuleId!]) self.sdlManager.send(request: getInteriorVehicleDataConsent, responseHandler: { (request, response, error) in guard let response = response as? SDLGetInteriorVehicleDataConsentResponse else { @@ -80,7 +83,7 @@ class RemoteControlManager { /// Displays Buttons for the user to control the climate func showClimateControl() { - /// Check that the climate module id has been set and consent has been given + // Check that the climate module id has been set and consent has been given guard climateModuleId != nil && hasConsent == true else { AlertManager.sendAlert(textField1: "The climate module id was not set or consent was not given", sdlManager: self.sdlManager) return @@ -109,7 +112,7 @@ class RemoteControlManager { } private func initializeClimateData() { - /// Check that the climate module id has been set and consent has been given + // Check that the climate module id has been set and consent has been given guard climateModuleId != nil && hasConsent == true else { AlertManager.sendAlert(textField1: "The climate module id was not set or consent was not given", sdlManager: self.sdlManager) return @@ -170,28 +173,7 @@ class RemoteControlManager { } } - /// Changes multiple climate variables at once - private func setClimateTemperature() { - let climateDictionary: [String: Any] = [ - "acEnable": true, - "fanSpeed": 100, - "desiredTemperature": SDLTemperature(fahrenheitValue: 73), - "ventilationMode": SDLVentilationMode.both.rawValue - ] - - let climateControlData = SDLClimateControlData(dictionary: climateDictionary) - let moduleData = SDLModuleData(climateControlData: climateControlData) - let setInteriorVehicleData = SDLSetInteriorVehicleData(moduleData: moduleData) - - self.sdlManager.send(request: setInteriorVehicleData) { (request, response, error) in - guard response?.success.boolValue == true else { - SDLLog.e("SDL errored trying to set climate temperature to 73 degrees: \(String(describing: error))") - return - } - } - } - - /// An array of button objects to control the climate + // An array of button objects to control the climate private var climateButtons : [SDLSoftButtonObject] { let acOnButton = SDLSoftButtonObject(name: "AC On", text: "AC On", artwork: nil) { (buttonPress, buttonEvent) in guard buttonPress != nil else { return } @@ -236,11 +218,12 @@ class RemoteControlManager { } } - let setClimateButton = SDLSoftButtonObject(name: "Set Climate", text: "Set 73 degrees", artwork: nil) { (buttonPress, buttonEvent) in + let backToHomeButton = SDLSoftButtonObject(name: "Home", text: "Back to Home", artwork: nil) { (buttonPress, buttonEvent) in guard buttonPress != nil else { return } - self.setClimateTemperature() + self.sdlManager.screenManager.softButtonObjects = self.homeButtons + self.sdlManager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .nonMedia)) } - return [acOnButton, acOffButton, acMaxToggle, temperatureDecreaseButton, temperatureIncreaseButton, setClimateButton] + return [acOnButton, acOffButton, acMaxToggle, temperatureDecreaseButton, temperatureIncreaseButton, backToHomeButton] } } diff --git a/Example Apps/Shared/Images.xcassets/remote_control.imageset/Contents.json b/Example Apps/Shared/Images.xcassets/remote_control.imageset/Contents.json index ed0a33e55..bbc03879b 100644 --- a/Example Apps/Shared/Images.xcassets/remote_control.imageset/Contents.json +++ b/Example Apps/Shared/Images.xcassets/remote_control.imageset/Contents.json @@ -6,12 +6,10 @@ "scale" : "1x" }, { - "filename" : "remote_control_icon-1.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "remote_control_icon-2.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-1.png b/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-1.png Binary files differdeleted file mode 100644 index 95b5dcec5..000000000 --- a/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-1.png +++ /dev/null diff --git a/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-2.png b/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-2.png Binary files differdeleted file mode 100644 index 95b5dcec5..000000000 --- a/Example Apps/Shared/Images.xcassets/remote_control.imageset/remote_control_icon-2.png +++ /dev/null |