summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2020-10-02 16:11:10 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2020-10-02 16:11:10 -0400
commit61e76c1472afe908046dde38f947b1f8b55960df (patch)
tree8fae540640ac6eb26a30f0bf2aaff7d0f83369c4
parentff3012d26d7d5f0a5cb71a5be26c4c0614e434b3 (diff)
downloadsdl_android-61e76c1472afe908046dde38f947b1f8b55960df.tar.gz
Reformat hello sdl javaEE code
-rw-r--r--javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java6
-rw-r--r--javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java89
2 files changed, 48 insertions, 47 deletions
diff --git a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java
index 8f685e984..22302d816 100644
--- a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java
+++ b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/Main.java
@@ -7,8 +7,8 @@ package com.smartdevicelink;
// @ServerEndpoint("/")
- // @Stateful(name = "SDLSessionEJB")
- public class Main {
+// @Stateful(name = "SDLSessionEJB")
+public class Main {
/* Session session;
static Thread thread = null, mainThread;
@@ -48,4 +48,4 @@ package com.smartdevicelink;
}
};
*/
- }
+}
diff --git a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
index 779c357ee..87bbf4c67 100644
--- a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
+++ b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java
@@ -48,7 +48,9 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener;
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.Alert;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.Speak;
import com.smartdevicelink.proxy.rpc.enums.*;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.transport.BaseTransportConfig;
@@ -59,23 +61,22 @@ import java.util.*;
public class SdlService {
- private static final String TAG = "SDL Service";
+ private static final String TAG = "SDL Service";
- private static final String APP_NAME = "Hello Sdl";
- private static final String APP_NAME_ES = "Hola Sdl";
- private static final String APP_NAME_FR = "Bonjour Sdl";
- private static final String APP_ID = "8678309";
+ private static final String APP_NAME = "Hello Sdl";
+ private static final String APP_NAME_ES = "Hola Sdl";
+ private static final String APP_NAME_FR = "Bonjour Sdl";
+ private static final String APP_ID = "8678309";
- private static final String ICON_FILENAME = "hello_sdl_icon.png";
- private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png";
+ private static final String ICON_FILENAME = "hello_sdl_icon.png";
+ private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png";
- private static final String WELCOME_SHOW = "Welcome to HelloSDL";
- private static final String WELCOME_SPEAK = "Welcome to Hello S D L";
+ private static final String WELCOME_SHOW = "Welcome to HelloSDL";
+ private static final String WELCOME_SPEAK = "Welcome to Hello S D L";
- private static final String TEST_COMMAND_NAME = "Test Command";
-
- private static final String IMAGE_DIR = "assets/images/";
+ private static final String TEST_COMMAND_NAME = "Test Command";
+ private static final String IMAGE_DIR = "assets/images/";
// variable to create and call functions of the SyncProxy
@@ -85,14 +86,14 @@ public class SdlService {
private SdlServiceCallback callback;
- public SdlService(BaseTransportConfig config, SdlServiceCallback callback){
+ public SdlService(BaseTransportConfig config, SdlServiceCallback callback) {
this.callback = callback;
buildSdlManager(config);
}
public void start() {
DebugTool.logInfo("SdlService start() ");
- if(sdlManager != null){
+ if (sdlManager != null) {
sdlManager.start();
}
}
@@ -128,7 +129,7 @@ public class SdlService {
public void onDestroy(SdlManager sdlManager) {
DebugTool.logInfo("SdlManager onDestroy ");
SdlService.this.sdlManager = null;
- if(SdlService.this.callback != null){
+ if (SdlService.this.callback != null) {
SdlService.this.callback.onEnd();
}
}
@@ -138,7 +139,7 @@ public class SdlService {
}
@Override
- public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language){
+ public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) {
String appName;
switch (language) {
case ES_MX:
@@ -151,12 +152,12 @@ public class SdlService {
return null;
}
- return new LifecycleConfigurationUpdate(appName,null,TTSChunkFactory.createSimpleTTSChunks(appName), null);
+ return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(appName), null);
}
};
- HashMap<FunctionID,OnRPCNotificationListener> notificationListenerHashMap = new HashMap<FunctionID,OnRPCNotificationListener>();
+ HashMap<FunctionID, OnRPCNotificationListener> notificationListenerHashMap = new HashMap<FunctionID, OnRPCNotificationListener>();
notificationListenerHashMap.put(FunctionID.ON_HMI_STATUS, new OnRPCNotificationListener() {
@Override
public void onNotified(RPCNotification notification) {
@@ -172,7 +173,7 @@ public class SdlService {
});
// 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);
+ SdlArtwork appIcon = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR + "sdl_s_green.png", true);
// The manager builder sets options for your session
SdlManager.Builder builder = new SdlManager.Builder(APP_ID, APP_NAME, listener);
@@ -187,7 +188,7 @@ public class SdlService {
/**
* Send some voice commands
*/
- private void setVoiceCommands(){
+ private void setVoiceCommands() {
List<String> list1 = Collections.singletonList("Command One");
List<String> list2 = Collections.singletonList("Command two");
@@ -206,16 +207,16 @@ public class SdlService {
}
});
- sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1,voiceCommand2));
+ sdlManager.getScreenManager().setVoiceCommands(Arrays.asList(voiceCommand1, voiceCommand2));
}
/**
- * Add menus for the app on SDL.
+ * Add menus for the app on SDL.
*/
- private void sendMenus(){
+ private void sendMenus() {
// some arts
- SdlArtwork livio = new SdlArtwork(ICON_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl_s_green.png", true);
+ 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");
@@ -223,7 +224,7 @@ public class SdlService {
MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() {
@Override
public void onTriggered(TriggerSource trigger) {
- Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString());
+ Log.i(TAG, "Test cell 1 triggered. Source: " + trigger.toString());
showTest();
}
});
@@ -231,28 +232,28 @@ public class SdlService {
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());
+ Log.i(TAG, "Test cell 2 triggered. Source: " + trigger.toString());
}
});
// SUB MENU
- MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() {
+ 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());
+ Log.i(TAG, "Sub cell 1 triggered. Source: " + trigger.toString());
}
});
- MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() {
+ 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());
+ Log.i(TAG, "Sub cell 2 triggered. Source: " + trigger.toString());
}
});
// sub menu parent cell
- MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2));
+ MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1, subCell2));
MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() {
@Override
@@ -261,10 +262,10 @@ public class SdlService {
}
});
- MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
+ 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());
+ Log.i(TAG, "Clearing Menu. Source: " + trigger.toString());
// Clear this thing
sdlManager.getScreenManager().setMenu(Collections.<MenuCell>emptyList());
showAlert("Menu Cleared");
@@ -278,7 +279,7 @@ public class SdlService {
/**
* Will speak a sample welcome message
*/
- private void performWelcomeSpeak(){
+ private void performWelcomeSpeak() {
sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK)));
}
@@ -291,11 +292,11 @@ public class SdlService {
sdlManager.getScreenManager().beginTransaction();
sdlManager.getScreenManager().setTextField1(APP_NAME);
sdlManager.getScreenManager().setTextField2(WELCOME_SHOW);
- sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR+"sdl.png", true));
+ sdlManager.getScreenManager().setPrimaryGraphic(new SdlArtwork(SDL_IMAGE_FILENAME, FileType.GRAPHIC_PNG, IMAGE_DIR + "sdl.png", true));
sdlManager.getScreenManager().commit(new CompletionListener() {
@Override
public void onComplete(boolean success) {
- if (success){
+ if (success) {
Log.i(TAG, "welcome show successful");
}
}
@@ -305,7 +306,7 @@ public class SdlService {
/**
* Will show a sample test message on screen as well as speak a sample test message
*/
- private void showTest(){
+ private void showTest() {
sdlManager.getScreenManager().beginTransaction();
sdlManager.getScreenManager().setTextField1("Test Cell 1 has been selected");
sdlManager.getScreenManager().setTextField2("");
@@ -314,28 +315,28 @@ public class SdlService {
sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME)));
}
- private void showAlert(String text){
+ private void showAlert(String text) {
Alert alert = new Alert();
alert.setAlertText1(text);
alert.setDuration(5000);
sdlManager.sendRPC(alert);
}
- public interface SdlServiceCallback{
+ public interface SdlServiceCallback {
void onEnd();
}
// Choice Set
- private void preloadChoices(){
+ 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));
+ choiceCellList = new ArrayList<>(Arrays.asList(cell1, cell2, cell3));
sdlManager.getScreenManager().preloadChoices(choiceCellList, null);
}
- private void showPerformInteraction(){
+ private void showPerformInteraction() {
if (choiceCellList != null) {
ChoiceSet choiceSet = new ChoiceSet("Choose an Item from the list", choiceCellList, new ChoiceSetSelectionListener() {
@Override
@@ -345,7 +346,7 @@ public class SdlService {
@Override
public void onError(String error) {
- Log.e(TAG, "There was an error showing the perform interaction: "+ error);
+ Log.e(TAG, "There was an error showing the perform interaction: " + error);
}
});
sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY);