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
17package android.view.inputmethod;
18
19import android.annotation.Nullable;
20import android.os.Bundle;
21import android.os.LocaleList;
22import android.os.Parcel;
23import android.os.Parcelable;
24import android.text.InputType;
25import android.text.TextUtils;
26import android.util.Printer;
27
28import java.util.Arrays;
29
30/**
31 * An EditorInfo describes several attributes of a text editing object
32 * that an input method is communicating with (typically an EditText), most
33 * importantly the type of text content it contains and the current cursor position.
34 */
35public class EditorInfo implements InputType, Parcelable {
36    /**
37     * Masks for {@link inputType}
38     *
39     * <pre>
40     * |-------|-------|-------|-------|
41     *                              1111 TYPE_MASK_CLASS
42     *                      11111111     TYPE_MASK_VARIATION
43     *          111111111111             TYPE_MASK_FLAGS
44     * |-------|-------|-------|-------|
45     *                                   TYPE_NULL
46     * |-------|-------|-------|-------|
47     *                                 1 TYPE_CLASS_TEXT
48     *                             1     TYPE_TEXT_VARIATION_URI
49     *                            1      TYPE_TEXT_VARIATION_EMAIL_ADDRESS
50     *                            11     TYPE_TEXT_VARIATION_EMAIL_SUBJECT
51     *                           1       TYPE_TEXT_VARIATION_SHORT_MESSAGE
52     *                           1 1     TYPE_TEXT_VARIATION_LONG_MESSAGE
53     *                           11      TYPE_TEXT_VARIATION_PERSON_NAME
54     *                           111     TYPE_TEXT_VARIATION_POSTAL_ADDRESS
55     *                          1        TYPE_TEXT_VARIATION_PASSWORD
56     *                          1  1     TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
57     *                          1 1      TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
58     *                          1 11     TYPE_TEXT_VARIATION_FILTER
59     *                          11       TYPE_TEXT_VARIATION_PHONETIC
60     *                          11 1     TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
61     *                          111      TYPE_TEXT_VARIATION_WEB_PASSWORD
62     *                     1             TYPE_TEXT_FLAG_CAP_CHARACTERS
63     *                    1              TYPE_TEXT_FLAG_CAP_WORDS
64     *                   1               TYPE_TEXT_FLAG_CAP_SENTENCES
65     *                  1                TYPE_TEXT_FLAG_AUTO_CORRECT
66     *                 1                 TYPE_TEXT_FLAG_AUTO_COMPLETE
67     *                1                  TYPE_TEXT_FLAG_MULTI_LINE
68     *               1                   TYPE_TEXT_FLAG_IME_MULTI_LINE
69     *              1                    TYPE_TEXT_FLAG_NO_SUGGESTIONS
70     * |-------|-------|-------|-------|
71     *                                1  TYPE_CLASS_NUMBER
72     *                             1     TYPE_NUMBER_VARIATION_PASSWORD
73     *                     1             TYPE_NUMBER_FLAG_SIGNED
74     *                    1              TYPE_NUMBER_FLAG_DECIMAL
75     * |-------|-------|-------|-------|
76     *                                11 TYPE_CLASS_PHONE
77     * |-------|-------|-------|-------|
78     *                               1   TYPE_CLASS_DATETIME
79     *                             1     TYPE_DATETIME_VARIATION_DATE
80     *                            1      TYPE_DATETIME_VARIATION_TIME
81     * |-------|-------|-------|-------|</pre>
82     */
83
84    /**
85     * The content type of the text box, whose bits are defined by
86     * {@link InputType}.
87     *
88     * @see InputType
89     * @see #TYPE_MASK_CLASS
90     * @see #TYPE_MASK_VARIATION
91     * @see #TYPE_MASK_FLAGS
92     */
93    public int inputType = TYPE_NULL;
94
95    /**
96     * Set of bits in {@link #imeOptions} that provide alternative actions
97     * associated with the "enter" key.  This both helps the IME provide
98     * better feedback about what the enter key will do, and also allows it
99     * to provide alternative mechanisms for providing that command.
100     */
101    public static final int IME_MASK_ACTION = 0x000000ff;
102
103    /**
104     * Bits of {@link #IME_MASK_ACTION}: no specific action has been
105     * associated with this editor, let the editor come up with its own if
106     * it can.
107     */
108    public static final int IME_ACTION_UNSPECIFIED = 0x00000000;
109
110    /**
111     * Bits of {@link #IME_MASK_ACTION}: there is no available action.
112     */
113    public static final int IME_ACTION_NONE = 0x00000001;
114
115    /**
116     * Bits of {@link #IME_MASK_ACTION}: the action key performs a "go"
117     * operation to take the user to the target of the text they typed.
118     * Typically used, for example, when entering a URL.
119     */
120    public static final int IME_ACTION_GO = 0x00000002;
121
122    /**
123     * Bits of {@link #IME_MASK_ACTION}: the action key performs a "search"
124     * operation, taking the user to the results of searching for the text
125     * they have typed (in whatever context is appropriate).
126     */
127    public static final int IME_ACTION_SEARCH = 0x00000003;
128
129    /**
130     * Bits of {@link #IME_MASK_ACTION}: the action key performs a "send"
131     * operation, delivering the text to its target.  This is typically used
132     * when composing a message in IM or SMS where sending is immediate.
133     */
134    public static final int IME_ACTION_SEND = 0x00000004;
135
136    /**
137     * Bits of {@link #IME_MASK_ACTION}: the action key performs a "next"
138     * operation, taking the user to the next field that will accept text.
139     */
140    public static final int IME_ACTION_NEXT = 0x00000005;
141
142    /**
143     * Bits of {@link #IME_MASK_ACTION}: the action key performs a "done"
144     * operation, typically meaning there is nothing more to input and the
145     * IME will be closed.
146     */
147    public static final int IME_ACTION_DONE = 0x00000006;
148
149    /**
150     * Bits of {@link #IME_MASK_ACTION}: like {@link #IME_ACTION_NEXT}, but
151     * for moving to the previous field.  This will normally not be used to
152     * specify an action (since it precludes {@link #IME_ACTION_NEXT}), but
153     * can be returned to the app if it sets {@link #IME_FLAG_NAVIGATE_PREVIOUS}.
154     */
155    public static final int IME_ACTION_PREVIOUS = 0x00000007;
156
157    /**
158     * Flag of {@link #imeOptions}: used to request that the IME should not update any personalized
159     * data such as typing history and personalized language model based on what the user typed on
160     * this text editing object.  Typical use cases are:
161     * <ul>
162     *     <li>When the application is in a special mode, where user's activities are expected to be
163     *     not recorded in the application's history.  Some web browsers and chat applications may
164     *     have this kind of modes.</li>
165     *     <li>When storing typing history does not make much sense.  Specifying this flag in typing
166     *     games may help to avoid typing history from being filled up with words that the user is
167     *     less likely to type in their daily life.  Another example is that when the application
168     *     already knows that the expected input is not a valid word (e.g. a promotion code that is
169     *     not a valid word in any natural language).</li>
170     * </ul>
171     *
172     * <p>Applications need to be aware that the flag is not a guarantee, and some IMEs may not
173     * respect it.</p>
174     */
175    public static final int IME_FLAG_NO_PERSONALIZED_LEARNING = 0x1000000;
176
177    /**
178     * Flag of {@link #imeOptions}: used to request that the IME never go
179     * into fullscreen mode.
180     * By default, IMEs may go into full screen mode when they think
181     * it's appropriate, for example on small screens in landscape
182     * orientation where displaying a software keyboard may occlude
183     * such a large portion of the screen that the remaining part is
184     * too small to meaningfully display the application UI.
185     * If this flag is set, compliant IMEs will never go into full screen mode,
186     * and always leave some space to display the application UI.
187     * Applications need to be aware that the flag is not a guarantee, and
188     * some IMEs may ignore it.
189     */
190    public static final int IME_FLAG_NO_FULLSCREEN = 0x2000000;
191
192    /**
193     * Flag of {@link #imeOptions}: like {@link #IME_FLAG_NAVIGATE_NEXT}, but
194     * specifies there is something interesting that a backward navigation
195     * can focus on.  If the user selects the IME's facility to backward
196     * navigate, this will show up in the application as an {@link #IME_ACTION_PREVIOUS}
197     * at {@link InputConnection#performEditorAction(int)
198     * InputConnection.performEditorAction(int)}.
199     */
200    public static final int IME_FLAG_NAVIGATE_PREVIOUS = 0x4000000;
201
202    /**
203     * Flag of {@link #imeOptions}: used to specify that there is something
204     * interesting that a forward navigation can focus on. This is like using
205     * {@link #IME_ACTION_NEXT}, except allows the IME to be multiline (with
206     * an enter key) as well as provide forward navigation.  Note that some
207     * IMEs may not be able to do this, especially when running on a small
208     * screen where there is little space.  In that case it does not need to
209     * present a UI for this option.  Like {@link #IME_ACTION_NEXT}, if the
210     * user selects the IME's facility to forward navigate, this will show up
211     * in the application at {@link InputConnection#performEditorAction(int)
212     * InputConnection.performEditorAction(int)}.
213     */
214    public static final int IME_FLAG_NAVIGATE_NEXT = 0x8000000;
215
216    /**
217     * Flag of {@link #imeOptions}: used to specify that the IME does not need
218     * to show its extracted text UI.  For input methods that may be fullscreen,
219     * often when in landscape mode, this allows them to be smaller and let part
220     * of the application be shown behind, through transparent UI parts in the
221     * fullscreen IME. The part of the UI visible to the user may not be responsive
222     * to touch because the IME will receive touch events, which may confuse the
223     * user; use {@link #IME_FLAG_NO_FULLSCREEN} instead for a better experience.
224     * Using this flag is discouraged and it may become deprecated in the future.
225     * Its meaning is unclear in some situations and it may not work appropriately
226     * on older versions of the platform.
227     */
228    public static final int IME_FLAG_NO_EXTRACT_UI = 0x10000000;
229
230    /**
231     * Flag of {@link #imeOptions}: used in conjunction with one of the actions
232     * masked by {@link #IME_MASK_ACTION}, this indicates that the action
233     * should not be available as an accessory button on the right of the extracted
234     * text when the input method is full-screen. Note that by setting this flag,
235     * there can be cases where the action is simply never available to the
236     * user. Setting this generally means that you think that in fullscreen mode,
237     * where there is little space to show the text, it's not worth taking some
238     * screen real estate to display the action and it should be used instead
239     * to show more text.
240     */
241    public static final int IME_FLAG_NO_ACCESSORY_ACTION = 0x20000000;
242
243    /**
244     * Flag of {@link #imeOptions}: used in conjunction with one of the actions
245     * masked by {@link #IME_MASK_ACTION}. If this flag is not set, IMEs will
246     * normally replace the "enter" key with the action supplied. This flag
247     * indicates that the action should not be available in-line as a replacement
248     * for the "enter" key. Typically this is because the action has such a
249     * significant impact or is not recoverable enough that accidentally hitting
250     * it should be avoided, such as sending a message. Note that
251     * {@link android.widget.TextView} will automatically set this flag for you
252     * on multi-line text views.
253     */
254    public static final int IME_FLAG_NO_ENTER_ACTION = 0x40000000;
255
256    /**
257     * Flag of {@link #imeOptions}: used to request an IME that is capable of
258     * inputting ASCII characters.  The intention of this flag is to ensure that
259     * the user can type Roman alphabet characters in a {@link android.widget.TextView}.
260     * It is typically used for an account ID or password input. A lot of the time,
261     * IMEs are already able to input ASCII even without being told so (such IMEs
262     * already respect this flag in a sense), but there are cases when this is not
263     * the default. For instance, users of languages using a different script like
264     * Arabic, Greek, Hebrew or Russian typically have a keyboard that can't
265     * input ASCII characters by default. Applications need to be
266     * aware that the flag is not a guarantee, and some IMEs may not respect it.
267     * However, it is strongly recommended for IME authors to respect this flag
268     * especially when their IME could end up with a state where only languages
269     * using non-ASCII are enabled.
270     */
271    public static final int IME_FLAG_FORCE_ASCII = 0x80000000;
272
273    /**
274     * Generic unspecified type for {@link #imeOptions}.
275     */
276    public static final int IME_NULL = 0x00000000;
277
278    /**
279     * Masks for {@link imeOptions}
280     *
281     * <pre>
282     * |-------|-------|-------|-------|
283     *                              1111 IME_MASK_ACTION
284     * |-------|-------|-------|-------|
285     *                                   IME_ACTION_UNSPECIFIED
286     *                                 1 IME_ACTION_NONE
287     *                                1  IME_ACTION_GO
288     *                                11 IME_ACTION_SEARCH
289     *                               1   IME_ACTION_SEND
290     *                               1 1 IME_ACTION_NEXT
291     *                               11  IME_ACTION_DONE
292     *                               111 IME_ACTION_PREVIOUS
293     *         1                         IME_FLAG_NO_PERSONALIZED_LEARNING
294     *        1                          IME_FLAG_NO_FULLSCREEN
295     *       1                           IME_FLAG_NAVIGATE_PREVIOUS
296     *      1                            IME_FLAG_NAVIGATE_NEXT
297     *     1                             IME_FLAG_NO_EXTRACT_UI
298     *    1                              IME_FLAG_NO_ACCESSORY_ACTION
299     *   1                               IME_FLAG_NO_ENTER_ACTION
300     *  1                                IME_FLAG_FORCE_ASCII
301     * |-------|-------|-------|-------|</pre>
302     */
303
304    /**
305     * Extended type information for the editor, to help the IME better
306     * integrate with it.
307     */
308    public int imeOptions = IME_NULL;
309
310    /**
311     * A string supplying additional information options that are
312     * private to a particular IME implementation.  The string must be
313     * scoped to a package owned by the implementation, to ensure there are
314     * no conflicts between implementations, but other than that you can put
315     * whatever you want in it to communicate with the IME.  For example,
316     * you could have a string that supplies an argument like
317     * <code>"com.example.myapp.SpecialMode=3"</code>.  This field is can be
318     * filled in from the {@link android.R.attr#privateImeOptions}
319     * attribute of a TextView.
320     */
321    public String privateImeOptions = null;
322
323    /**
324     * In some cases an IME may be able to display an arbitrary label for
325     * a command the user can perform, which you can specify here. This is
326     * typically used as the label for the action to use in-line as a replacement
327     * for the "enter" key (see {@link #actionId}). Remember the key where
328     * this will be displayed is typically very small, and there are significant
329     * localization challenges to make this fit in all supported languages. Also
330     * you can not count absolutely on this being used, as some IMEs may
331     * ignore this.
332     */
333    public CharSequence actionLabel = null;
334
335    /**
336     * If {@link #actionLabel} has been given, this is the id for that command
337     * when the user presses its button that is delivered back with
338     * {@link InputConnection#performEditorAction(int)
339     * InputConnection.performEditorAction()}.
340     */
341    public int actionId = 0;
342
343    /**
344     * The text offset of the start of the selection at the time editing
345     * begins; -1 if not known. Keep in mind that, without knowing the cursor
346     * position, many IMEs will not be able to offer their full feature set and
347     * may even behave in unpredictable ways: pass the actual cursor position
348     * here if possible at all.
349     *
350     * <p>Also, this needs to be the cursor position <strong>right now</strong>,
351     * not at some point in the past, even if input is starting in the same text field
352     * as before. When the app is filling this object, input is about to start by
353     * definition, and this value will override any value the app may have passed to
354     * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)}
355     * before.</p>
356     */
357    public int initialSelStart = -1;
358
359    /**
360     * <p>The text offset of the end of the selection at the time editing
361     * begins; -1 if not known. Keep in mind that, without knowing the cursor
362     * position, many IMEs will not be able to offer their full feature set and
363     * may behave in unpredictable ways: pass the actual cursor position
364     * here if possible at all.</p>
365     *
366     * <p>Also, this needs to be the cursor position <strong>right now</strong>,
367     * not at some point in the past, even if input is starting in the same text field
368     * as before. When the app is filling this object, input is about to start by
369     * definition, and this value will override any value the app may have passed to
370     * {@link InputMethodManager#updateSelection(android.view.View, int, int, int, int)}
371     * before.</p>
372     */
373    public int initialSelEnd = -1;
374
375    /**
376     * The capitalization mode of the first character being edited in the
377     * text.  Values may be any combination of
378     * {@link TextUtils#CAP_MODE_CHARACTERS TextUtils.CAP_MODE_CHARACTERS},
379     * {@link TextUtils#CAP_MODE_WORDS TextUtils.CAP_MODE_WORDS}, and
380     * {@link TextUtils#CAP_MODE_SENTENCES TextUtils.CAP_MODE_SENTENCES}, though
381     * you should generally just take a non-zero value to mean "start out in
382     * caps mode".
383     */
384    public int initialCapsMode = 0;
385
386    /**
387     * The "hint" text of the text view, typically shown in-line when the
388     * text is empty to tell the user what to enter.
389     */
390    public CharSequence hintText;
391
392    /**
393     * A label to show to the user describing the text they are writing.
394     */
395    public CharSequence label;
396
397    /**
398     * Name of the package that owns this editor.
399     *
400     * <p><strong>IME authors:</strong> In API level 22
401     * {@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1} and prior, do not trust this package
402     * name. The system had not verified the consistency between the package name here and
403     * application's uid. Consider to use {@link InputBinding#getUid()}, which is trustworthy.
404     * Starting from {@link android.os.Build.VERSION_CODES#M}, the system verifies the consistency
405     * between this package name and application uid before {@link EditorInfo} is passed to the
406     * input method.</p>
407     *
408     * <p><strong>Editor authors:</strong> Starting from {@link android.os.Build.VERSION_CODES#M},
409     * the application is no longer
410     * able to establish input connections if the package name provided here is inconsistent with
411     * application's uid.</p>
412     */
413    public String packageName;
414
415    /**
416     * Identifier for the editor's field.  This is optional, and may be
417     * 0.  By default it is filled in with the result of
418     * {@link android.view.View#getId() View.getId()} on the View that
419     * is being edited.
420     */
421    public int fieldId;
422
423    /**
424     * Additional name for the editor's field.  This can supply additional
425     * name information for the field.  By default it is null.  The actual
426     * contents have no meaning.
427     */
428    public String fieldName;
429
430    /**
431     * Any extra data to supply to the input method.  This is for extended
432     * communication with specific input methods; the name fields in the
433     * bundle should be scoped (such as "com.mydomain.im.SOME_FIELD") so
434     * that they don't conflict with others.  This field can be
435     * filled in from the {@link android.R.attr#editorExtras}
436     * attribute of a TextView.
437     */
438    public Bundle extras;
439
440    /**
441     * List of the languages that the user is supposed to switch to no matter what input method
442     * subtype is currently used.  This special "hint" can be used mainly for, but not limited to,
443     * multilingual users who want IMEs to switch language context automatically.
444     *
445     * <p>{@code null} means that no special language "hint" is needed.</p>
446     *
447     * <p><strong>Editor authors:</strong> Specify this only when you are confident that the user
448     * will switch to certain languages in this context no matter what input method subtype is
449     * currently selected.  Otherwise, keep this {@code null}.  Explicit user actions and/or
450     * preferences would be good signals to specify this special "hint",  For example, a chat
451     * application may be able to put the last used language at the top of {@link #hintLocales}
452     * based on whom the user is going to talk, by remembering what language is used in the last
453     * conversation.  Do not specify {@link android.widget.TextView#getTextLocales()} only because
454     * it is used for text rendering.</p>
455     *
456     * @see android.widget.TextView#setImeHintLocales(LocaleList)
457     * @see android.widget.TextView#getImeHintLocales()
458     */
459    @Nullable
460    public LocaleList hintLocales = null;
461
462
463    /**
464     * List of acceptable MIME types for
465     * {@link InputConnection#commitContent(InputContentInfo, int, Bundle)}.
466     *
467     * <p>{@code null} or an empty array means that
468     * {@link InputConnection#commitContent(InputContentInfo, int, Bundle)} is not supported in this
469     * editor.</p>
470     */
471    @Nullable
472    public String[] contentMimeTypes = null;
473
474    /**
475     * Ensure that the data in this EditorInfo is compatible with an application
476     * that was developed against the given target API version.  This can
477     * impact the following input types:
478     * {@link InputType#TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS},
479     * {@link InputType#TYPE_TEXT_VARIATION_WEB_PASSWORD},
480     * {@link InputType#TYPE_NUMBER_VARIATION_NORMAL},
481     * {@link InputType#TYPE_NUMBER_VARIATION_PASSWORD}.
482     *
483     * <p>This is called by the framework for input method implementations;
484     * you should not generally need to call it yourself.
485     *
486     * @param targetSdkVersion The API version number that the compatible
487     * application was developed against.
488     */
489    public final void makeCompatible(int targetSdkVersion) {
490        if (targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
491            switch (inputType&(TYPE_MASK_CLASS|TYPE_MASK_VARIATION)) {
492                case TYPE_CLASS_TEXT|TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
493                    inputType = TYPE_CLASS_TEXT|TYPE_TEXT_VARIATION_EMAIL_ADDRESS
494                            | (inputType&TYPE_MASK_FLAGS);
495                    break;
496                case TYPE_CLASS_TEXT|TYPE_TEXT_VARIATION_WEB_PASSWORD:
497                    inputType = TYPE_CLASS_TEXT|TYPE_TEXT_VARIATION_PASSWORD
498                            | (inputType&TYPE_MASK_FLAGS);
499                    break;
500                case TYPE_CLASS_NUMBER|TYPE_NUMBER_VARIATION_NORMAL:
501                case TYPE_CLASS_NUMBER|TYPE_NUMBER_VARIATION_PASSWORD:
502                    inputType = TYPE_CLASS_NUMBER
503                            | (inputType&TYPE_MASK_FLAGS);
504                    break;
505            }
506        }
507    }
508
509    /**
510     * Write debug output of this object.
511     */
512    public void dump(Printer pw, String prefix) {
513        pw.println(prefix + "inputType=0x" + Integer.toHexString(inputType)
514                + " imeOptions=0x" + Integer.toHexString(imeOptions)
515                + " privateImeOptions=" + privateImeOptions);
516        pw.println(prefix + "actionLabel=" + actionLabel
517                + " actionId=" + actionId);
518        pw.println(prefix + "initialSelStart=" + initialSelStart
519                + " initialSelEnd=" + initialSelEnd
520                + " initialCapsMode=0x"
521                + Integer.toHexString(initialCapsMode));
522        pw.println(prefix + "hintText=" + hintText
523                + " label=" + label);
524        pw.println(prefix + "packageName=" + packageName
525                + " fieldId=" + fieldId
526                + " fieldName=" + fieldName);
527        pw.println(prefix + "extras=" + extras);
528        pw.println(prefix + "hintLocales=" + hintLocales);
529        pw.println(prefix + "contentMimeTypes=" + Arrays.toString(contentMimeTypes));
530    }
531
532    /**
533     * Used to package this object into a {@link Parcel}.
534     *
535     * @param dest The {@link Parcel} to be written.
536     * @param flags The flags used for parceling.
537     */
538    public void writeToParcel(Parcel dest, int flags) {
539        dest.writeInt(inputType);
540        dest.writeInt(imeOptions);
541        dest.writeString(privateImeOptions);
542        TextUtils.writeToParcel(actionLabel, dest, flags);
543        dest.writeInt(actionId);
544        dest.writeInt(initialSelStart);
545        dest.writeInt(initialSelEnd);
546        dest.writeInt(initialCapsMode);
547        TextUtils.writeToParcel(hintText, dest, flags);
548        TextUtils.writeToParcel(label, dest, flags);
549        dest.writeString(packageName);
550        dest.writeInt(fieldId);
551        dest.writeString(fieldName);
552        dest.writeBundle(extras);
553        if (hintLocales != null) {
554            hintLocales.writeToParcel(dest, flags);
555        } else {
556            LocaleList.getEmptyLocaleList().writeToParcel(dest, flags);
557        }
558        dest.writeStringArray(contentMimeTypes);
559    }
560
561    /**
562     * Used to make this class parcelable.
563     */
564    public static final Parcelable.Creator<EditorInfo> CREATOR =
565            new Parcelable.Creator<EditorInfo>() {
566                public EditorInfo createFromParcel(Parcel source) {
567                    EditorInfo res = new EditorInfo();
568                    res.inputType = source.readInt();
569                    res.imeOptions = source.readInt();
570                    res.privateImeOptions = source.readString();
571                    res.actionLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
572                    res.actionId = source.readInt();
573                    res.initialSelStart = source.readInt();
574                    res.initialSelEnd = source.readInt();
575                    res.initialCapsMode = source.readInt();
576                    res.hintText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
577                    res.label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
578                    res.packageName = source.readString();
579                    res.fieldId = source.readInt();
580                    res.fieldName = source.readString();
581                    res.extras = source.readBundle();
582                    LocaleList hintLocales = LocaleList.CREATOR.createFromParcel(source);
583                    res.hintLocales = hintLocales.isEmpty() ? null : hintLocales;
584                    res.contentMimeTypes = source.readStringArray();
585                    return res;
586                }
587
588                public EditorInfo[] newArray(int size) {
589                    return new EditorInfo[size];
590                }
591            };
592
593    public int describeContents() {
594        return 0;
595    }
596
597}
598