summaryrefslogtreecommitdiff
path: root/base/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
blob: cd721fec8bb64bd9eb2b7f87910181f09e183229 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from this 
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package com.smartdevicelink.proxy.rpc;

import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout;
import com.smartdevicelink.proxy.rpc.enums.KeypressMode;
import com.smartdevicelink.proxy.rpc.enums.Language;

import java.util.Hashtable;
import java.util.List;

/** This mode causes the interaction to immediately display a keyboard entry through the HMI.
 * 
 * <p><b>Parameter List</b></p>
 * <table border="1" rules="all">
 * 		<tr>
 * 			<th>Name</th>
 * 			<th>Type</th>
 * 			<th>Mandatory</th>
 *                 <th> Additional</th>
 * 			<th>Description</th>
 * 		</tr>
 * 		<tr>
 * 			<td>language</td>
 * 			<td>Language</td>
 * 			<td>false</td>
 *                 <td></td>
 * 			<td>The keyboard language. </td>
 * 		</tr>
 * 		<tr>
 * 			<td>keyboardLayout</td>
 * 			<td>KeyboardLayout</td>
 * 			<td>false</td>
 *                 <td></td>
 * 			<td>Desired keyboard layout.</td>
 * 		</tr>
 * 		<tr>
 * 			<td>sendDynamicEntry</td>
 * 			<td>Boolean</td>
 * 			<td>false</td>
 *                 <td></td>
 * 			<td>In this mode, all keypresses will be sent as they occur. If disabled, entire string of text will be returned only once submitted by user.If omitted, this value will be set to FALSE.</td>
 * 		</tr>
 * 		<tr>
 * 			<td>keypressMode</td>
 * 			<td>KeypressMode</td>
 * 			<td>False</td>
 *                 <td></td>
 * 			<td>Desired keypress mode.If omitted, this value will be set to RESEND_CURRENT_ENTRY. </td>
 * 		</tr>
 * 		<tr>
 * 			<td>limitedCharacterList</td>
 * 			<td>String</td>
 * 			<td>false</td>
 *                 <td>Array = true maxlength = 1 minsize = 1 maxsize = 100</td>
 * 			<td>Array of keyboard characters to enable. All omitted characters will be greyed out (disabled) on the keyboard. If omitted, the entire keyboard will be enabled.</td>
 * 		</tr>
 *
 * 		<tr>
 * 			<td>autoCompleteText</td>
 * 			<td>String</td>
 * 			<td>false</td>
 *                 <td>maxlength = 1000 </td>
 * 			<td>Allows an app to prepopulate the text field with a suggested or completed entry as the user types.</td>
 * 		</tr>
 * 		<tr>
 * 			<td>autoCompleteList</td>
 * 			<td>String</td>
 * 			<td>false</td>
 *                 <td>Array = true maxlength = 1000 minsize = 0 maxsize = 100</td>
 * 			<td>Allows an app to prepopulate the text field with a list of suggested or completed entry as the user types. Set to an empty array to remove the auto-complete list from the screen</td>
 * 		</tr>
 *  </table>
 * 
 * @since SmartDeviceLink 3.0
 *
 */

public class KeyboardProperties extends RPCStruct {
    public static final String KEY_KEYPRESS_MODE = "keypressMode";
	public static final String KEY_KEYBOARD_LAYOUT = "keyboardLayout";
	public static final String KEY_LIMITED_CHARACTER_LIST = "limitedCharacterList";
	@Deprecated public static final String KEY_AUTO_COMPLETE_TEXT = "autoCompleteText";
	public static final String KEY_AUTO_COMPLETE_LIST = "autoCompleteList";
	public static final String KEY_LANGUAGE = "language";
	
    private static final KeypressMode KEYPRESS_MODE_DEFAULT = KeypressMode.RESEND_CURRENT_ENTRY;

    public KeyboardProperties() {
        setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
    }

    public KeyboardProperties(Hashtable<String, Object> hash) {
        super(hash);
        if (!store.containsKey(KEY_KEYPRESS_MODE)) {
            setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
        }
    }

    public Language getLanguage() {
        return (Language) getObject(Language.class, KEY_LANGUAGE);
    }

    public void setLanguage(Language language) {
        setValue(KEY_LANGUAGE, language);
    }

    public KeyboardLayout getKeyboardLayout() {
        return (KeyboardLayout) getObject(KeyboardLayout.class, KEY_KEYBOARD_LAYOUT);
    }

    public void setKeyboardLayout(KeyboardLayout keyboardLayout) {
        setValue(KEY_KEYBOARD_LAYOUT, keyboardLayout);
    }

    public KeypressMode getKeypressMode() {
        KeypressMode kp = (KeypressMode) getObject(KeypressMode.class, KEY_KEYPRESS_MODE);
        if(kp == null){
            kp = KEYPRESS_MODE_DEFAULT;
        }
        return kp;
    }

    public void setKeypressMode(KeypressMode keypressMode) {
        if (keypressMode != null) {
            setValue(KEY_KEYPRESS_MODE, keypressMode);
        } else {
            setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
        }
    }

    @SuppressWarnings("unchecked")
    public List<String> getLimitedCharacterList() {
        return (List<String>) getObject(String.class, KEY_LIMITED_CHARACTER_LIST);
    }

    public void setLimitedCharacterList(List<String> limitedCharacterList) {
        setValue(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList);
    }

    /**
     * Gets the text that allows an app to prepopulate the text field with a suggested entry as the user types
     * @return String representing the suggestions text
     */
    @Deprecated
    public String getAutoCompleteText() {
        return (String) getObject(String.class, KEY_AUTO_COMPLETE_TEXT);
    }

    /**
     * Sets the text that allows an app to prepopulate the text field with a suggested entry as the user types
     * @param autoCompleteText String representing the suggestions text
     * @deprecated use {@link #setAutoCompleteList(List<String>)} instead
     */
    @Deprecated // Note: removing autoCompleteText setter will leave no way to provide auto complete suggestions on old head units that don't support autoCompleteList
    public void setAutoCompleteText(String autoCompleteText) {
        setValue(KEY_AUTO_COMPLETE_TEXT, autoCompleteText);
    }

    /**
     * Gets the list that allows an app to prepopulate the text field with a list of suggested or
     * completed entries as the user types.
     * @return List<String> representing the suggestions list
     */
    public List<String> getAutoCompleteList() {
        return (List<String>) getObject(String.class, KEY_AUTO_COMPLETE_LIST);
    }

    /**
     * Sets the lists that allows an app to prepopulate the text field with a list of suggested or
     * completed entries as the user types. Set to an empty array to remove the auto-complete list from the screen
     * @param autoCompleteList List<String> representing the suggestions list
     */
    public void setAutoCompleteList(List<String> autoCompleteList) {
        setValue(KEY_AUTO_COMPLETE_LIST, autoCompleteList);
    }
}