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