Android Open Source - sdl_tester_android Sdl Button






From Project

Back to project page sdl_tester_android.

License

The source code is released under:

Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

If you think the Android project sdl_tester_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.livio.sdl.enums;
// w w  w . ja va  2  s.co  m
import java.util.Arrays;

import com.smartdevicelink.proxy.rpc.enums.ButtonName;

/**
 * <p>
 * Defines logical buttons which, on a given SDL unit, would correspond to
 * either physical or soft (touchscreen) buttons. These logical buttons present
 * a standard functional abstraction which the developer can rely upon,
 * independent of the SYNC unit. For example, the developer can rely upon the OK
 * button having the same meaning to the user across SDL platforms.
 * </p>
 * <p>
 * The preset buttons (0-9) can typically be interpreted by the application as
 * corresponding to some user-configured choices, though the application is free
 * to interpret these button presses as it sees fit.
 * </p>
 * <p>
 * The application can discover which buttons a given SDL unit implements by
 * interrogating the ButtonCapabilities parameter of the
 * RegisterAppInterface response.
 * </p>
 * 
 * @since SmartDeviceLink 1.0
 */
public enum SdlButton {
  
  /**
   * Represents the button usually labeled "OK". A typical use of this button
   * is for the user to press it to make a selection.
   * 
   * @since SmartDeviceLink 1.0
   */
  OK ("Ok"),
  /**
   * Represents the seek-left button. A typical use of this button is for the
   * user to scroll to the left through menu choices one menu item per press.
   * 
   * @since SmartDeviceLink 1.0
   */
  SEEK_LEFT ("Seek Left"),
  /**
   * Represents the seek-right button. A typical use of this button is for the
   * user to scroll to the right through menu choices one menu item per press.
   * 
   * @since SmartDeviceLink 1.0
   */
  SEEK_RIGHT ("Seek Right"),
  /**
   * Represents a turn of the tuner knob in the clockwise direction one tick.
   * 
   * @since SmartDeviceLink 1.0
   */
  TUNE_UP ("Tune Up"),
  /**
   * Represents a turn of the tuner knob in the counter-clockwise direction
   * one tick.
   * 
   * @since SmartDeviceLink 1.0
   */
  TUNE_DOWN ("Tune Down"),
  /**
   * Represents the preset 0 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_0 ("Preset #0"),
  /**
   * Represents the preset 1 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_1 ("Preset #1"),
  /**
   * Represents the preset 2 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_2 ("Preset #2"),
  /**
   * Represents the preset 3 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_3 ("Preset #3"),
  /**
   * Represents the preset 4 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_4 ("Preset #4"),
  /**
   * Represents the preset 5 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_5 ("Preset #5"),
  /**
   * Represents the preset 6 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_6 ("Preset #6"),
  /**
   * Represents the preset 7 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_7 ("Preset #7"),
  /**
   * Represents the preset 8 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_8 ("Preset #8"),
  /**
   * Represents the preset 9 button.
   * 
   * @since SmartDeviceLink 1.0
   */
  PRESET_9 ("Preset #9"),
  
  CUSTOM_BUTTON ("Custom Buttons"),
  ;
  
  private final String READABLE_NAME;
  
  private SdlButton(String readableName){
    this.READABLE_NAME = readableName;
  }
  
  /**
   * Returns an array of the objects in this enum sorted in alphabetical order.
   * 
   * @return The sorted array
   */
  public static SdlButton[] getSortedArray(){
    SdlButton[] result = values();
    Arrays.sort(result, new EnumComparator<SdlButton>());
    return result;
  }
  
  /**
   * Translates a legacy button (ButtonName) to this type of button (SdlButton).
   * 
   * @param legacyButton The legacy button to translate
   * @return The appropriate SdlButton for the input
   */
  public static SdlButton translateFromLegacy(ButtonName legacyButton){
    switch(legacyButton){
    case OK:
      return OK;
    case SEEKLEFT:
      return SEEK_LEFT;
    case SEEKRIGHT:
      return SEEK_RIGHT;
    case TUNEDOWN:
      return TUNE_DOWN;
    case TUNEUP:
      return TUNE_UP;
    case PRESET_0:
      return PRESET_0;
    case PRESET_1:
      return PRESET_1;
    case PRESET_2:
      return PRESET_2;
    case PRESET_3:
      return PRESET_3;
    case PRESET_4:
      return PRESET_4;
    case PRESET_5:
      return PRESET_5;
    case PRESET_6:
      return PRESET_6;
    case PRESET_7:
      return PRESET_7;
    case PRESET_8:
      return PRESET_8;
    case PRESET_9:
      return PRESET_9;
    case CUSTOM_BUTTON:
        return CUSTOM_BUTTON;
    default:
      return null;
    }
  }
  
  /**
   * Translates this type of button (SdlButton) to a legacy button (ButtonName).
   * 
   * @param sdlButton The new button to translate
   * @return The appropriate legacy button for the input
   */
  public static ButtonName translateToLegacy(SdlButton sdlButton){
    switch(sdlButton){
    case OK:
      return ButtonName.OK;
    case SEEK_LEFT:
      return ButtonName.SEEKLEFT;
    case SEEK_RIGHT:
      return ButtonName.SEEKRIGHT;
    case TUNE_DOWN:
      return ButtonName.TUNEDOWN;
    case TUNE_UP:
      return ButtonName.TUNEUP;
    case PRESET_0:
      return ButtonName.PRESET_0;
    case PRESET_1:
      return ButtonName.PRESET_1;
    case PRESET_2:
      return ButtonName.PRESET_2;
    case PRESET_3:
      return ButtonName.PRESET_3;
    case PRESET_4:
      return ButtonName.PRESET_4;
    case PRESET_5:
      return ButtonName.PRESET_5;
    case PRESET_6:
      return ButtonName.PRESET_6;
    case PRESET_7:
      return ButtonName.PRESET_7;
    case PRESET_8:
      return ButtonName.PRESET_8;
    case PRESET_9:
      return ButtonName.PRESET_9;
    case CUSTOM_BUTTON:
        return ButtonName.CUSTOM_BUTTON;
    default:
      return null;
    }
  }
  
  @Override
  public String toString(){
    return this.READABLE_NAME;
  }
}




Java Source Code List

com.livio.sdl.IdGenerator.java
com.livio.sdl.IpAddress.java
com.livio.sdl.SdlConstants.java
com.livio.sdl.SdlImageItem.java
com.livio.sdl.SdlLogMessage.java
com.livio.sdl.SdlRequestFactory.java
com.livio.sdl.SdlResponseFactory.java
com.livio.sdl.SdlResponseTracker.java
com.livio.sdl.SdlService.java
com.livio.sdl.adapters.SdlImageAdapter.java
com.livio.sdl.adapters.SdlMessageAdapter.java
com.livio.sdl.dialogs.BaseAlertDialog.java
com.livio.sdl.dialogs.BaseImageListDialog.java
com.livio.sdl.dialogs.BaseMultipleListViewDialog.java
com.livio.sdl.dialogs.BaseOkCancelDialog.java
com.livio.sdl.dialogs.BaseSingleListViewDialog.java
com.livio.sdl.dialogs.ImageListDialog.java
com.livio.sdl.dialogs.IndeterminateProgressDialog.java
com.livio.sdl.dialogs.JsonFlipperDialog.java
com.livio.sdl.dialogs.ListViewDialog.java
com.livio.sdl.dialogs.MultipleListViewDialog.java
com.livio.sdl.dialogs.SingleJsonDialog.java
com.livio.sdl.dialogs.TextViewAlertDialog.java
com.livio.sdl.dialogs.TextViewOkCancelDialog.java
com.livio.sdl.enums.EnumClickListener.java
com.livio.sdl.enums.EnumComparator.java
com.livio.sdl.enums.SdlButton.java
com.livio.sdl.enums.SdlCommand.java
com.livio.sdl.enums.SdlImageType.java
com.livio.sdl.enums.SdlInteractionMode.java
com.livio.sdl.enums.SdlLanguage.java
com.livio.sdl.enums.SdlSpeechCapability.java
com.livio.sdl.enums.SdlSystemAction.java
com.livio.sdl.enums.SdlTextAlignment.java
com.livio.sdl.enums.SdlTransportType.java
com.livio.sdl.enums.SdlUpdateMode.java
com.livio.sdl.enums.SdlVehicleData.java
com.livio.sdl.menu.CommandButton.java
com.livio.sdl.menu.MenuItem.java
com.livio.sdl.menu.MenuManager.java
com.livio.sdl.menu.SubmenuButton.java
com.livio.sdl.utils.AndroidUtils.java
com.livio.sdl.utils.ApplicationPreferences.java
com.livio.sdl.utils.Counter.java
com.livio.sdl.utils.DownCounter.java
com.livio.sdl.utils.MathUtils.java
com.livio.sdl.utils.SdlUtils.java
com.livio.sdl.utils.StringUtils.java
com.livio.sdl.utils.Timeout.java
com.livio.sdl.utils.UpCounter.java
com.livio.sdl.utils.WifiUtils.java
com.livio.sdl.viewhelpers.MinMaxInputFilter.java
com.livio.sdl.viewhelpers.SeekBarCalculator.java
com.livio.sdltester.HelpActivity.java
com.livio.sdltester.LivioSdlTesterPreferences.java
com.livio.sdltester.MainActivity.java
com.livio.sdltester.SdlTesterImageResource.java
com.livio.sdltester.dialogs.AddCommandDialog.java
com.livio.sdltester.dialogs.AddSubMenuDialog.java
com.livio.sdltester.dialogs.ButtonSubscriptionDialog.java
com.livio.sdltester.dialogs.ButtonUnsubscriptionDialog.java
com.livio.sdltester.dialogs.ChangeRegistrationDialog.java
com.livio.sdltester.dialogs.ChoiceItemDialog.java
com.livio.sdltester.dialogs.CreateInteractionChoiceSetDialog.java
com.livio.sdltester.dialogs.DeleteCommandDialog.java
com.livio.sdltester.dialogs.DeleteFileDialog.java
com.livio.sdltester.dialogs.DeleteInteractionDialog.java
com.livio.sdltester.dialogs.DeleteSubmenuDialog.java
com.livio.sdltester.dialogs.GetDtcsDialog.java
com.livio.sdltester.dialogs.PerformInteractionDialog.java
com.livio.sdltester.dialogs.PutFileDialog.java
com.livio.sdltester.dialogs.ReadDidsDialog.java
com.livio.sdltester.dialogs.ScrollableMessageDialog.java
com.livio.sdltester.dialogs.SdlAlertDialog.java
com.livio.sdltester.dialogs.SdlConnectionDialog.java
com.livio.sdltester.dialogs.SetAppIconDialog.java
com.livio.sdltester.dialogs.SetMediaClockTimerDialog.java
com.livio.sdltester.dialogs.ShowDialog.java
com.livio.sdltester.dialogs.SliderDialog.java
com.livio.sdltester.dialogs.SoftButtonItemDialog.java
com.livio.sdltester.dialogs.SoftButtonListDialog.java
com.livio.sdltester.dialogs.SpeakDialog.java