1212import android .util .Log ;
1313
1414import com .smartdevicelink .managers .CompletionListener ;
15- import com .smartdevicelink .managers .OnButtonListener ;
15+ import com .smartdevicelink .managers .screen . OnButtonListener ;
1616import com .smartdevicelink .managers .SdlManager ;
1717import com .smartdevicelink .managers .SdlManagerListener ;
1818import com .smartdevicelink .managers .file .filetypes .SdlArtwork ;
@@ -82,7 +82,9 @@ public class SdlService extends Service {
8282 private SdlManager sdlManager = null ;
8383 private List <ChoiceCell > choiceCellList ;
8484
85- private ButtonName [] buttonNames = {ButtonName .PRESET_0 , ButtonName .PRESET_1 , ButtonName .PRESET_2 , ButtonName .PRESET_3 , ButtonName .PRESET_4 , ButtonName .PRESET_5 , ButtonName .PRESET_6 , ButtonName .PRESET_7 };
85+ private ButtonName [] buttonNames = {ButtonName .PLAY_PAUSE , ButtonName .SEEKLEFT , ButtonName .SEEKRIGHT , ButtonName .AC_MAX , ButtonName .AC , ButtonName .RECIRCULATE ,
86+ ButtonName .FAN_UP , ButtonName .FAN_DOWN , ButtonName .TEMP_UP , ButtonName .FAN_DOWN , ButtonName .DEFROST_MAX , ButtonName .DEFROST_REAR , ButtonName .DEFROST ,
87+ ButtonName .UPPER_VENT , ButtonName .LOWER_VENT , ButtonName .VOLUME_UP , ButtonName .VOLUME_DOWN , ButtonName .EJECT , ButtonName .SOURCE , ButtonName .SHUFFLE , ButtonName .REPEAT };
8688 private OnButtonListener onButtonListener ;
8789
8890 @ Override
@@ -190,7 +192,7 @@ public void onNotified(RPCNotification notification) {
190192 performWelcomeSpeak ();
191193 performWelcomeShow ();
192194 preloadChoices ();
193- subscribeToPresetButtons ();
195+ subscribeToButtons ();
194196 }
195197 }
196198 });
@@ -347,15 +349,8 @@ public void onTriggered(TriggerSource trigger) {
347349 }
348350 });
349351
350- MenuCell mainCell6 = new MenuCell ("Unsubscribe to preset buttons" ,null , null , new MenuSelectionListener () {
351- @ Override
352- public void onTriggered (TriggerSource trigger ) {
353- unsubscribeToPresetButtons ();
354- }
355- });
356-
357352 // Send the entire menu off to be created
358- sdlManager .getScreenManager ().setMenu (Arrays .asList (mainCell1 , mainCell2 , mainCell3 , mainCell4 , mainCell5 , mainCell6 ));
353+ sdlManager .getScreenManager ().setMenu (Arrays .asList (mainCell1 , mainCell2 , mainCell3 , mainCell4 , mainCell5 ));
359354 }
360355
361356 /**
@@ -388,16 +383,16 @@ public void onComplete(boolean success) {
388383 /**
389384 * Attempts to Subscribe to all preset buttons
390385 */
391- private void subscribeToPresetButtons () {
386+ private void subscribeToButtons () {
392387 onButtonListener = new OnButtonListener () {
393388 @ Override
394389 public void onPress (ButtonName buttonName , OnButtonPress buttonPress ) {
395- Log . i ( TAG , "onPress : " + buttonName );
390+ sdlManager . getScreenManager (). setTextField1 ( "Subscribed Button Named : " + buttonName + " was pressed" );
396391 }
397392
398393 @ Override
399394 public void onEvent (ButtonName buttonName , OnButtonEvent buttonEvent ) {
400- Log . i ( TAG , "onEvent : " + buttonName + " " + buttonEvent );
395+ sdlManager . getScreenManager (). setTextField2 ( "Subscribed Button Named : " + buttonName + " Event: " + buttonEvent . getButtonEventMode () );
401396 }
402397
403398 @ Override
@@ -411,15 +406,6 @@ public void onError(String info) {
411406 }
412407 }
413408
414- /**
415- * Attempts to Unsubscribe to all preset Buttons
416- */
417- private void unsubscribeToPresetButtons () {
418- for (ButtonName buttonName : buttonNames ) {
419- sdlManager .getScreenManager ().removeButtonListener (buttonName , onButtonListener );
420- }
421- }
422-
423409 /**
424410 * Will show a sample test message on screen as well as speak a sample test message
425411 */
0 commit comments