summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrettyWhite <geekman3454@protonmail.com>2019-06-14 11:22:28 -0400
committerBrettyWhite <geekman3454@protonmail.com>2019-06-14 11:22:28 -0400
commitcd1de72ff9e1252696bc16aec68cbdef9a538c94 (patch)
tree70251f2127cd4b727226d71851d91931518e1df7
parent3026466d061d72cd3f21abf051d8b3d71b5ae075 (diff)
downloadsdl_android-cd1de72ff9e1252696bc16aec68cbdef9a538c94.tar.gz
add choice example to hello sdl java
-rw-r--r--hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java53
1 files changed, 40 insertions, 13 deletions
diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
index 9af923026..4292c086c 100644
--- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
+++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java
@@ -37,6 +37,9 @@ import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.SdlManager;
import com.smartdevicelink.managers.SdlManagerListener;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.managers.screen.choiceset.ChoiceCell;
+import com.smartdevicelink.managers.screen.choiceset.ChoiceSet;
+import com.smartdevicelink.managers.screen.choiceset.ChoiceSetSelectionListener;
import com.smartdevicelink.managers.screen.menu.MenuCell;
import com.smartdevicelink.managers.screen.menu.MenuSelectionListener;
import com.smartdevicelink.managers.screen.menu.VoiceCommand;
@@ -45,18 +48,13 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.TTSChunkFactory;
import com.smartdevicelink.proxy.rpc.*;
-import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
+import com.smartdevicelink.proxy.rpc.enums.*;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.util.DebugTool;
import java.util.*;
-import static javafx.scene.input.KeyCode.R;
-
public class SdlService {
@@ -72,7 +70,6 @@ public class SdlService {
private static final String WELCOME_SPEAK = "Welcome to Hello S D L";
private static final String TEST_COMMAND_NAME = "Test Command";
- private static final int TEST_COMMAND_ID = 1;
private static final String IMAGE_DIR = "assets/images/";
@@ -80,6 +77,7 @@ public class SdlService {
// variable to create and call functions of the SyncProxy
private SdlManager sdlManager = null;
+ private List<ChoiceCell> choiceCellList;
private SdlServiceCallback callback;
@@ -89,8 +87,6 @@ public class SdlService {
buildSdlManager(config);
}
-
-
public void start() {
DebugTool.logInfo("SdlService start() ");
if(sdlManager != null){
@@ -150,6 +146,7 @@ public class SdlService {
sendMenus();
performWelcomeSpeak();
performWelcomeShow();
+ preloadChoices();
}
}
});
@@ -167,7 +164,7 @@ public class SdlService {
}
}
-/**
+ /**
* Send some voice commands
*/
private void setVoiceCommands(){
@@ -237,7 +234,14 @@ public class SdlService {
// sub menu parent cell
MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2));
- MenuCell mainCell4 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
+ MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ showPerformInteraction();
+ }
+ });
+
+ MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
@Override
public void onTriggered(TriggerSource trigger) {
Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString());
@@ -248,7 +252,7 @@ public class SdlService {
});
// Send the entire menu off to be created
- sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4));
+ sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4, mainCell5));
}
/**
@@ -297,11 +301,34 @@ public class SdlService {
sdlManager.sendRPC(alert);
}
-
public interface SdlServiceCallback{
void onEnd();
}
+ // Choice Set
+ private void preloadChoices(){
+ ChoiceCell cell1 = new ChoiceCell("Item 1");
+ ChoiceCell cell2 = new ChoiceCell("Item 2");
+ ChoiceCell cell3 = new ChoiceCell("Item 3");
+ choiceCellList = new ArrayList<>(Arrays.asList(cell1,cell2,cell3));
+ sdlManager.getScreenManager().preloadChoices(choiceCellList, null);
+ }
+ private void showPerformInteraction(){
+ if (choiceCellList != null) {
+ ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() {
+ @Override
+ public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) {
+ showAlert(choiceCell.getText() + " was selected");
+ }
+
+ @Override
+ public void onError(String error) {
+ Log.e(TAG, "There was an error showing the perform interaction: "+ error);
+ }
+ });
+ sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY);
+ }
+ }
}