diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-11-06 14:45:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 14:45:07 -0500 |
commit | 1c2a043b620ff16e7ca84bd7e51f325bf10e8603 (patch) | |
tree | 1841a03de0e20053201ad4f1c841c18af95022a9 | |
parent | 983819a3e0c30cb96f6a63ed1df2a2c515cacf96 (diff) | |
parent | 3e4c0c5962f3bd8d0b16173d064225ce982fcfc9 (diff) | |
download | sdl_ios-1c2a043b620ff16e7ca84bd7e51f325bf10e8603.tar.gz |
Merge pull request #1786 from smartdevicelink/bugfix/issue-1784-deprecate-autoCompleteText-property-in-SDLKeyboardProperties
deprecate autoCompleteText property in SDLKeyboardProperties
9 files changed, 90 insertions, 24 deletions
diff --git a/SmartDeviceLink/private/SDLChoiceSetManager.m b/SmartDeviceLink/private/SDLChoiceSetManager.m index 80d691b87..a8a0de0e7 100644 --- a/SmartDeviceLink/private/SDLChoiceSetManager.m +++ b/SmartDeviceLink/private/SDLChoiceSetManager.m @@ -502,7 +502,10 @@ UInt16 const ChoiceCellCancelIdMin = 1; _keyboardConfiguration = [self sdl_defaultKeyboardConfiguration]; } else { SDLLogD(@"Updating keyboard configuration to a new configuration: %@", keyboardConfiguration); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" _keyboardConfiguration = [[SDLKeyboardProperties alloc] initWithLanguage:keyboardConfiguration.language layout:keyboardConfiguration.keyboardLayout keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:keyboardConfiguration.limitedCharacterList autoCompleteText:keyboardConfiguration.autoCompleteText autoCompleteList:keyboardConfiguration.autoCompleteList]; +#pragma clang diagnostic pop if (keyboardConfiguration.keypressMode != SDLKeypressModeResendCurrentEntry) { SDLLogW(@"Attempted to set a keyboard configuration with an invalid keypress mode; only .resentCurrentEntry is valid. This value will be ignored, the rest of the properties will be set."); @@ -511,7 +514,7 @@ UInt16 const ChoiceCellCancelIdMin = 1; } - (SDLKeyboardProperties *)sdl_defaultKeyboardConfiguration { - return [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageEnUs layout:SDLKeyboardLayoutQWERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteText:nil autoCompleteList:nil]; + return [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageEnUs keyboardLayout:SDLKeyboardLayoutQWERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteList:nil]; } #pragma mark - Getters diff --git a/SmartDeviceLink/private/SDLPresentChoiceSetOperation.m b/SmartDeviceLink/private/SDLPresentChoiceSetOperation.m index 0788b0b97..f0fbbf28a 100644 --- a/SmartDeviceLink/private/SDLPresentChoiceSetOperation.m +++ b/SmartDeviceLink/private/SDLPresentChoiceSetOperation.m @@ -278,7 +278,10 @@ NS_ASSUME_NONNULL_BEGIN } weakself.keyboardProperties.autoCompleteList = (newList.count > 0) ? newList : @[]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" weakself.keyboardProperties.autoCompleteText = (newList.count > 0) ? newList.firstObject : nil; +#pragma clang diagnostic pop [weakself sdl_updateKeyboardPropertiesWithCompletionHandler:nil]; }]; } diff --git a/SmartDeviceLink/private/SDLPresentKeyboardOperation.m b/SmartDeviceLink/private/SDLPresentKeyboardOperation.m index 633ccfba6..798e046af 100644 --- a/SmartDeviceLink/private/SDLPresentKeyboardOperation.m +++ b/SmartDeviceLink/private/SDLPresentKeyboardOperation.m @@ -192,7 +192,10 @@ NS_ASSUME_NONNULL_BEGIN } weakself.keyboardProperties.autoCompleteList = (newList.count > 0) ? newList : @[]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" weakself.keyboardProperties.autoCompleteText = (newList.count > 0) ? newList.firstObject : nil; +#pragma clang diagnostic pop [weakself sdl_updateKeyboardPropertiesWithCompletionHandler:nil]; }]; } diff --git a/SmartDeviceLink/public/SDLKeyboardProperties.h b/SmartDeviceLink/public/SDLKeyboardProperties.h index 5939d398f..a538b52bd 100644 --- a/SmartDeviceLink/public/SDLKeyboardProperties.h +++ b/SmartDeviceLink/public/SDLKeyboardProperties.h @@ -25,7 +25,19 @@ NS_ASSUME_NONNULL_BEGIN @param autoCompleteList A list of strings to show the user to complete what they are typing. @return The RPC object */ -- (instancetype)initWithLanguage:(nullable SDLLanguage)language layout:(nullable SDLKeyboardLayout)layout keypressMode:(nullable SDLKeypressMode)keypressMode limitedCharacterList:(nullable NSArray<NSString *> *)limitedCharacterList autoCompleteText:(nullable NSString *)autoCompleteText autoCompleteList:(nullable NSArray<NSString *> *)autoCompleteList; +- (instancetype)initWithLanguage:(nullable SDLLanguage)language layout:(nullable SDLKeyboardLayout)layout keypressMode:(nullable SDLKeypressMode)keypressMode limitedCharacterList:(nullable NSArray<NSString *> *)limitedCharacterList autoCompleteText:(nullable NSString *)autoCompleteText autoCompleteList:(nullable NSArray<NSString *> *)autoCompleteList __deprecated_msg("Use initWithLanguage:keyboardLayout:keypressMode:limitedCharacterList:autoCompleteList: instead"); + +/** + * Convenience init with all properties. + * + * @param language - language + * @param keyboardLayout - keyboardLayout + * @param keypressMode - keypressMode + * @param limitedCharacterList - limitedCharacterList + * @param autoCompleteList - autoCompleteList + * @return A SDLKeyboardProperties object + */ +- (instancetype)initWithLanguage:(nullable SDLLanguage)language keyboardLayout:(nullable SDLKeyboardLayout)keyboardLayout keypressMode:(nullable SDLKeypressMode)keypressMode limitedCharacterList:(nullable NSArray<NSString *> *)limitedCharacterList autoCompleteList:(nullable NSArray<NSString *> *)autoCompleteList; /** The keyboard language @@ -58,11 +70,13 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, strong, nonatomic) NSArray<NSString *> *limitedCharacterList; /** - Allows an app to prepopulate the text field with a suggested or completed entry as the user types - - Optional + * Deprecated, use autoCompleteList instead. + * {"string_min_length": 1, "string_max_length": 1000} + * + * @deprecated in SmartDeviceLink 6.0.0 + * @added in SmartDeviceLink 3.0.0 */ -@property (nullable, strong, nonatomic) NSString *autoCompleteText; +@property (nullable, strong, nonatomic) NSString *autoCompleteText __deprecated_msg("Use autoCompleteList instead"); /** Allows an app to show a list of possible autocomplete suggestions as the user types diff --git a/SmartDeviceLink/public/SDLKeyboardProperties.m b/SmartDeviceLink/public/SDLKeyboardProperties.m index 5f6fa82dd..c21c91bc7 100644 --- a/SmartDeviceLink/public/SDLKeyboardProperties.m +++ b/SmartDeviceLink/public/SDLKeyboardProperties.m @@ -11,16 +11,23 @@ NS_ASSUME_NONNULL_BEGIN @implementation SDLKeyboardProperties - (instancetype)initWithLanguage:(nullable SDLLanguage)language layout:(nullable SDLKeyboardLayout)layout keypressMode:(nullable SDLKeypressMode)keypressMode limitedCharacterList:(nullable NSArray<NSString *> *)limitedCharacterList autoCompleteText:(nullable NSString *)autoCompleteText autoCompleteList:(nullable NSArray<NSString *> *)autoCompleteList { + self = [[self init] initWithLanguage:language keyboardLayout:layout keypressMode:keypressMode limitedCharacterList:limitedCharacterList autoCompleteList:autoCompleteList]; + if (!self) { return nil; } + self.autoCompleteText = autoCompleteText; + + return self; +} + +- (instancetype)initWithLanguage:(nullable SDLLanguage)language keyboardLayout:(nullable SDLKeyboardLayout)keyboardLayout keypressMode:(nullable SDLKeypressMode)keypressMode limitedCharacterList:(nullable NSArray<NSString *> *)limitedCharacterList autoCompleteList:(nullable NSArray<NSString *> *)autoCompleteList { self = [self init]; if (!self) { return nil; } self.language = language; - self.keyboardLayout = layout; + self.keyboardLayout = keyboardLayout; self.keypressMode = keypressMode; - self.limitedCharacterList = [limitedCharacterList mutableCopy]; - self.autoCompleteText = autoCompleteText; + self.limitedCharacterList = limitedCharacterList; self.autoCompleteList = autoCompleteList; return self; diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m index 47156d1c0..321a2dde6 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m @@ -105,7 +105,7 @@ describe(@"choice set manager tests", ^{ it(@"should be in the correct startup state", ^{ expect(testManager.currentState).to(equal(SDLChoiceManagerStateShutdown)); - SDLKeyboardProperties *defaultProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageEnUs layout:SDLKeyboardLayoutQWERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteText:nil autoCompleteList:nil]; + SDLKeyboardProperties *defaultProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageEnUs keyboardLayout:SDLKeyboardLayoutQWERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteList:nil]; expect(testManager.keyboardConfiguration).to(equal(defaultProperties)); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentChoiceSetOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentChoiceSetOperationSpec.m index 7ca891608..883720b82 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentChoiceSetOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentChoiceSetOperationSpec.m @@ -60,7 +60,7 @@ describe(@"present choice operation", ^{ testKeyboardDelegate = OCMProtocolMock(@protocol(SDLKeyboardDelegate)); OCMStub([testKeyboardDelegate customKeyboardConfiguration]).andReturn(nil); - testKeyboardProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageArSa layout:SDLKeyboardLayoutAZERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteText:nil autoCompleteList:nil]; + testKeyboardProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageArSa keyboardLayout:SDLKeyboardLayoutAZERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteList:nil]; }); it(@"should have a priority of 'normal'", ^{ @@ -460,7 +460,10 @@ describe(@"present choice operation", ^{ expect(testConnectionManager.receivedRequests.lastObject).to(beAnInstanceOf([SDLSetGlobalProperties class])); SDLSetGlobalProperties *setProperties = testConnectionManager.receivedRequests.lastObject; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" expect(setProperties.keyboardProperties.autoCompleteText).to(equal(inputData)); +#pragma clang diagnostic pop }); it(@"should respond to text input notification with character set", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m index 08424949d..29ed6d0b0 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m @@ -43,7 +43,7 @@ describe(@"present keyboard operation", ^{ testDelegate = OCMProtocolMock(@protocol(SDLKeyboardDelegate)); OCMStub([testDelegate customKeyboardConfiguration]).andReturn(nil); - testInitialProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageArSa layout:SDLKeyboardLayoutAZERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteText:nil autoCompleteList:nil]; + testInitialProperties = [[SDLKeyboardProperties alloc] initWithLanguage:SDLLanguageArSa keyboardLayout:SDLKeyboardLayoutAZERTY keypressMode:SDLKeypressModeResendCurrentEntry limitedCharacterList:nil autoCompleteList:nil]; }); it(@"should have a priority of 'normal'", ^{ @@ -194,7 +194,10 @@ describe(@"present keyboard operation", ^{ expect(testConnectionManager.receivedRequests.lastObject).to(beAnInstanceOf([SDLSetGlobalProperties class])); SDLSetGlobalProperties *setProperties = testConnectionManager.receivedRequests.lastObject; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" expect(setProperties.keyboardProperties.autoCompleteText).to(equal(inputData)); +#pragma clang diagnostic pop }); it(@"should respond to text input notification with character set", ^{ diff --git a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m index 7b1e28362..b1f15a63f 100644 --- a/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m @@ -32,45 +32,72 @@ describe(@"Getter/Setter Tests", ^ { testStruct.keyboardLayout = testLayout; testStruct.keypressMode = testMode; testStruct.limitedCharacterList = testLimitedCharacterList; - testStruct.autoCompleteText = testAutoCompleteText; testStruct.autoCompleteList = testAutoCompleteList; - +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + testStruct.autoCompleteText = testAutoCompleteText; +#pragma clang diagnostic pop + expect(testStruct.language).to(equal(testLanguage)); expect(testStruct.keyboardLayout).to(equal(testLayout)); expect(testStruct.keypressMode).to(equal(testMode)); expect(testStruct.limitedCharacterList).to(equal(testLimitedCharacterList)); - expect(testStruct.autoCompleteText).to(equal(testAutoCompleteText)); expect(testStruct.autoCompleteList).to(equal(testAutoCompleteList)); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + expect(testStruct.autoCompleteText).to(equal(testAutoCompleteText)); +#pragma clang diagnostic pop }); it(@"Should get correctly when initialized with a dictionary", ^ { NSDictionary* dict = @{SDLRPCParameterNameLanguage: testLanguage, - SDLRPCParameterNameKeyboardLayout: testLayout, - SDLRPCParameterNameKeypressMode: testMode, - SDLRPCParameterNameLimitedCharacterList: testLimitedCharacterList, - SDLRPCParameterNameAutoCompleteText: testAutoCompleteText, - SDLRPCParameterNameAutoCompleteList: testAutoCompleteList - }; + SDLRPCParameterNameKeyboardLayout: testLayout, + SDLRPCParameterNameKeypressMode: testMode, + SDLRPCParameterNameLimitedCharacterList: testLimitedCharacterList, + SDLRPCParameterNameAutoCompleteList: testAutoCompleteList, + SDLRPCParameterNameAutoCompleteText: testAutoCompleteText + }; SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] initWithDictionary:dict]; expect(testStruct.language).to(equal(testLanguage)); expect(testStruct.keyboardLayout).to(equal(testLayout)); expect(testStruct.keypressMode).to(equal(testMode)); expect(testStruct.limitedCharacterList).to(equal(testLimitedCharacterList)); - expect(testStruct.autoCompleteText).to(equal(testAutoCompleteText)); expect(testStruct.autoCompleteList).to(equal(testAutoCompleteList)); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + expect(testStruct.autoCompleteText).to(equal(testAutoCompleteText)); +#pragma clang diagnostic pop }); it(@"Should get correctly when initialized with initWithLanguage:layout:keypressMode:limitedCharacterList:autoCompleteText:autoCompleteList:", ^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLKeyboardProperties *testStruct = [[SDLKeyboardProperties alloc] initWithLanguage:testLanguage layout:testLayout keypressMode:testMode limitedCharacterList:testLimitedCharacterList autoCompleteText:testAutoCompleteText autoCompleteList:testAutoCompleteList]; - +#pragma clang diagnostic pop expect(testStruct.language).to(equal(testLanguage)); expect(testStruct.keyboardLayout).to(equal(testLayout)); expect(testStruct.keypressMode).to(equal(testMode)); expect(testStruct.limitedCharacterList).to(equal(testLimitedCharacterList)); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" expect(testStruct.autoCompleteText).to(equal(testAutoCompleteText)); +#pragma clang diagnostic pop expect(testStruct.autoCompleteList).to(equal(testAutoCompleteList)); }); + + it(@"Should get correctly when initialized with initWithLanguage:keyboardLayout:keypressMode:limitedCharacterList:autoCompleteList:", ^ { + SDLKeyboardProperties *testStruct = [[SDLKeyboardProperties alloc] initWithLanguage:testLanguage keyboardLayout:testLayout keypressMode:testMode limitedCharacterList:testLimitedCharacterList autoCompleteList:testAutoCompleteList]; + expect(testStruct.language).to(equal(testLanguage)); + expect(testStruct.keyboardLayout).to(equal(testLayout)); + expect(testStruct.keypressMode).to(equal(testMode)); + expect(testStruct.limitedCharacterList).to(equal(testLimitedCharacterList)); + expect(testStruct.autoCompleteList).to(equal(testAutoCompleteList)); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + expect(testStruct.autoCompleteText).to(beNil()); +#pragma clang diagnostic pop + }); it(@"Should return nil if not set", ^ { SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] init]; @@ -79,8 +106,11 @@ describe(@"Getter/Setter Tests", ^ { expect(testStruct.keyboardLayout).to(beNil()); expect(testStruct.keypressMode).to(beNil()); expect(testStruct.limitedCharacterList).to(beNil()); - expect(testStruct.autoCompleteText).to(beNil()); expect(testStruct.autoCompleteList).to(beNil()); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + expect(testStruct.autoCompleteText).to(beNil()); +#pragma clang diagnostic pop }); }); |