summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-07-29 15:22:19 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-07-29 15:22:19 -0400
commitacfd18bb67b8f15c124dbe694e4d08ab7ee8f811 (patch)
tree2bcb889c122477e6be28f8c3865f7b018e642399
parent03b2b9b4a8470ba41ce5ec70c809a9ff842f8c09 (diff)
downloadsdl_ios-feature/issue_790_autocompletelist.tar.gz
Review fixes for autocomplete listfeature/issue_790_autocompletelist
-rw-r--r--SmartDeviceLink/SDLKeyboardDelegate.h10
-rw-r--r--SmartDeviceLink/SDLKeyboardProperties.h2
-rw-r--r--SmartDeviceLink/SDLPresentChoiceSetOperation.m11
-rw-r--r--SmartDeviceLink/SDLPresentKeyboardOperation.m11
4 files changed, 28 insertions, 6 deletions
diff --git a/SmartDeviceLink/SDLKeyboardDelegate.h b/SmartDeviceLink/SDLKeyboardDelegate.h
index 7eaa3633c..4af085ab4 100644
--- a/SmartDeviceLink/SDLKeyboardDelegate.h
+++ b/SmartDeviceLink/SDLKeyboardDelegate.h
@@ -24,7 +24,7 @@ typedef void(^SDLKeyboardAutocompleteCompletionHandler)(NSString *_Nullable upd
/**
This handler is called when you wish to update your autocomplete text in response to the user's input.
- @param updatedAutoCompleteList The list of autocomplete results to use
+ @param updatedAutoCompleteList The list of autocomplete results to use, a max of 100 items are allowed
*/
typedef void(^SDLKeyboardAutoCompleteResultsHandler)(NSArray<NSString *> *_Nullable updatedAutoCompleteList);
@@ -74,6 +74,14 @@ typedef void(^SDLKeyboardCharacterSetCompletionHandler)(NSArray<NSString *> *_Nu
*/
- (void)updateAutocompleteWithInput:(NSString *)currentInputText completionHandler:(SDLKeyboardAutocompleteCompletionHandler)completionHandler __deprecated_msg("Use updateAutocompleteWithInput:autoCompleteResultsHandler:");
+/**
+ Implement this if you wish to updated the KeyboardProperties.autoCompleteList as the user updates their input. This is called upon a KEYPRESS event.
+
+ This allows you to present a list of options that the user can use to fill in the search / text box with suggestions you provide.
+
+ @param currentInputText The user's full current input text
+ @param resultsHandler A completion handler to update the autoCompleteList
+ */
- (void)updateAutocompleteWithInput:(NSString *)currentInputText autoCompleteResultsHandler:(SDLKeyboardAutoCompleteResultsHandler)resultsHandler;
/**
diff --git a/SmartDeviceLink/SDLKeyboardProperties.h b/SmartDeviceLink/SDLKeyboardProperties.h
index d80f16585..19b494eb2 100644
--- a/SmartDeviceLink/SDLKeyboardProperties.h
+++ b/SmartDeviceLink/SDLKeyboardProperties.h
@@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Allows an app to show a list of possible autocomplete suggestions as the user types
- Optional, 1-100 items
+ Optional, 1-100 items, max string length 1000 characters (note that these may not all be displayed on the screen)
*/
@property (nullable, strong, nonatomic) NSArray<NSString *> *autoCompleteList;
diff --git a/SmartDeviceLink/SDLPresentChoiceSetOperation.m b/SmartDeviceLink/SDLPresentChoiceSetOperation.m
index feab819ca..02faf5fd5 100644
--- a/SmartDeviceLink/SDLPresentChoiceSetOperation.m
+++ b/SmartDeviceLink/SDLPresentChoiceSetOperation.m
@@ -215,8 +215,15 @@ NS_ASSUME_NONNULL_BEGIN
// Notify of keypress
if ([self.keyboardDelegate respondsToSelector:@selector(updateAutocompleteWithInput:autoCompleteResultsHandler:)]) {
[self.keyboardDelegate updateAutocompleteWithInput:onKeyboard.data autoCompleteResultsHandler:^(NSArray<NSString *> * _Nullable updatedAutoCompleteList) {
- weakself.keyboardProperties.autoCompleteList = (updatedAutoCompleteList.count > 0) ? updatedAutoCompleteList : nil;
- weakself.keyboardProperties.autoCompleteText = (updatedAutoCompleteList.count > 0) ? updatedAutoCompleteList.firstObject : nil;
+ NSArray<NSString *> *newList = nil;
+ if (updatedAutoCompleteList.count > 100) {
+ newList = [updatedAutoCompleteList subarrayWithRange:NSMakeRange(0, 100)];
+ } else {
+ newList = updatedAutoCompleteList;
+ }
+
+ weakself.keyboardProperties.autoCompleteList = (newList.count > 0) ? newList : nil;
+ weakself.keyboardProperties.autoCompleteText = (newList.count > 0) ? newList.firstObject : nil;
[weakself sdl_updateKeyboardPropertiesWithCompletionHandler:nil];
}];
} else if ([self.keyboardDelegate respondsToSelector:@selector(updateAutocompleteWithInput:completionHandler:)]) {
diff --git a/SmartDeviceLink/SDLPresentKeyboardOperation.m b/SmartDeviceLink/SDLPresentKeyboardOperation.m
index 301c834d5..1598a9fd3 100644
--- a/SmartDeviceLink/SDLPresentKeyboardOperation.m
+++ b/SmartDeviceLink/SDLPresentKeyboardOperation.m
@@ -145,8 +145,15 @@ NS_ASSUME_NONNULL_BEGIN
// Notify of keypress
if ([self.keyboardDelegate respondsToSelector:@selector(updateAutocompleteWithInput:autoCompleteResultsHandler:)]) {
[self.keyboardDelegate updateAutocompleteWithInput:onKeyboard.data autoCompleteResultsHandler:^(NSArray<NSString *> * _Nullable updatedAutoCompleteList) {
- weakself.keyboardProperties.autoCompleteList = (updatedAutoCompleteList.count > 0) ? updatedAutoCompleteList : nil;
- weakself.keyboardProperties.autoCompleteText = (updatedAutoCompleteList.count > 0) ? updatedAutoCompleteList.firstObject : nil;
+ NSArray<NSString *> *newList = nil;
+ if (updatedAutoCompleteList.count > 100) {
+ newList = [updatedAutoCompleteList subarrayWithRange:NSMakeRange(0, 100)];
+ } else {
+ newList = updatedAutoCompleteList;
+ }
+
+ weakself.keyboardProperties.autoCompleteList = (newList.count > 0) ? newList : nil;
+ weakself.keyboardProperties.autoCompleteText = (newList.count > 0) ? newList.firstObject : nil;
[weakself sdl_updateKeyboardPropertiesWithCompletionHandler:nil];
}];
} else if ([self.keyboardDelegate respondsToSelector:@selector(updateAutocompleteWithInput:completionHandler:)]) {