summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrettyWhite <geekman3454@protonmail.com>2019-04-25 11:38:24 -0400
committerBrettyWhite <geekman3454@protonmail.com>2019-04-25 11:38:24 -0400
commit2e581deb01bbf500d3bacb10c5767978ef4ff8d2 (patch)
tree8e23bcf36464d91f732f360517ef9731c8262723
parentb2307153a57acad4b9628a9f2b73a9cd47c081c8 (diff)
downloadsdl_android-2e581deb01bbf500d3bacb10c5767978ef4ff8d2.tar.gz
start of voicecommandmanager
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java85
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java5
2 files changed, 90 insertions, 0 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java
index 6ce102d16..aa169ef5b 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java
@@ -35,12 +35,97 @@ package com.smartdevicelink.managers.screen.menu;
import android.support.annotation.NonNull;
import com.smartdevicelink.managers.BaseSubManager;
+import com.smartdevicelink.managers.screen.menu.cells.VoiceCommand;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.rpc.OnCommand;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.util.DebugTool;
+
+import java.util.ArrayList;
+import java.util.List;
abstract class BaseVoiceCommandManager extends BaseSubManager {
+ private List<VoiceCommand> voiceCommands;
+ private List<VoiceCommand> oldVoiceCommands;
+
+ private List<RPCRequest> inProgressUpdate;
+
+ private int commandId;
+ private int lastVoiceCommandId;
+ private static final int voiceCommandIdMin = 1900000000;
+
+ private boolean waitingOnHMIUpdate;
+ private boolean hasQueuedUpdate;
+
+ private HMILevel currentHMILevel;
+ private OnRPCNotificationListener hmiListener;
+ private OnRPCNotificationListener commandListener;
+
+ // CONSTRUCTORS
public BaseVoiceCommandManager(@NonNull ISdl internalInterface) {
super(internalInterface);
+ addListeners();
+
+ lastVoiceCommandId = voiceCommandIdMin;
+ voiceCommands = new ArrayList<>();
+ oldVoiceCommands = new ArrayList<>();
+ }
+
+
+ // HELPERS
+
+ public void stop(){
+
+ lastVoiceCommandId = voiceCommandIdMin;
+ voiceCommands = null;
+ oldVoiceCommands = null;
+
+ waitingOnHMIUpdate = false;
+ currentHMILevel = null;
+ inProgressUpdate = null;
+ hasQueuedUpdate = false;
+
+ // remove listeners
+ internalInterface.removeOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener);
+ internalInterface.removeOnRPCNotificationListener(FunctionID.ON_COMMAND, commandListener);
+
+ super.dispose();
+ }
+
+ // LISTENERS
+
+ private void addListeners(){
+ // HMI UPDATES
+ hmiListener = new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ currentHMILevel = ((OnHMIStatus) notification).getHmiLevel();
+ if (currentHMILevel == HMILevel.HMI_FULL){
+ if (waitingOnHMIUpdate){
+ DebugTool.logInfo( "Acquired HMI_FULL with pending update. Sending now");
+ waitingOnHMIUpdate = false;
+ // TODO: DO THINGS HERE
+ }
+ }
+ }
+ };
+ internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener);
+
+ // COMMANDS
+ commandListener = new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnCommand command = (OnCommand) notification;
+ // TODO: STUFF HERE
+ }
+ };
+ internalInterface.addOnRPCNotificationListener(FunctionID.ON_COMMAND, commandListener);
}
}
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java
index f9e52f0b5..28b02b3a1 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java
@@ -50,6 +50,11 @@ public class VoiceCommand {
// CONSTRUCTOR(S)
+ /**
+ * Constructor that sets all parameters for this class
+ * @param voiceCommands The strings the user can say to activate this voice command
+ * @param voiceCommandSelectionListener The listener that will be called when the command is activated
+ */
public VoiceCommand(List<String> voiceCommands, VoiceCommandSelectionListener voiceCommandSelectionListener){
setVoiceCommands(voiceCommands);
setVoiceCommandSelectionListener(voiceCommandSelectionListener);