4848import com .smartdevicelink .protocol .enums .FunctionID ;
4949import com .smartdevicelink .proxy .RPCNotification ;
5050import com .smartdevicelink .proxy .TTSChunkFactory ;
51- import com .smartdevicelink .proxy .rpc .*;
51+ import com .smartdevicelink .proxy .rpc .Alert ;
52+ import com .smartdevicelink .proxy .rpc .OnHMIStatus ;
53+ import com .smartdevicelink .proxy .rpc .Speak ;
5254import com .smartdevicelink .proxy .rpc .enums .*;
5355import com .smartdevicelink .proxy .rpc .listeners .OnRPCNotificationListener ;
5456import com .smartdevicelink .transport .BaseTransportConfig ;
5961public class SdlService {
6062
6163
62- private static final String TAG = "SDL Service" ;
64+ private static final String TAG = "SDL Service" ;
6365
64- private static final String APP_NAME = "Hello Sdl" ;
65- private static final String APP_NAME_ES = "Hola Sdl" ;
66- private static final String APP_NAME_FR = "Bonjour Sdl" ;
67- private static final String APP_ID = "8678309" ;
66+ private static final String APP_NAME = "Hello Sdl" ;
67+ private static final String APP_NAME_ES = "Hola Sdl" ;
68+ private static final String APP_NAME_FR = "Bonjour Sdl" ;
69+ private static final String APP_ID = "8678309" ;
6870
69- private static final String ICON_FILENAME = "hello_sdl_icon.png" ;
70- private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png" ;
71+ private static final String ICON_FILENAME = "hello_sdl_icon.png" ;
72+ private static final String SDL_IMAGE_FILENAME = "sdl_full_image.png" ;
7173
72- private static final String WELCOME_SHOW = "Welcome to HelloSDL" ;
73- private static final String WELCOME_SPEAK = "Welcome to Hello S D L" ;
74+ private static final String WELCOME_SHOW = "Welcome to HelloSDL" ;
75+ private static final String WELCOME_SPEAK = "Welcome to Hello S D L" ;
7476
75- private static final String TEST_COMMAND_NAME = "Test Command" ;
76-
77- private static final String IMAGE_DIR = "assets/images/" ;
77+ private static final String TEST_COMMAND_NAME = "Test Command" ;
7878
79+ private static final String IMAGE_DIR = "assets/images/" ;
7980
8081
8182 // variable to create and call functions of the SyncProxy
@@ -85,14 +86,14 @@ public class SdlService {
8586 private SdlServiceCallback callback ;
8687
8788
88- public SdlService (BaseTransportConfig config , SdlServiceCallback callback ){
89+ public SdlService (BaseTransportConfig config , SdlServiceCallback callback ) {
8990 this .callback = callback ;
9091 buildSdlManager (config );
9192 }
9293
9394 public void start () {
9495 DebugTool .logInfo ("SdlService start() " );
95- if (sdlManager != null ){
96+ if (sdlManager != null ) {
9697 sdlManager .start ();
9798 }
9899 }
@@ -128,7 +129,7 @@ public void onStart(SdlManager sdlManager) {
128129 public void onDestroy (SdlManager sdlManager ) {
129130 DebugTool .logInfo ("SdlManager onDestroy " );
130131 SdlService .this .sdlManager = null ;
131- if (SdlService .this .callback != null ){
132+ if (SdlService .this .callback != null ) {
132133 SdlService .this .callback .onEnd ();
133134 }
134135 }
@@ -138,7 +139,7 @@ public void onError(SdlManager sdlManager, String info, Exception e) {
138139 }
139140
140141 @ Override
141- public LifecycleConfigurationUpdate managerShouldUpdateLifecycle (Language language ){
142+ public LifecycleConfigurationUpdate managerShouldUpdateLifecycle (Language language ) {
142143 String appName ;
143144 switch (language ) {
144145 case ES_MX :
@@ -151,12 +152,12 @@ public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language langua
151152 return null ;
152153 }
153154
154- return new LifecycleConfigurationUpdate (appName ,null ,TTSChunkFactory .createSimpleTTSChunks (appName ), null );
155+ return new LifecycleConfigurationUpdate (appName , null , TTSChunkFactory .createSimpleTTSChunks (appName ), null );
155156 }
156157 };
157158
158159
159- HashMap <FunctionID ,OnRPCNotificationListener > notificationListenerHashMap = new HashMap <FunctionID ,OnRPCNotificationListener >();
160+ HashMap <FunctionID , OnRPCNotificationListener > notificationListenerHashMap = new HashMap <FunctionID , OnRPCNotificationListener >();
160161 notificationListenerHashMap .put (FunctionID .ON_HMI_STATUS , new OnRPCNotificationListener () {
161162 @ Override
162163 public void onNotified (RPCNotification notification ) {
@@ -172,7 +173,7 @@ public void onNotified(RPCNotification notification) {
172173 });
173174
174175 // Create App Icon, this is set in the SdlManager builder
175- SdlArtwork appIcon = new SdlArtwork (ICON_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl_s_green.png" , true );
176+ SdlArtwork appIcon = new SdlArtwork (ICON_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl_s_green.png" , true );
176177
177178 // The manager builder sets options for your session
178179 SdlManager .Builder builder = new SdlManager .Builder (APP_ID , APP_NAME , listener );
@@ -187,7 +188,7 @@ public void onNotified(RPCNotification notification) {
187188 /**
188189 * Send some voice commands
189190 */
190- private void setVoiceCommands (){
191+ private void setVoiceCommands () {
191192
192193 List <String > list1 = Collections .singletonList ("Command One" );
193194 List <String > list2 = Collections .singletonList ("Command two" );
@@ -206,53 +207,53 @@ public void onVoiceCommandSelected() {
206207 }
207208 });
208209
209- sdlManager .getScreenManager ().setVoiceCommands (Arrays .asList (voiceCommand1 ,voiceCommand2 ));
210+ sdlManager .getScreenManager ().setVoiceCommands (Arrays .asList (voiceCommand1 , voiceCommand2 ));
210211 }
211212
212213 /**
213- * Add menus for the app on SDL.
214+ * Add menus for the app on SDL.
214215 */
215- private void sendMenus (){
216+ private void sendMenus () {
216217
217218 // some arts
218- SdlArtwork livio = new SdlArtwork (ICON_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl_s_green.png" , true );
219+ SdlArtwork livio = new SdlArtwork (ICON_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl_s_green.png" , true );
219220
220221 // some voice commands
221222 List <String > voice2 = Collections .singletonList ("Cell two" );
222223
223224 MenuCell mainCell1 = new MenuCell ("Test Cell 1 (speak)" , livio , null , new MenuSelectionListener () {
224225 @ Override
225226 public void onTriggered (TriggerSource trigger ) {
226- Log .i (TAG , "Test cell 1 triggered. Source: " + trigger .toString ());
227+ Log .i (TAG , "Test cell 1 triggered. Source: " + trigger .toString ());
227228 showTest ();
228229 }
229230 });
230231
231232 MenuCell mainCell2 = new MenuCell ("Test Cell 2" , null , voice2 , new MenuSelectionListener () {
232233 @ Override
233234 public void onTriggered (TriggerSource trigger ) {
234- Log .i (TAG , "Test cell 2 triggered. Source: " + trigger .toString ());
235+ Log .i (TAG , "Test cell 2 triggered. Source: " + trigger .toString ());
235236 }
236237 });
237238
238239 // SUB MENU
239240
240- MenuCell subCell1 = new MenuCell ("SubCell 1" ,null , null , new MenuSelectionListener () {
241+ MenuCell subCell1 = new MenuCell ("SubCell 1" , null , null , new MenuSelectionListener () {
241242 @ Override
242243 public void onTriggered (TriggerSource trigger ) {
243- Log .i (TAG , "Sub cell 1 triggered. Source: " + trigger .toString ());
244+ Log .i (TAG , "Sub cell 1 triggered. Source: " + trigger .toString ());
244245 }
245246 });
246247
247- MenuCell subCell2 = new MenuCell ("SubCell 2" ,null , null , new MenuSelectionListener () {
248+ MenuCell subCell2 = new MenuCell ("SubCell 2" , null , null , new MenuSelectionListener () {
248249 @ Override
249250 public void onTriggered (TriggerSource trigger ) {
250- Log .i (TAG , "Sub cell 2 triggered. Source: " + trigger .toString ());
251+ Log .i (TAG , "Sub cell 2 triggered. Source: " + trigger .toString ());
251252 }
252253 });
253254
254255 // sub menu parent cell
255- MenuCell mainCell3 = new MenuCell ("Test Cell 3 (sub menu)" , null , Arrays .asList (subCell1 ,subCell2 ));
256+ MenuCell mainCell3 = new MenuCell ("Test Cell 3 (sub menu)" , null , Arrays .asList (subCell1 , subCell2 ));
256257
257258 MenuCell mainCell4 = new MenuCell ("Show Perform Interaction" , null , null , new MenuSelectionListener () {
258259 @ Override
@@ -261,10 +262,10 @@ public void onTriggered(TriggerSource trigger) {
261262 }
262263 });
263264
264- MenuCell mainCell5 = new MenuCell ("Clear the menu" ,null , null , new MenuSelectionListener () {
265+ MenuCell mainCell5 = new MenuCell ("Clear the menu" , null , null , new MenuSelectionListener () {
265266 @ Override
266267 public void onTriggered (TriggerSource trigger ) {
267- Log .i (TAG , "Clearing Menu. Source: " + trigger .toString ());
268+ Log .i (TAG , "Clearing Menu. Source: " + trigger .toString ());
268269 // Clear this thing
269270 sdlManager .getScreenManager ().setMenu (Collections .<MenuCell >emptyList ());
270271 showAlert ("Menu Cleared" );
@@ -278,7 +279,7 @@ public void onTriggered(TriggerSource trigger) {
278279 /**
279280 * Will speak a sample welcome message
280281 */
281- private void performWelcomeSpeak (){
282+ private void performWelcomeSpeak () {
282283 sdlManager .sendRPC (new Speak (TTSChunkFactory .createSimpleTTSChunks (WELCOME_SPEAK )));
283284 }
284285
@@ -291,11 +292,11 @@ private void performWelcomeShow() {
291292 sdlManager .getScreenManager ().beginTransaction ();
292293 sdlManager .getScreenManager ().setTextField1 (APP_NAME );
293294 sdlManager .getScreenManager ().setTextField2 (WELCOME_SHOW );
294- sdlManager .getScreenManager ().setPrimaryGraphic (new SdlArtwork (SDL_IMAGE_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl.png" , true ));
295+ sdlManager .getScreenManager ().setPrimaryGraphic (new SdlArtwork (SDL_IMAGE_FILENAME , FileType .GRAPHIC_PNG , IMAGE_DIR + "sdl.png" , true ));
295296 sdlManager .getScreenManager ().commit (new CompletionListener () {
296297 @ Override
297298 public void onComplete (boolean success ) {
298- if (success ){
299+ if (success ) {
299300 Log .i (TAG , "welcome show successful" );
300301 }
301302 }
@@ -305,7 +306,7 @@ public void onComplete(boolean success) {
305306 /**
306307 * Will show a sample test message on screen as well as speak a sample test message
307308 */
308- private void showTest (){
309+ private void showTest () {
309310 sdlManager .getScreenManager ().beginTransaction ();
310311 sdlManager .getScreenManager ().setTextField1 ("Test Cell 1 has been selected" );
311312 sdlManager .getScreenManager ().setTextField2 ("" );
@@ -314,28 +315,28 @@ private void showTest(){
314315 sdlManager .sendRPC (new Speak (TTSChunkFactory .createSimpleTTSChunks (TEST_COMMAND_NAME )));
315316 }
316317
317- private void showAlert (String text ){
318+ private void showAlert (String text ) {
318319 Alert alert = new Alert ();
319320 alert .setAlertText1 (text );
320321 alert .setDuration (5000 );
321322 sdlManager .sendRPC (alert );
322323 }
323324
324- public interface SdlServiceCallback {
325+ public interface SdlServiceCallback {
325326 void onEnd ();
326327 }
327328
328329 // Choice Set
329330
330- private void preloadChoices (){
331+ private void preloadChoices () {
331332 ChoiceCell cell1 = new ChoiceCell ("Item 1" );
332333 ChoiceCell cell2 = new ChoiceCell ("Item 2" );
333334 ChoiceCell cell3 = new ChoiceCell ("Item 3" );
334- choiceCellList = new ArrayList <>(Arrays .asList (cell1 ,cell2 ,cell3 ));
335+ choiceCellList = new ArrayList <>(Arrays .asList (cell1 , cell2 , cell3 ));
335336 sdlManager .getScreenManager ().preloadChoices (choiceCellList , null );
336337 }
337338
338- private void showPerformInteraction (){
339+ private void showPerformInteraction () {
339340 if (choiceCellList != null ) {
340341 ChoiceSet choiceSet = new ChoiceSet ("Choose an Item from the list" , choiceCellList , new ChoiceSetSelectionListener () {
341342 @ Override
@@ -345,7 +346,7 @@ public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource,
345346
346347 @ Override
347348 public void onError (String error ) {
348- Log .e (TAG , "There was an error showing the perform interaction: " + error );
349+ Log .e (TAG , "There was an error showing the perform interaction: " + error );
349350 }
350351 });
351352 sdlManager .getScreenManager ().presentChoiceSet (choiceSet , InteractionMode .MANUAL_ONLY );
0 commit comments