diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-06-14 09:44:13 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-06-14 09:44:13 -0400 |
commit | 46f8c2751a2b271c660e79254d2012b9287e2d75 (patch) | |
tree | 6b831f5f2a70cdb3bf81d457930d99b2a1abbd67 | |
parent | d1711aff0e9697d832b4240516e04b6cf0c8767f (diff) | |
download | sdl_android-46f8c2751a2b271c660e79254d2012b9287e2d75.tar.gz |
first set of review fixes
3 files changed, 22 insertions, 16 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 207897f69..cc33bae86 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -431,7 +431,7 @@ abstract class BaseScreenManager extends BaseSubManager { * Deletes choices that were sent previously * @param choices - A list of ChoiceCell objects */ - public void deleteChoices(List<ChoiceCell> choices){ + public void deleteChoices(@NonNull List<ChoiceCell> choices){ this.choiceSetManager.deleteChoices(choices); } @@ -440,7 +440,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @param choices - a list of ChoiceCell objects that will be part of a choice set later * @param listener - a completion listener to inform when the operation is complete */ - public void preloadChoices(List<ChoiceCell> choices, CompletionListener listener){ + public void preloadChoices(@NonNull List<ChoiceCell> choices, CompletionListener listener){ this.choiceSetManager.preloadChoices(choices, listener); } @@ -450,7 +450,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @param mode - The intended interaction mode * @param keyboardListener - A keyboard listener to capture user input */ - public void presentSearchableChoiceSet(ChoiceSet choiceSet, InteractionMode mode, KeyboardListener keyboardListener){ + public void presentSearchableChoiceSet(@NonNull ChoiceSet choiceSet, @Nullable InteractionMode mode, @NonNull KeyboardListener keyboardListener){ this.choiceSetManager.presentChoiceSet(choiceSet, mode, keyboardListener); } @@ -459,7 +459,7 @@ abstract class BaseScreenManager extends BaseSubManager { * @param choiceSet - The choice set to be presented. This can include Choice Cells that were preloaded or not * @param mode - The intended interaction mode */ - public void presentChoiceSet(ChoiceSet choiceSet, InteractionMode mode){ + public void presentChoiceSet(@NonNull ChoiceSet choiceSet, @Nullable InteractionMode mode){ this.choiceSetManager.presentChoiceSet(choiceSet, mode, null); } @@ -469,15 +469,15 @@ abstract class BaseScreenManager extends BaseSubManager { * @param customKeyboardProperties - the custom keyboard configuration to be used when the keyboard is displayed * @param keyboardListener - A keyboard listener to capture user input */ - public void presentKeyboard(String initialText, KeyboardProperties customKeyboardProperties, KeyboardListener keyboardListener){ + public void presentKeyboard(@NonNull String initialText, @Nullable KeyboardProperties customKeyboardProperties, @NonNull KeyboardListener keyboardListener){ this.choiceSetManager.presentKeyboard(initialText, customKeyboardProperties, keyboardListener); } /** - * Set a custom keyboard configuration for this session + * Set a custom keyboard configuration for this session. If set to null, it will reset to default keyboard configuration. * @param keyboardConfiguration - the custom keyboard configuration to be used when the keyboard is displayed */ - public void setKeyboardConfiguration(KeyboardProperties keyboardConfiguration){ + public void setKeyboardConfiguration(@Nullable KeyboardProperties keyboardConfiguration){ this.choiceSetManager.setKeyboardConfiguration(keyboardConfiguration); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java index 07ebcc247..7aad31e08 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java @@ -35,6 +35,7 @@ package com.smartdevicelink.managers.screen.choiceset; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -170,7 +171,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { executor.submit(checkChoiceVR); } - public void preloadChoices(List<ChoiceCell> choices, final CompletionListener listener){ + public void preloadChoices(@NonNull List<ChoiceCell> choices, @Nullable final CompletionListener listener){ final HashSet<ChoiceCell> choicesToUpload = choicesToBeUploadedWithArray(choices); choicesToUpload.removeAll(preloadedChoices); @@ -213,7 +214,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { } } - public void deleteChoices(List<ChoiceCell> choices){ + public void deleteChoices(@NonNull List<ChoiceCell> choices){ if (!isReady()){ return; } @@ -259,7 +260,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { executor.submit(deleteChoicesOperation); } - public void presentChoiceSet(final ChoiceSet choiceSet, final InteractionMode mode, final KeyboardListener keyboardListener){ + public void presentChoiceSet(@NonNull final ChoiceSet choiceSet, @Nullable final InteractionMode mode, @Nullable final KeyboardListener keyboardListener){ if (!isReady()){ return; } @@ -322,7 +323,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { pendingPresentOperation = executor.submit(presentOp); } - public void presentKeyboard(String initialText, KeyboardProperties customKeyboardConfig, KeyboardListener listener){ + public void presentKeyboard(@NonNull String initialText, @Nullable KeyboardProperties customKeyboardConfig, @NonNull KeyboardListener listener){ if (!isReady()){ return; } @@ -346,7 +347,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { pendingPresentOperation = executor.submit(keyboardOp); } - public void setKeyboardConfiguration(KeyboardProperties keyboardConfiguration){ + public void setKeyboardConfiguration(@Nullable KeyboardProperties keyboardConfiguration){ if (keyboardConfiguration == null){ this.keyboardConfiguration = defaultKeyboardConfiguration(); } else{ @@ -481,6 +482,13 @@ abstract class BaseChoiceSetManager extends BaseSubManager { return false; } + if (choiceSet.getTimeout() != null) { + if (choiceSet.getTimeout() < 5 || choiceSet.getTimeout() > 100) { + DebugTool.logWarning("Attempted to create a choice set with a " + choiceSet.getTimeout() + " second timeout; Only 5 - 100 seconds is valid. When using the choice set manager, setTimeout() uses seconds."); + return false; + } + } + HashSet<String> choiceTextSet = new HashSet<>(); HashSet<String> uniqueVoiceCommands = new HashSet<>(); int allVoiceCommandsCount = 0; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCell.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCell.java index 27a7d8914..5a74b94f5 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCell.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceCell.java @@ -214,7 +214,7 @@ public class ChoiceCell { * Get the choiceId * @return the choiceId for this Choice Cell */ - public int getChoiceId() { + int getChoiceId() { return choiceId; } @@ -242,9 +242,7 @@ public class ChoiceCell { // if this is not an instance of this class, not the same if (!(o instanceof ChoiceCell)) return false; - ChoiceCell choiceCell = (ChoiceCell) o; - // if we get to this point, create the hashes and compare them - return hashCode() == choiceCell.hashCode(); + return hashCode() == o.hashCode(); } /** |