summaryrefslogtreecommitdiff
path: root/SDL_Android/SmartDeviceLinkProxyAndroid/src/com/smartdevicelink/proxy/rpc/enums/ButtonName.java
blob: 8ab57d3326d60a26a99894846e98e4663af044eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.smartdevicelink.proxy.rpc.enums;

/**
 * <p>
 * Defines logical buttons which, on a given SMARTDEVICELINK 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 SMARTDEVICELINK unit. For example, the developer can rely upon the OK
 * button having the same meaning to the user across SMARTDEVICELINK 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 SMARTDEVICELINK unit implements by
 * interrogating the ButtonCapabilities parameter of the
 * RegisterAppInterface response.
 * </p>
 * 
 * @since SmartDeviceLink 1.0
 */
public enum ButtonName{
	/**
	 * 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,
	/**
	 * 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
	 */
	SEEKLEFT,
	/**
	 * 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
	 */
	SEEKRIGHT,
	/**
	 * Represents a turn of the tuner knob in the clockwise direction one tick.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	TUNEUP,
	/**
	 * Represents a turn of the tuner knob in the counter-clockwise direction
	 * one tick.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	TUNEDOWN,
	/**
	 * Represents the preset 0 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_0,
	/**
	 * Represents the preset 1 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_1,
	/**
	 * Represents the preset 2 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_2,
	/**
	 * Represents the preset 3 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_3,
	/**
	 * Represents the preset 4 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_4,
	/**
	 * Represents the preset 5 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_5,
	/**
	 * Represents the preset 6 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_6,
	/**
	 * Represents the preset 7 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_7,
	/**
	 * Represents the preset 8 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_8,
	/**
	 * Represents the preset 9 button.
	 * 
	 * @since SmartDeviceLink 1.0
	 */
	PRESET_9, CUSTOM_BUTTON;

    public static ButtonName valueForString(String value) {
        return valueOf(value);
    }
    
    /**
     * indexForPresetButton returns the integer index for preset buttons
     * which match the preset order. E.G.: indexForPresetButton(PRESET_1)
     * returns the value 1. If the buttonName given is not a preset button,
     * the method will return null.
     *  
     * @param buttonName
     * @return Integer
     */
    public static Integer indexForPresetButton(ButtonName buttonName) {
    	
    	Integer returnIndex = null;
    	
    	switch(buttonName) {        	
        	case PRESET_0:
        		returnIndex = 0;
        		break;
        	case PRESET_1:
        		returnIndex = 1;
        		break;
        	case PRESET_2:
        		returnIndex = 2;
        		break;
        	case PRESET_3:
        		returnIndex = 3;
        		break;
        	case PRESET_4:
        		returnIndex = 4;
        		break;
        	case PRESET_5:
        		returnIndex = 5;
        		break;
        	case PRESET_6:
        		returnIndex = 6;
        		break;
        	case PRESET_7:
        		returnIndex = 7;
        		break;
        	case PRESET_8:
        		returnIndex = 8;
        		break;
        	case PRESET_9:
        		returnIndex = 9;
        		break;
    	}
    	
    	return returnIndex;
    }
}