summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrettyWhite <geekman3454@protonmail.com>2019-05-09 15:53:52 -0400
committerBrettyWhite <geekman3454@protonmail.com>2019-05-09 15:53:52 -0400
commit41f05aa9189178892ca673c458db10f919136ac2 (patch)
treeb52bd0b10d38ddb73e845d050545a0f83af7daf7
parent086274997eabcdf99b85c785ba4cf78402b2204f (diff)
downloadsdl_android-41f05aa9189178892ca673c458db10f919136ac2.tar.gz
update hello examples
-rwxr-xr-xandroid/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java2
-rw-r--r--hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java117
-rw-r--r--hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java115
3 files changed, 175 insertions, 59 deletions
diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
index efdbff67b..ec7af8ca0 100755
--- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
+++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
@@ -228,7 +228,7 @@ public class SdlService extends Service {
SdlArtwork livio = new SdlArtwork("livio", FileType.GRAPHIC_PNG, R.drawable.sdl, false);
// some voice commands
- List<String> voice2 = Arrays.asList("Cell two");
+ List<String> voice2 = Collections.singletonList("Cell two");
MenuCell mainCell1 = new MenuCell("Test Cell 1", livio, null, new MenuSelectionListener() {
@Override
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 0330ce192..312b1faa4 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,10 @@ 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.menu.MenuCell;
+import com.smartdevicelink.managers.screen.menu.MenuSelectionListener;
+import com.smartdevicelink.managers.screen.menu.VoiceCommand;
+import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.TTSChunkFactory;
@@ -44,13 +48,14 @@ 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.listeners.OnRPCNotificationListener;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.util.DebugTool;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Vector;
+import java.util.*;
+
+import static javafx.scene.input.KeyCode.R;
public class SdlService {
@@ -141,29 +146,14 @@ public class SdlService {
public void onNotified(RPCNotification notification) {
OnHMIStatus status = (OnHMIStatus) notification;
if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) {
- sendCommands();
+ setVoiceCommands();
+ sendMenus();
performWelcomeSpeak();
performWelcomeShow();
}
}
});
- notificationListenerHashMap.put(FunctionID.ON_COMMAND, new OnRPCNotificationListener() {
- @Override
- public void onNotified(RPCNotification notification) {
- OnCommand command = (OnCommand) notification;
- Integer id = command.getCmdID();
- if(id != null){
- switch(id){
- case TEST_COMMAND_ID:
- showTest();
- break;
- }
- }
- }
- });
-
-
// Create App Icon, this is set in the SdlManager builder
SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
@@ -177,17 +167,86 @@ public class SdlService {
}
}
+/**
+ * Send some voice commands
+ */
+ private void setVoiceCommands(){
+
+ List<String> list1 = Arrays.asList("Command One");
+ List<String> list2 = Arrays.asList("Command two");
+
+ VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() {
+ @Override
+ public void onVoiceCommandSelected() {
+ Log.i(TAG, "Voice Command 1 triggered");
+ }
+ });
+
+ VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() {
+ @Override
+ public void onVoiceCommandSelected() {
+ Log.i(TAG, "Voice Command 2 triggered");
+ }
+ });
+
+ sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2));
+ }
+
/**
- * Add commands for the app on SDL.
+ * Add menus for the app on SDL.
*/
- private void sendCommands(){
- AddCommand command = new AddCommand();
- MenuParams params = new MenuParams();
- params.setMenuName(TEST_COMMAND_NAME);
- command.setCmdID(TEST_COMMAND_ID);
- command.setMenuParams(params);
- command.setVrCommands(Collections.singletonList(TEST_COMMAND_NAME));
- sdlManager.sendRPC(command);
+ private void sendMenus(){
+
+ // some arts
+ SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
+
+ // some voice commands
+ List<String> voice2 = Collections.singletonList("Cell two");
+
+ MenuCell mainCell1 = new MenuCell("Test Cell 1", livio, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ // SUB MENU
+
+ MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ // sub menu parent cell
+ MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", livio, Arrays.asList(subCell1,subCell2));
+
+ MenuCell mainCell4 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString());
+ // Clear this thing
+ sdlManager.getScreenManager().setMenu(Collections.<MenuCell>emptyList());
+ }
+ });
+
+ // Send the entire menu off to be created
+ sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4));
}
/**
diff --git a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java b/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
index 58d98cf8d..f8d51ed4e 100644
--- a/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
+++ b/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
@@ -5,6 +5,10 @@ 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.menu.MenuCell;
+import com.smartdevicelink.managers.screen.menu.MenuSelectionListener;
+import com.smartdevicelink.managers.screen.menu.VoiceCommand;
+import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.TTSChunkFactory;
@@ -12,13 +16,12 @@ 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.listeners.OnRPCNotificationListener;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.util.DebugTool;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Vector;
+import java.util.*;
public class SdlService {
@@ -109,29 +112,14 @@ public class SdlService {
public void onNotified(RPCNotification notification) {
OnHMIStatus status = (OnHMIStatus) notification;
if (status.getHmiLevel() == HMILevel.HMI_FULL && ((OnHMIStatus) notification).getFirstRun()) {
- sendCommands();
+ setVoiceCommands();
+ sendMenus();
performWelcomeSpeak();
performWelcomeShow();
}
}
});
- notificationListenerHashMap.put(FunctionID.ON_COMMAND, new OnRPCNotificationListener() {
- @Override
- public void onNotified(RPCNotification notification) {
- OnCommand command = (OnCommand) notification;
- Integer id = command.getCmdID();
- if(id != null){
- switch(id){
- case TEST_COMMAND_ID:
- showTest();
- break;
- }
- }
- }
- });
-
-
// Create App Icon, this is set in the SdlManager builder
SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
@@ -145,17 +133,86 @@ public class SdlService {
}
}
+ /**
+ * Send some voice commands
+ */
+ private void setVoiceCommands(){
+
+ List<String> list1 = Arrays.asList("Command One");
+ List<String> list2 = Arrays.asList("Command two");
+
+ VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() {
+ @Override
+ public void onVoiceCommandSelected() {
+ Log.i(TAG, "Voice Command 1 triggered");
+ }
+ });
+
+ VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() {
+ @Override
+ public void onVoiceCommandSelected() {
+ Log.i(TAG, "Voice Command 2 triggered");
+ }
+ });
+
+ sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2));
+ }
+
/**
- * Add commands for the app on SDL.
+ * Add menus for the app on SDL.
*/
- private void sendCommands(){
- AddCommand command = new AddCommand();
- MenuParams params = new MenuParams();
- params.setMenuName(TEST_COMMAND_NAME);
- command.setCmdID(TEST_COMMAND_ID);
- command.setMenuParams(params);
- command.setVrCommands(Collections.singletonList(TEST_COMMAND_NAME));
- sdlManager.sendRPC(command);
+ private void sendMenus(){
+
+ // some arts
+ SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
+
+ // some voice commands
+ List<String> voice2 = Collections.singletonList("Cell two");
+
+ MenuCell mainCell1 = new MenuCell("Test Cell 1", livio, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ // SUB MENU
+
+ MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString());
+ }
+ });
+
+ // sub menu parent cell
+ MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", livio, Arrays.asList(subCell1,subCell2));
+
+ MenuCell mainCell4 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
+ @Override
+ public void onTriggered(TriggerSource trigger) {
+ Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString());
+ // Clear this thing
+ sdlManager.getScreenManager().setMenu(Collections.<MenuCell>emptyList());
+ }
+ });
+
+ // Send the entire menu off to be created
+ sdlManager.getScreenManager().setMenu(Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4));
}
/**