1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.text; 18 19 import android.text.TextUtils; 20 21 /** 22 * Bit definitions for an integer defining the basic content type of text 23 * held in an {@link Editable} object. 24 */ 25 public interface InputType { 26 /** 27 * Mask of bits that determine the overall class 28 * of text being given. Currently supported classes are: 29 * {@link #TYPE_CLASS_TEXT}, {@link #TYPE_CLASS_NUMBER}, 30 * {@link #TYPE_CLASS_PHONE}, {@link #TYPE_CLASS_DATETIME}. 31 * If the class is not one you 32 * understand, assume {@link #TYPE_CLASS_TEXT} with NO variation 33 * or flags. 34 */ 35 public static final int TYPE_MASK_CLASS = 0x0000000f; 36 37 /** 38 * Mask of bits that determine the variation of 39 * the base content class. 40 */ 41 public static final int TYPE_MASK_VARIATION = 0x00000ff0; 42 43 /** 44 * Mask of bits that provide addition bit flags 45 * of options. 46 */ 47 public static final int TYPE_MASK_FLAGS = 0x00fff000; 48 49 /** 50 * Special content type for when no explicit type has been specified. 51 * This should be interpreted to mean that the target input connection 52 * is not rich, it can not process and show things like candidate text nor 53 * retrieve the current text, so the input method will need to run in a 54 * limited "generate key events" mode. 55 */ 56 public static final int TYPE_NULL = 0x00000000; 57 58 // ---------------------------------------------------------------------- 59 // ---------------------------------------------------------------------- 60 // ---------------------------------------------------------------------- 61 62 /** 63 * Class for normal text. This class supports the following flags (only 64 * one of which should be set): 65 * {@link #TYPE_TEXT_FLAG_CAP_CHARACTERS}, 66 * {@link #TYPE_TEXT_FLAG_CAP_WORDS}, and. 67 * {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. It also supports the 68 * following variations: 69 * {@link #TYPE_TEXT_VARIATION_NORMAL}, and 70 * {@link #TYPE_TEXT_VARIATION_URI}. If you do not recognize the 71 * variation, normal should be assumed. 72 */ 73 public static final int TYPE_CLASS_TEXT = 0x00000001; 74 75 /** 76 * Flag for {@link #TYPE_CLASS_TEXT}: capitalize all characters. Overrides 77 * {@link #TYPE_TEXT_FLAG_CAP_WORDS} and 78 * {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This value is explicitly defined 79 * to be the same as {@link TextUtils#CAP_MODE_CHARACTERS}. 80 */ 81 public static final int TYPE_TEXT_FLAG_CAP_CHARACTERS = 0x00001000; 82 83 /** 84 * Flag for {@link #TYPE_CLASS_TEXT}: capitalize first character of 85 * all words. Overrides {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This 86 * value is explicitly defined 87 * to be the same as {@link TextUtils#CAP_MODE_WORDS}. 88 */ 89 public static final int TYPE_TEXT_FLAG_CAP_WORDS = 0x00002000; 90 91 /** 92 * Flag for {@link #TYPE_CLASS_TEXT}: capitalize first character of 93 * each sentence. This value is explicitly defined 94 * to be the same as {@link TextUtils#CAP_MODE_SENTENCES}. 95 */ 96 public static final int TYPE_TEXT_FLAG_CAP_SENTENCES = 0x00004000; 97 98 /** 99 * Flag for {@link #TYPE_CLASS_TEXT}: the user is entering free-form 100 * text that should have auto-correction applied to it. 101 */ 102 public static final int TYPE_TEXT_FLAG_AUTO_CORRECT = 0x00008000; 103 104 /** 105 * Flag for {@link #TYPE_CLASS_TEXT}: the text editor is performing 106 * auto-completion of the text being entered based on its own semantics, 107 * which it will present to the user as they type. This generally means 108 * that the input method should not be showing candidates itself, but can 109 * expect for the editor to supply its own completions/candidates from 110 * {@link android.view.inputmethod.InputMethodSession#displayCompletions 111 * InputMethodSession.displayCompletions()} as a result of the editor calling 112 * {@link android.view.inputmethod.InputMethodManager#displayCompletions 113 * InputMethodManager.displayCompletions()}. 114 */ 115 public static final int TYPE_TEXT_FLAG_AUTO_COMPLETE = 0x00010000; 116 117 /** 118 * Flag for {@link #TYPE_CLASS_TEXT}: multiple lines of text can be 119 * entered into the field. If this flag is not set, the text field 120 * will be constrained to a single line. 121 */ 122 public static final int TYPE_TEXT_FLAG_MULTI_LINE = 0x00020000; 123 124 /** 125 * Flag for {@link #TYPE_CLASS_TEXT}: the regular text view associated 126 * with this should not be multi-line, but when a fullscreen input method 127 * is providing text it should use multiple lines if it can. 128 */ 129 public static final int TYPE_TEXT_FLAG_IME_MULTI_LINE = 0x00040000; 130 131 /** 132 * Flag for {@link #TYPE_CLASS_TEXT}: the input method does not need to 133 * display any dictionary-based candidates. This is useful for text views that 134 * do not contain words from the language and do not benefit from any 135 * dictionary-based completions or corrections. It overrides the 136 * {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} value when set. 137 */ 138 public static final int TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000; 139 140 // ---------------------------------------------------------------------- 141 142 /** 143 * Default variation of {@link #TYPE_CLASS_TEXT}: plain old normal text. 144 */ 145 public static final int TYPE_TEXT_VARIATION_NORMAL = 0x00000000; 146 147 /** 148 * Variation of {@link #TYPE_CLASS_TEXT}: entering a URI. 149 */ 150 public static final int TYPE_TEXT_VARIATION_URI = 0x00000010; 151 152 /** 153 * Variation of {@link #TYPE_CLASS_TEXT}: entering an e-mail address. 154 */ 155 public static final int TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 0x00000020; 156 157 /** 158 * Variation of {@link #TYPE_CLASS_TEXT}: entering the subject line of 159 * an e-mail. 160 */ 161 public static final int TYPE_TEXT_VARIATION_EMAIL_SUBJECT = 0x00000030; 162 163 /** 164 * Variation of {@link #TYPE_CLASS_TEXT}: entering a short, possibly informal 165 * message such as an instant message or a text message. 166 */ 167 public static final int TYPE_TEXT_VARIATION_SHORT_MESSAGE = 0x00000040; 168 169 /** 170 * Variation of {@link #TYPE_CLASS_TEXT}: entering the content of a long, possibly 171 * formal message such as the body of an e-mail. 172 */ 173 public static final int TYPE_TEXT_VARIATION_LONG_MESSAGE = 0x00000050; 174 175 /** 176 * Variation of {@link #TYPE_CLASS_TEXT}: entering the name of a person. 177 */ 178 public static final int TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000060; 179 180 /** 181 * Variation of {@link #TYPE_CLASS_TEXT}: entering a postal mailing address. 182 */ 183 public static final int TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000070; 184 185 /** 186 * Variation of {@link #TYPE_CLASS_TEXT}: entering a password. 187 */ 188 public static final int TYPE_TEXT_VARIATION_PASSWORD = 0x00000080; 189 190 /** 191 * Variation of {@link #TYPE_CLASS_TEXT}: entering a password, which should 192 * be visible to the user. 193 */ 194 public static final int TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 0x00000090; 195 196 /** 197 * Variation of {@link #TYPE_CLASS_TEXT}: entering text inside of a web form. 198 */ 199 public static final int TYPE_TEXT_VARIATION_WEB_EDIT_TEXT = 0x000000a0; 200 201 /** 202 * Variation of {@link #TYPE_CLASS_TEXT}: entering text to filter contents 203 * of a list etc. 204 */ 205 public static final int TYPE_TEXT_VARIATION_FILTER = 0x000000b0; 206 207 /** 208 * Variation of {@link #TYPE_CLASS_TEXT}: entering text for phonetic 209 * pronunciation, such as a phonetic name field in contacts. 210 */ 211 public static final int TYPE_TEXT_VARIATION_PHONETIC = 0x000000c0; 212 213 // ---------------------------------------------------------------------- 214 // ---------------------------------------------------------------------- 215 // ---------------------------------------------------------------------- 216 217 /** 218 * Class for numeric text. This class supports the following flag: 219 * {@link #TYPE_NUMBER_FLAG_SIGNED} and 220 * {@link #TYPE_NUMBER_FLAG_DECIMAL}. 221 */ 222 public static final int TYPE_CLASS_NUMBER = 0x00000002; 223 224 /** 225 * Flag of {@link #TYPE_CLASS_NUMBER}: the number is signed, allowing 226 * a positive or negative sign at the start. 227 */ 228 public static final int TYPE_NUMBER_FLAG_SIGNED = 0x00001000; 229 230 /** 231 * Flag of {@link #TYPE_CLASS_NUMBER}: the number is decimal, allowing 232 * a decimal point to provide fractional values. 233 */ 234 public static final int TYPE_NUMBER_FLAG_DECIMAL = 0x00002000; 235 236 // ---------------------------------------------------------------------- 237 // ---------------------------------------------------------------------- 238 // ---------------------------------------------------------------------- 239 240 /** 241 * Class for a phone number. This class currently supports no variations 242 * or flags. 243 */ 244 public static final int TYPE_CLASS_PHONE = 0x00000003; 245 246 // ---------------------------------------------------------------------- 247 // ---------------------------------------------------------------------- 248 // ---------------------------------------------------------------------- 249 250 /** 251 * Class for dates and times. It supports the 252 * following variations: 253 * {@link #TYPE_DATETIME_VARIATION_NORMAL} 254 * {@link #TYPE_DATETIME_VARIATION_DATE}, and 255 * {@link #TYPE_DATETIME_VARIATION_TIME},. 256 */ 257 public static final int TYPE_CLASS_DATETIME = 0x00000004; 258 259 /** 260 * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering 261 * both a date and time. 262 */ 263 public static final int TYPE_DATETIME_VARIATION_NORMAL = 0x00000000; 264 265 /** 266 * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering 267 * only a date. 268 */ 269 public static final int TYPE_DATETIME_VARIATION_DATE = 0x00000010; 270 271 /** 272 * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering 273 * only a time. 274 */ 275 public static final int TYPE_DATETIME_VARIATION_TIME = 0x00000020; 276 } 277