diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2019-07-11 15:20:39 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2019-07-11 15:20:39 -0400 |
commit | ba116feaf4951565aaf9626f978027eecb7e9b49 (patch) | |
tree | 2429e2a3d87ff9b7719a713bdf3c7fe4d7c24237 | |
parent | c819c439e04590f58398db7cf051156603f98e1b (diff) | |
download | sdl_ios-ba116feaf4951565aaf9626f978027eecb7e9b49.tar.gz |
Implement SDL-0177 Alert Icon
-rw-r--r-- | SmartDeviceLink/SDLAlert.h | 7 | ||||
-rw-r--r-- | SmartDeviceLink/SDLAlert.m | 9 | ||||
-rw-r--r-- | SmartDeviceLink/SDLImageFieldName.h | 5 | ||||
-rw-r--r-- | SmartDeviceLink/SDLImageFieldName.m | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCParameterNames.h | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRPCParameterNames.m | 1 | ||||
-rw-r--r-- | SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m | 63 |
7 files changed, 61 insertions, 26 deletions
diff --git a/SmartDeviceLink/SDLAlert.h b/SmartDeviceLink/SDLAlert.h index b888deb6a..082dd7124 100644 --- a/SmartDeviceLink/SDLAlert.h +++ b/SmartDeviceLink/SDLAlert.h @@ -4,6 +4,7 @@ #import "SDLRPCRequest.h" +@class SDLImage; @class SDLSoftButton; @class SDLTTSChunk; @@ -154,6 +155,12 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nullable, strong, nonatomic) NSArray<SDLSoftButton *> *softButtons; +/** + Image struct determining whether static or dynamic icon. + If omitted on supported displays, no (or the default if applicable) icon should be displayed. + */ +@property (nullable, strong, nonatomic) SDLImage *alertIcon; + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLAlert.m b/SmartDeviceLink/SDLAlert.m index 120ed6fe7..6d708ab56 100644 --- a/SmartDeviceLink/SDLAlert.m +++ b/SmartDeviceLink/SDLAlert.m @@ -3,6 +3,7 @@ #import "SDLAlert.h" #import "NSMutableDictionary+Store.h" +#import "SDLImage.h" #import "SDLRPCParameterNames.h" #import "SDLRPCFunctionNames.h" #import "SDLSoftButton.h" @@ -141,6 +142,14 @@ NS_ASSUME_NONNULL_BEGIN return [self.parameters sdl_objectsForName:SDLRPCParameterNameSoftButtons ofClass:SDLSoftButton.class error:nil]; } +- (void)setAlertIcon:(nullable SDLImage *)alertIcon { + [self.parameters setObject:alertIcon forKey:SDLRPCParameterNameAlertIcon]; +} + +- (nullable SDLImage *)alertIcon { + return [self.parameters sdl_objectForName:SDLRPCParameterNameAlertIcon ofClass:SDLImage.class error:nil]; +} + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLImageFieldName.h b/SmartDeviceLink/SDLImageFieldName.h index 34e50c3b3..cd3e101c9 100644 --- a/SmartDeviceLink/SDLImageFieldName.h +++ b/SmartDeviceLink/SDLImageFieldName.h @@ -12,6 +12,11 @@ typedef SDLEnum SDLImageFieldName SDL_SWIFT_ENUM; /** + The image field for Alert + */ +extern SDLImageFieldName const SDLImageFieldNameAlertIcon; + +/** The image field for SoftButton */ extern SDLImageFieldName const SDLImageFieldNameSoftButtonImage; diff --git a/SmartDeviceLink/SDLImageFieldName.m b/SmartDeviceLink/SDLImageFieldName.m index 63397b089..0282f25b6 100644 --- a/SmartDeviceLink/SDLImageFieldName.m +++ b/SmartDeviceLink/SDLImageFieldName.m @@ -4,6 +4,7 @@ #import "SDLImageFieldName.h" +SDLImageFieldName const SDLImageFieldNameAlertIcon = @"alertIcon"; SDLImageFieldName const SDLImageFieldNameSoftButtonImage = @"softButtonImage"; SDLImageFieldName const SDLImageFieldNameChoiceImage = @"choiceImage"; SDLImageFieldName const SDLImageFieldNameChoiceSecondaryImage = @"choiceSecondaryImage"; diff --git a/SmartDeviceLink/SDLRPCParameterNames.h b/SmartDeviceLink/SDLRPCParameterNames.h index 6e346e357..f3b2161d9 100644 --- a/SmartDeviceLink/SDLRPCParameterNames.h +++ b/SmartDeviceLink/SDLRPCParameterNames.h @@ -20,6 +20,7 @@ extern SDLRPCParameterName const SDLRPCParameterNameAddress; extern SDLRPCParameterName const SDLRPCParameterNameAddressLines; extern SDLRPCParameterName const SDLRPCParameterNameAdministrativeArea; extern SDLRPCParameterName const SDLRPCParameterNameAirbagStatus; +extern SDLRPCParameterName const SDLRPCParameterNameAlertIcon; extern SDLRPCParameterName const SDLRPCParameterNameAlerts; extern SDLRPCParameterName const SDLRPCParameterNameAlertText1; extern SDLRPCParameterName const SDLRPCParameterNameAlertText2; diff --git a/SmartDeviceLink/SDLRPCParameterNames.m b/SmartDeviceLink/SDLRPCParameterNames.m index 0aae8440d..2dc826eba 100644 --- a/SmartDeviceLink/SDLRPCParameterNames.m +++ b/SmartDeviceLink/SDLRPCParameterNames.m @@ -18,6 +18,7 @@ SDLRPCParameterName const SDLRPCParameterNameAddress = @"address"; SDLRPCParameterName const SDLRPCParameterNameAddressLines = @"addressLines"; SDLRPCParameterName const SDLRPCParameterNameAdministrativeArea = @"administrativeArea"; SDLRPCParameterName const SDLRPCParameterNameAirbagStatus = @"airbagStatus"; +SDLRPCParameterName const SDLRPCParameterNameAlertIcon = @"alertIcon"; SDLRPCParameterName const SDLRPCParameterNameAlerts = @"alerts"; SDLRPCParameterName const SDLRPCParameterNameAlertText1 = @"alertText1"; SDLRPCParameterName const SDLRPCParameterNameAlertText2 = @"alertText2"; diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m index 27d853822..d3571a08a 100644 --- a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLAlertSpec.m @@ -9,6 +9,7 @@ #import <Nimble/Nimble.h> #import "SDLAlert.h" +#import "SDLImage.h" #import "SDLTTSChunk.h" #import "SDLSoftButton.h" #import "SDLRPCParameterNames.h" @@ -16,8 +17,9 @@ QuickSpecBegin(SDLAlertSpec) -SDLTTSChunk* tts = [[SDLTTSChunk alloc] init]; -SDLSoftButton* button = [[SDLSoftButton alloc] init]; +SDLTTSChunk *tts = [[SDLTTSChunk alloc] init]; +SDLSoftButton *button = [[SDLSoftButton alloc] init]; +SDLImage *testImage = [[SDLImage alloc] init]; describe(@"Getter/Setter Tests", ^ { it(@"Should set and get correctly", ^ { @@ -26,34 +28,40 @@ describe(@"Getter/Setter Tests", ^ { testRequest.alertText1 = @"alert#1"; testRequest.alertText2 = @"alert#2"; testRequest.alertText3 = @"alert#3"; - testRequest.ttsChunks = [@[tts] mutableCopy]; + testRequest.ttsChunks = @[tts]; testRequest.duration = @4357; testRequest.playTone = @YES; testRequest.progressIndicator = @NO; - testRequest.softButtons = [@[button] mutableCopy]; + testRequest.softButtons = @[button]; + testRequest.alertIcon = testImage; expect(testRequest.alertText1).to(equal(@"alert#1")); expect(testRequest.alertText2).to(equal(@"alert#2")); expect(testRequest.alertText3).to(equal(@"alert#3")); - expect(testRequest.ttsChunks).to(equal([@[tts] mutableCopy])); + expect(testRequest.ttsChunks).to(equal(@[tts])); expect(testRequest.duration).to(equal(@4357)); expect(testRequest.playTone).to(equal(@YES)); expect(testRequest.progressIndicator).to(equal(@NO)); - expect(testRequest.softButtons).to(equal([@[button] mutableCopy])); + expect(testRequest.softButtons).to(equal(@[button])); + expect(testRequest.alertIcon).to(equal(testImage)); }); it(@"Should get correctly when initialized", ^ { - NSMutableDictionary<NSString *, id> *dict = [@{SDLRPCParameterNameRequest: + NSMutableDictionary<NSString *, id> *dict = @{SDLRPCParameterNameRequest: @{SDLRPCParameterNameParameters: - @{SDLRPCParameterNameAlertText1:@"alert#1", - SDLRPCParameterNameAlertText2:@"alert#2", - SDLRPCParameterNameAlertText3:@"alert#3", - SDLRPCParameterNameTTSChunks:[@[tts] mutableCopy], - SDLRPCParameterNameDuration:@4357, - SDLRPCParameterNamePlayTone:@YES, - SDLRPCParameterNameProgressIndicator:@NO, - SDLRPCParameterNameSoftButtons:[@[button] mutableCopy]}, - SDLRPCParameterNameOperationName:SDLRPCFunctionNameAlert}} mutableCopy]; + @{SDLRPCParameterNameAlertText1: @"alert#1", + SDLRPCParameterNameAlertText2: @"alert#2", + SDLRPCParameterNameAlertText3: @"alert#3", + SDLRPCParameterNameTTSChunks: @[tts], + SDLRPCParameterNameDuration: @4357, + SDLRPCParameterNamePlayTone: @YES, + SDLRPCParameterNameProgressIndicator: @NO, + SDLRPCParameterNameSoftButtons: @[button], + SDLRPCParameterNameAlertIcon: testImage + }, + SDLRPCParameterNameOperationName: SDLRPCFunctionNameAlert + } + }; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLAlert* testRequest = [[SDLAlert alloc] initWithDictionary:dict]; @@ -70,17 +78,20 @@ describe(@"Getter/Setter Tests", ^ { }); it(@"Should handle NSNull", ^{ - NSMutableDictionary* dict = [@{SDLRPCParameterNameRequest: + NSMutableDictionary* dict = @{SDLRPCParameterNameRequest: @{SDLRPCParameterNameParameters: - @{SDLRPCParameterNameAlertText1:@"alert#1", - SDLRPCParameterNameAlertText2:@"alert#2", - SDLRPCParameterNameAlertText3:@"alert#3", - SDLRPCParameterNameTTSChunks:[@[tts] mutableCopy], - SDLRPCParameterNameDuration:@4357, - SDLRPCParameterNamePlayTone:@YES, - SDLRPCParameterNameProgressIndicator:@NO, - SDLRPCParameterNameSoftButtons:[NSNull null]}, - SDLRPCParameterNameOperationName:SDLRPCFunctionNameAlert}} mutableCopy]; + @{SDLRPCParameterNameAlertText1: @"alert#1", + SDLRPCParameterNameAlertText2: @"alert#2", + SDLRPCParameterNameAlertText3: @"alert#3", + SDLRPCParameterNameTTSChunks: @[tts], + SDLRPCParameterNameDuration: @4357, + SDLRPCParameterNamePlayTone: @YES, + SDLRPCParameterNameProgressIndicator: @NO, + SDLRPCParameterNameSoftButtons: [NSNull null], + SDLRPCParameterNameAlertIcon: testImage + }, + SDLRPCParameterNameOperationName:SDLRPCFunctionNameAlert} + }; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLAlert* testRequest = [[SDLAlert alloc] initWithDictionary:dict]; |