SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / Show.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 import java.util.Vector;\r
5 \r
6 import com.smartdevicelink.proxy.RPCRequest;\r
7 import com.smartdevicelink.proxy.constants.Names;\r
8 import com.smartdevicelink.proxy.rpc.enums.TextAlignment;\r
9 import com.smartdevicelink.util.DebugTool;\r
10 \r
11 /**\r
12  * Updates the application's display text area, regardless of whether or not\r
13  * this text area is visible to the user at the time of the request. The\r
14  * application's display text area remains unchanged until updated by subsequent\r
15  * calls to Show\r
16  * <p>\r
17  * The content of the application's display text area is visible to the user\r
18  * when the application's {@linkplain com.smartdevicelink.proxy.rpc.enums.HMILevel}\r
19  * is FULL or LIMITED, and the\r
20  * {@linkplain com.smartdevicelink.proxy.rpc.enums.SystemContext}=MAIN and no\r
21  * {@linkplain Alert} is in progress\r
22  * <p>\r
23  * The Show operation cannot be used to create an animated scrolling screen. To\r
24  * avoid distracting the driver, Show commands cannot be issued more than once\r
25  * every 4 seconds. Requests made more frequently than this will be rejected\r
26  * <p>\r
27  * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b>\r
28  * </p>\r
29  * \r
30  * @since SmartDeviceLink 1.0\r
31  * @see Alert\r
32  * @see SetMediaClockTimer\r
33  */\r
34 public class Show extends RPCRequest {\r
35 \r
36         /**\r
37          * Constructs a new Show object\r
38          */\r
39         public Show() {\r
40         super("Show");\r
41     }\r
42         /**\r
43          * Constructs a new Show object indicated by the Hashtable parameter\r
44          * <p>\r
45          * \r
46          * @param hash\r
47          *            The Hashtable to use\r
48          */\r
49     public Show(Hashtable hash) {\r
50         super(hash);\r
51     }\r
52         /**\r
53          * Gets the text displayed in a single-line display, or in the upper display\r
54          * line in a two-line display\r
55          * \r
56          * @return String -a String value representing the text displayed in a\r
57          *         single-line display, or in the upper display line in a two-line\r
58          *         display\r
59          */    \r
60     public String getMainField1() {\r
61         return (String) parameters.get(Names.mainField1);\r
62     }\r
63         /**\r
64          * Sets the text displayed in a single-line display, or in the upper display\r
65          * line in a two-line display\r
66          * \r
67          * @param mainField1\r
68          *            the String value representing the text displayed in a\r
69          *            single-line display, or in the upper display line in a\r
70          *            two-line display\r
71          *            <p>\r
72          *            <b>Notes: </b>\r
73          *            <ul>\r
74          *            <li>If this parameter is omitted, the text of mainField1 does\r
75          *            not change</li>\r
76          *            <li>If this parameter is an empty string, the field will be\r
77          *            cleared</li>\r
78          *            </ul>\r
79          */    \r
80     public void setMainField1(String mainField1) {\r
81         if (mainField1 != null) {\r
82             parameters.put(Names.mainField1, mainField1);\r
83         } else {\r
84                 parameters.remove(Names.mainField1);\r
85         }\r
86     }\r
87         /**\r
88          * Gets the text displayed on the second display line of a two-line display\r
89          * \r
90          * @return String -a String value representing the text displayed on the\r
91          *         second display line of a two-line display\r
92          */    \r
93     public String getMainField2() {\r
94         return (String) parameters.get(Names.mainField2);\r
95     }\r
96         /**\r
97          * Sets the text displayed on the second display line of a two-line display\r
98          * \r
99          * @param mainField2\r
100          *            the String value representing the text displayed on the second\r
101          *            display line of a two-line display\r
102          *            <p>\r
103          *            <b>Notes: </b>\r
104          *            <ul>\r
105          *            <li>If this parameter is omitted, the text of mainField2 does\r
106          *            not change</li>\r
107          *            <li>If this parameter is an empty string, the field will be\r
108          *            cleared</li>\r
109          *            <li>If provided and the display is a single-line display, the\r
110          *            parameter is ignored</li>\r
111          *            <li>Maxlength = 500</li>\r
112          *            </ul>\r
113          */    \r
114     public void setMainField2(String mainField2) {\r
115         if (mainField2 != null) {\r
116             parameters.put(Names.mainField2, mainField2);\r
117         } else {\r
118                 parameters.remove(Names.mainField2);\r
119         }\r
120     }\r
121 \r
122         /**\r
123          * Gets the text displayed on the first display line of the second page\r
124          * \r
125          * @return String -a String value representing the text displayed on the\r
126          *         first display line of the second page\r
127          * @since SmartDeviceLink 2.0\r
128          */\r
129     public String getMainField3() {\r
130         return (String) parameters.get(Names.mainField3);\r
131     }\r
132 \r
133         /**\r
134          * Sets the text displayed on the first display line of the second page\r
135          * \r
136          * @param mainField3\r
137          *            the String value representing the text displayed on the first\r
138          *            display line of the second page\r
139          *            <p>\r
140          *            <b>Notes: </b>\r
141          *            <ul>\r
142          *            <li>If this parameter is omitted, the text of mainField3 does\r
143          *            not change</li>\r
144          *            <li>If this parameter is an empty string, the field will be\r
145          *            cleared</li>\r
146          *            <li>If provided and the display is a single-line display, the\r
147          *            parameter is ignored</li>\r
148          *            <li>Maxlength = 500</li>\r
149          *            </ul>\r
150          * @since SmartDeviceLink 2.0\r
151          */\r
152     public void setMainField3(String mainField3) {\r
153         if (mainField3 != null) {\r
154             parameters.put(Names.mainField3, mainField3);\r
155         } else {\r
156                 parameters.remove(Names.mainField3);\r
157         }\r
158     }\r
159 \r
160         /**\r
161          * Gets the text displayed on the second display line of the second page\r
162          * \r
163          * @return String -a String value representing the text displayed on the\r
164          *         first display line of the second page\r
165          * @since SmartDeviceLink 2.0\r
166          */\r
167     public String getMainField4() {\r
168         return (String) parameters.get(Names.mainField4);\r
169     }\r
170 \r
171         /**\r
172          * Sets the text displayed on the second display line of the second page\r
173          * \r
174          * @param mainField4\r
175          *            the String value representing the text displayed on the second\r
176          *            display line of the second page\r
177          *            <p>\r
178          *            <b>Notes: </b>\r
179          *            <ul>\r
180          *            <li>If this parameter is omitted, the text of mainField4 does\r
181          *            not change</li>\r
182          *            <li>If this parameter is an empty string, the field will be\r
183          *            cleared</li>\r
184          *            <li>If provided and the display is a single-line display, the\r
185          *            parameter is ignored</li>\r
186          *            <li>Maxlength = 500</li>\r
187          *            </ul>\r
188          * @since SmartDeviceLink 2.0\r
189          */\r
190     public void setMainField4(String mainField4) {\r
191         if (mainField4 != null) {\r
192             parameters.put(Names.mainField4, mainField4);\r
193         } else {\r
194                 parameters.remove(Names.mainField4);\r
195         }\r
196     }\r
197         /**\r
198          * Gets the alignment that Specifies how mainField1 and mainField2 text\r
199          * should be aligned on display\r
200          * \r
201          * @return TextAlignment -an Enumeration value\r
202          */    \r
203     public TextAlignment getAlignment() {\r
204         Object obj = parameters.get(Names.alignment);\r
205         if (obj instanceof TextAlignment) {\r
206             return (TextAlignment) obj;\r
207         } else if (obj instanceof String) {\r
208             TextAlignment theCode = null;\r
209             try {\r
210                 theCode = TextAlignment.valueForString((String) obj);\r
211             } catch (Exception e) {\r
212                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.alignment, e);\r
213             }\r
214             return theCode;\r
215         }\r
216         return null;\r
217     }\r
218         /**\r
219          * Sets the alignment that Specifies how mainField1 and mainField2 text\r
220          * should be aligned on display\r
221          * \r
222          * @param alignment\r
223          *            an Enumeration value\r
224          *            <p>\r
225          *            <b>Notes: </b>\r
226          *            <ul>\r
227          *            <li>Applies only to mainField1 and mainField2 provided on this\r
228          *            call, not to what is already showing in display</li>\r
229          *            <li>If this parameter is omitted, text in both mainField1 and\r
230          *            mainField2 will be centered</li>\r
231          *            <li>Has no effect with navigation display</li>\r
232          *            </ul>\r
233          */    \r
234     public void setAlignment(TextAlignment alignment) {\r
235         if (alignment != null) {\r
236             parameters.put(Names.alignment, alignment);\r
237         } else {\r
238                 parameters.remove(Names.alignment);\r
239         }\r
240     }\r
241         /**\r
242          * Gets text in the Status Bar\r
243          * \r
244          * @return String -the value in the Status Bar\r
245          */    \r
246     public String getStatusBar() {\r
247         return (String) parameters.get(Names.statusBar);\r
248     }\r
249         /**\r
250          * Sets text in the Status Bar\r
251          * \r
252          * @param statusBar\r
253          *            a String representing the text you want to add in the Status\r
254          *            Bar\r
255          *            <p>\r
256          *            <b>Notes: </b><i>The status bar only exists on navigation\r
257          *            displays</i><br/>\r
258          *            <ul>\r
259          *            <li>If this parameter is omitted, the status bar text will\r
260          *            remain unchanged</li>\r
261          *            <li>If this parameter is an empty string, the field will be\r
262          *            cleared</li>\r
263          *            <li>If provided and the display has no status bar, this\r
264          *            parameter is ignored</li>\r
265          *            </ul>\r
266          */    \r
267     public void setStatusBar(String statusBar) {\r
268         if (statusBar != null) {\r
269             parameters.put(Names.statusBar, statusBar);\r
270         } else {\r
271                 parameters.remove(Names.statusBar);\r
272         }\r
273     }\r
274         /**\r
275          * Gets the String value of the MediaClock\r
276          * \r
277          * @return String -a String value of the MediaClock\r
278          */    \r
279     public String getMediaClock() {\r
280         return (String) parameters.get(Names.mediaClock);\r
281     }\r
282         /**\r
283          * Sets the value for the MediaClock field using a format described in the\r
284          * MediaClockFormat enumeration\r
285          * \r
286          * @param mediaClock\r
287          *            a String value for the MdaiaClock\r
288          *            <p>\r
289          *            <b>Notes: </b><br/>\r
290          *            <ul>\r
291          *            <li>Must be properly formatted as described in the\r
292          *            MediaClockFormat enumeration</li>\r
293          *            <li>If a value of five spaces is provided, this will clear\r
294          *            that field on the display (i.e. the media clock timer field\r
295          *            will not display anything)</li>\r
296          *            </ul>\r
297          */    \r
298     public void setMediaClock(String mediaClock) {\r
299         if (mediaClock != null) {\r
300             parameters.put(Names.mediaClock, mediaClock);\r
301         } else {\r
302                 parameters.remove(Names.mediaClock);\r
303         }\r
304     }\r
305         /**\r
306          * Gets the text in the track field\r
307          * \r
308          * @return String -a String displayed in the track field\r
309          */    \r
310     public String getMediaTrack() {\r
311         return (String) parameters.get(Names.mediaTrack);\r
312     }\r
313         /**\r
314          * Sets the text in the track field\r
315          * \r
316          * @param mediaTrack\r
317          *            a String value disaplayed in the track field\r
318          *            <p>\r
319          *            <b>Notes: </b><br/>\r
320          *            <ul>\r
321          *            <li>If parameter is omitted, the track field remains unchanged</li>\r
322          *            <li>If an empty string is provided, the field will be cleared</li>\r
323          *            <li>This field is only valid for media applications on navigation displays</li>\r
324          *            </ul>\r
325          */    \r
326     public void setMediaTrack(String mediaTrack) {\r
327         if (mediaTrack != null) {\r
328             parameters.put(Names.mediaTrack, mediaTrack);\r
329         } else {\r
330                 parameters.remove(Names.mediaTrack);\r
331         }\r
332     }\r
333 \r
334         /**\r
335          * Sets an image to be shown on supported displays\r
336          * \r
337          * @param graphic\r
338          *            the value representing the image shown on supported displays\r
339          *            <p>\r
340          *            <b>Notes: </b>If omitted on supported displays, the displayed\r
341          *            graphic shall not change<br/>\r
342          * @since SmartDeviceLink 2.0\r
343          */\r
344     public void setGraphic(Image graphic) {\r
345         if (graphic != null) {\r
346             parameters.put(Names.graphic, graphic);\r
347         } else {\r
348                 parameters.remove(Names.graphic);\r
349         }\r
350     }\r
351 \r
352         /**\r
353          * Gets an image to be shown on supported displays\r
354          * \r
355          * @return Image -the value representing the image shown on supported\r
356          *         displays\r
357          * @since SmartDeviceLink 2.0\r
358          */\r
359     public Image getGraphic() {\r
360         Object obj = parameters.get(Names.graphic);\r
361         if (obj instanceof Image) {\r
362             return (Image) obj;\r
363         } else if (obj instanceof Hashtable) {\r
364                 try {\r
365                         return new Image((Hashtable) obj);\r
366             } catch (Exception e) {\r
367                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.graphic, e);\r
368             }\r
369         }\r
370         return null;\r
371     }\r
372 \r
373         /**\r
374          * Gets the Soft buttons defined by the App\r
375          * \r
376          * @return Vector<SoftButton> -a Vector value representing the Soft buttons\r
377          *         defined by the App\r
378          * @since SmartDeviceLink 2.0\r
379          */\r
380     public Vector<SoftButton> getSoftButtons() {\r
381         if (parameters.get(Names.softButtons) instanceof Vector<?>) {\r
382                 Vector<?> list = (Vector<?>)parameters.get(Names.softButtons);\r
383                 if (list != null && list.size() > 0) {\r
384                     Object obj = list.get(0);\r
385                     if (obj instanceof SoftButton) {\r
386                         return (Vector<SoftButton>) list;\r
387                     } else if (obj instanceof Hashtable) {\r
388                         Vector<SoftButton> newList = new Vector<SoftButton>();\r
389                         for (Object hashObj : list) {\r
390                             newList.add(new SoftButton((Hashtable)hashObj));\r
391                         }\r
392                         return newList;\r
393                     }\r
394                 }\r
395         }\r
396         return null;\r
397     }\r
398 \r
399         /**\r
400          * Sets the the Soft buttons defined by the App\r
401          * \r
402          * @param softButtons\r
403          *            a Vector value represemting the Soft buttons defined by the\r
404          *            App\r
405          *            <p>\r
406          *            <b>Notes: </b><br/>\r
407          *            <ul>\r
408          *            <li>If omitted on supported displays, the currently displayed\r
409          *            SoftButton values will not change</li>\r
410          *            <li>Array Minsize: 0</li>\r
411          *            <li>Array Maxsize: 8</li>\r
412          *            </ul>\r
413          * \r
414          * @since SmartDeviceLink 2.0\r
415          */\r
416     public void setSoftButtons(Vector<SoftButton> softButtons) {\r
417         if (softButtons != null) {\r
418             parameters.put(Names.softButtons, softButtons);\r
419         } else {\r
420                 parameters.remove(Names.softButtons);\r
421         }\r
422     }\r
423 \r
424         /**\r
425          * Gets the Custom Presets defined by the App\r
426          * \r
427          * @return Vector<String> - a Vector value representing the Custom presets\r
428          *         defined by the App\r
429          * @since SmartDeviceLink 2.0\r
430          */\r
431     public Vector<String> getCustomPresets() {\r
432         if (parameters.get(Names.customPresets) instanceof Vector<?>) {\r
433                 Vector<?> list = (Vector<?>)parameters.get(Names.customPresets);\r
434                 if (list != null && list.size()>0) {\r
435                         Object obj = list.get(0);\r
436                         if (obj instanceof String) {\r
437                                 return (Vector<String>) list;\r
438                         }\r
439                 }\r
440         }\r
441         return null;\r
442     }\r
443 \r
444         /**\r
445          * Sets the Custom Presets defined by the App\r
446          * \r
447          * @param customPresets\r
448          *            a Vector value representing the Custom Presets defined by the\r
449          *            App\r
450          *            <p>\r
451          *            <ul>\r
452          *            <li>If omitted on supported displays, the presets will be shown as not defined</li>\r
453          *            <li>Array Minsize: 0</li>\r
454          *            <li>Array Maxsize: 6</li>\r
455          *            </ul>\r
456          * @since SmartDeviceLink 2.0\r
457          */\r
458     public void setCustomPresets(Vector<String> customPresets) {\r
459         if (customPresets != null) {\r
460             parameters.put(Names.customPresets, customPresets);\r
461         } else {\r
462                 parameters.remove(Names.customPresets);\r
463         }\r
464     }\r
465 }\r