Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate autoCompleteText property in SDLKeyboardProperties #1786

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SmartDeviceLink/private/SDLChoiceSetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ - (void)setKeyboardConfiguration:(nullable SDLKeyboardProperties *)keyboardConfi
_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.");
Expand All @@ -511,7 +514,7 @@ - (void)setKeyboardConfiguration:(nullable SDLKeyboardProperties *)keyboardConfi
}

- (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
Expand Down
3 changes: 3 additions & 0 deletions SmartDeviceLink/private/SDLPresentChoiceSetOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ - (void)sdl_keyboardInputNotification:(SDLRPCNotificationNotification *)notifica
}

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];
}];
}
Expand Down
3 changes: 3 additions & 0 deletions SmartDeviceLink/private/SDLPresentKeyboardOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ - (void)sdl_keyboardInputNotification:(SDLRPCNotificationNotification *)notifica
}

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];
}];
}
Expand Down
24 changes: 19 additions & 5 deletions SmartDeviceLink/public/SDLKeyboardProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions SmartDeviceLink/public/SDLKeyboardProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@
@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;
Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (void)sdl_displayCapabilityDidUpdate:(SDLSystemCapability *)systemCapability;
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));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ @interface SDLChoiceSet()

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'", ^{
Expand Down Expand Up @@ -460,7 +460,10 @@ @interface SDLChoiceSet()
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", ^{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
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'", ^{
Expand Down Expand Up @@ -194,7 +194,10 @@
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", ^{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,72 @@
testStruct.keyboardLayout = testLayout;
testStruct.keypressMode = testMode;
NicoleYarroch marked this conversation as resolved.
Show resolved Hide resolved
testStruct.limitedCharacterList = testLimitedCharacterList;
testStruct.autoCompleteText = testAutoCompleteText;
NicoleYarroch marked this conversation as resolved.
Show resolved Hide resolved
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];
Expand All @@ -79,8 +106,11 @@
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
});
});

Expand Down