diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-04-25 14:18:15 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-04-25 14:18:15 -0400 |
commit | d8db1016737583e765f59cea04f4db2a4d479ab6 (patch) | |
tree | fac68041d17c29032e0911a03ffa0ac60e78d378 | |
parent | c4d9f6e137364c93dfec168c2dc238796fc670b7 (diff) | |
download | sdl_android-d8db1016737583e765f59cea04f4db2a4d479ab6.tar.gz |
still working on voicemanager. incremental commit
-rw-r--r-- | base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java | 67 | ||||
-rw-r--r-- | base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/VoiceCommand.java | 29 |
2 files changed, 89 insertions, 7 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 4b88b70dc..9ff30f565 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,11 +35,14 @@ package com.smartdevicelink.managers.screen.menu; import android.support.annotation.NonNull; import com.smartdevicelink.managers.BaseSubManager; +import com.smartdevicelink.managers.CompletionListener; 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.AddCommand; +import com.smartdevicelink.proxy.rpc.DeleteCommand; import com.smartdevicelink.proxy.rpc.OnCommand; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.enums.HMILevel; @@ -82,31 +85,81 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { public void setVoiceCommands(List<VoiceCommand> voiceCommands){ + // make sure hmi is not none + if (currentHMILevel == null || currentHMILevel == HMILevel.HMI_NONE){ + // Trying to send on HMI_NONE, waiting for full + waitingOnHMIUpdate = true; + return; + } + + waitingOnHMIUpdate = false; + lastVoiceCommandId = voiceCommandIdMin; + updateIdsOnVoiceCommands(voiceCommands); + oldVoiceCommands = voiceCommands; + this.voiceCommands = voiceCommands; + + updateWithListener(null); } // UPDATING SYSTEM - // update w/ listener + private void updateWithListener(CompletionListener listener){ + + + + } // DELETING OLD MENU ITEMS - // deleteCurrentVoiceCommands w/ listener + private void sendDeleteCurrentVoiceCommands(CompletionListener listener){ + + + + } // SEND NEW MENU ITEMS - // send current voice commands w/ listener + private void sendCurrentVoiceCommands(CompletionListener listener){ + + + + } // DELETES - // deleteCommandsForVoiceCommands + private List<DeleteCommand> deleteCommandsForVoiceCommands(List<VoiceCommand> voiceCommands){ + List<DeleteCommand> deleteCommandList = new ArrayList<>(); + for (VoiceCommand command : voiceCommands){ + DeleteCommand delete = new DeleteCommand(command.getCommandId()); + deleteCommandList.add(delete); + } + return deleteCommandList; + } // COMMANDS - // addCommandsForVoiceCommands + private List<AddCommand> addCommandsForVoiceCommands(List<VoiceCommand> voiceCommands){ + List<AddCommand> addCommandList = new ArrayList<>(); + for (VoiceCommand command : voiceCommands){ + addCommandList.add(commandForVoiceCommand(command)); + } + return addCommandList; + } + + private AddCommand commandForVoiceCommand(VoiceCommand voiceCommand){ + AddCommand command = new AddCommand(); + command.setVrCommands(voiceCommand.getVoiceCommands()); + command.setCmdID(voiceCommand.getCommandId()); + return command; + } // HELPERS - // updateIdsOnVoiceCommands + private void updateIdsOnVoiceCommands(List<VoiceCommand> voiceCommands){ + for (VoiceCommand command : voiceCommands){ + command.setCommandId(++lastVoiceCommandId); + } + } public void stop(){ @@ -129,7 +182,7 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { // LISTENERS private void addListeners(){ - + // HMI UPDATES hmiListener = new OnRPCNotificationListener() { @Override 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 28b02b3a1..4f6f51d56 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 @@ -48,6 +48,9 @@ public class VoiceCommand { */ private VoiceCommandSelectionListener voiceCommandSelectionListener; + + private int commandId; + // CONSTRUCTOR(S) /** @@ -93,4 +96,30 @@ public class VoiceCommand { public VoiceCommandSelectionListener getVoiceCommandSelectionListener() { return voiceCommandSelectionListener; } + + /** + * set the command ID + * @param commandId the id to identify the command + */ + public void setCommandId(int commandId) { + this.commandId = commandId; + } + + /** + * the id used to identify the command + * @return the id + */ + public int getCommandId() { + return commandId; + } + + // HELPER + + /** + * Get the description of the cell + * @return a String description of the cell object + */ + public String getDescription(){ + return "VOICE COMMAND - ID: "+commandId+ " First Object: "+ voiceCommands.get(0)+ " Voice Commands: "+ voiceCommands.size(); + } } |