summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-08-12 09:04:31 -0400
committerNicoleYarroch <nicole@livio.io>2019-08-12 09:04:31 -0400
commitaac1e6ef72cb7e69845c9cebda81171eaf55ea6d (patch)
treea9befaadcfc8adc1ed9ce21bbc28c8c7052f3f13
parent6b31b954760e2b1c4e87d3dc45a88e8566a9df44 (diff)
downloadsdl_android-aac1e6ef72cb7e69845c9cebda81171eaf55ea6d.tar.gz
Refactored the dismiss keyboard methods
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java3
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java42
2 files changed, 28 insertions, 17 deletions
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 3dcb6fbaf..103612c74 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
@@ -403,6 +403,9 @@ abstract class BaseChoiceSetManager extends BaseSubManager {
pendingPresentOperation = executor.submit(keyboardOp);
}
+ /*
+ * Cancels the keyboard-only interface if it is currently showing
+ */
public void dismissKeyboard() {
if (currentlyPresentedKeyboardOperation == null || !currentlyPresentedKeyboardOperation.isExecuting()) { return; }
currentlyPresentedKeyboardOperation.dismissKeyboard();
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java
index 159aba3ad..30d2b75e6 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java
@@ -127,29 +127,37 @@ class PresentKeyboardOperation extends AsynchronousOperation {
}
+ /*
+ * Cancels a currently presented keyboard
+ */
void dismissKeyboard() {
if (Thread.currentThread().isInterrupted()) {
+ // This operation has been canceled. It will be finished at some point during the operation.
return;
- } else if (isExecuting()) {
- DebugTool.logInfo("Canceling the presented keyboard.");
+ }
- CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID);
- cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() {
- @Override
- public void onResponse(int correlationId, RPCResponse response) {
- DebugTool.logInfo("Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully"));
- }
+ if (!isExecuting()) {
+ DebugTool.logInfo("Keyboard is not being presented so it can not be canceled.");
+ return;
+ }
- @Override
- public void onError(int correlationId, Result resultCode, String info){
- DebugTool.logError("Error canceling the presented keyboard " + resultCode + " " + info);
- };
- });
- if (internalInterface.get() != null){
- internalInterface.get().sendRPC(cancelInteraction);
- } else {
- DebugTool.logError("Internal interface null - could not send cancel interaction for keyboard");
+ DebugTool.logInfo("Canceling the presented keyboard.");
+ CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID);
+ cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() {
+ @Override
+ public void onResponse(int correlationId, RPCResponse response) {
+ DebugTool.logInfo("Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully"));
}
+
+ @Override
+ public void onError(int correlationId, Result resultCode, String info){
+ DebugTool.logError("Error canceling the presented keyboard " + resultCode + " " + info);
+ }
+ });
+ if (internalInterface.get() != null){
+ internalInterface.get().sendRPC(cancelInteraction);
+ } else {
+ DebugTool.logError("Internal interface null - could not send cancel interaction for keyboard");
}
}