public class EditorInfo extends Object implements InputType, Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
int |
actionId
If
actionLabel has been given, this is the id for that command
when the user presses its button that is delivered back with
InputConnection.performEditorAction() . |
CharSequence |
actionLabel
In some cases an IME may be able to display an arbitrary label for
a command the user can perform, which you can specify here.
|
String[] |
contentMimeTypes
List of acceptable MIME types for
InputConnection.commitContent(InputContentInfo, int, Bundle) . |
static Parcelable.Creator<EditorInfo> |
CREATOR
Used to make this class parcelable.
|
Bundle |
extras
Any extra data to supply to the input method.
|
int |
fieldId
Identifier for the editor's field.
|
String |
fieldName
Additional name for the editor's field.
|
LocaleList |
hintLocales
List of the languages that the user is supposed to switch to no matter what input method
subtype is currently used.
|
CharSequence |
hintText
The "hint" text of the text view, typically shown in-line when the
text is empty to tell the user what to enter.
|
static int |
IME_ACTION_DONE
Bits of
IME_MASK_ACTION : the action key performs a "done"
operation, typically meaning there is nothing more to input and the
IME will be closed. |
static int |
IME_ACTION_GO
Bits of
IME_MASK_ACTION : the action key performs a "go"
operation to take the user to the target of the text they typed. |
static int |
IME_ACTION_NEXT
Bits of
IME_MASK_ACTION : the action key performs a "next"
operation, taking the user to the next field that will accept text. |
static int |
IME_ACTION_NONE
Bits of
IME_MASK_ACTION : there is no available action. |
static int |
IME_ACTION_PREVIOUS
Bits of
IME_MASK_ACTION : like IME_ACTION_NEXT , but
for moving to the previous field. |
static int |
IME_ACTION_SEARCH
Bits of
IME_MASK_ACTION : the action key performs a "search"
operation, taking the user to the results of searching for the text
they have typed (in whatever context is appropriate). |
static int |
IME_ACTION_SEND
Bits of
IME_MASK_ACTION : the action key performs a "send"
operation, delivering the text to its target. |
static int |
IME_ACTION_UNSPECIFIED
Bits of
IME_MASK_ACTION : no specific action has been
associated with this editor, let the editor come up with its own if
it can. |
static int |
IME_FLAG_FORCE_ASCII
Flag of
imeOptions : used to request an IME that is capable of
inputting ASCII characters. |
static int |
IME_FLAG_NAVIGATE_NEXT
Flag of
imeOptions : used to specify that there is something
interesting that a forward navigation can focus on. |
static int |
IME_FLAG_NAVIGATE_PREVIOUS
Flag of
imeOptions : like IME_FLAG_NAVIGATE_NEXT , but
specifies there is something interesting that a backward navigation
can focus on. |
static int |
IME_FLAG_NO_ACCESSORY_ACTION
Flag of
imeOptions : used in conjunction with one of the actions
masked by IME_MASK_ACTION , this indicates that the action
should not be available as an accessory button on the right of the extracted
text when the input method is full-screen. |
static int |
IME_FLAG_NO_ENTER_ACTION
Flag of
imeOptions : used in conjunction with one of the actions
masked by IME_MASK_ACTION . |
static int |
IME_FLAG_NO_EXTRACT_UI
Flag of
imeOptions : used to specify that the IME does not need
to show its extracted text UI. |
static int |
IME_FLAG_NO_FULLSCREEN
Flag of
imeOptions : used to request that the IME never go
into fullscreen mode. |
static int |
IME_MASK_ACTION
Set of bits in
imeOptions that provide alternative actions
associated with the "enter" key. |
static int |
IME_NULL
Generic unspecified type for
imeOptions . |
int |
imeOptions
Extended type information for the editor, to help the IME better
integrate with it.
|
int |
initialCapsMode
The capitalization mode of the first character being edited in the
text.
|
int |
initialSelEnd
The text offset of the end of the selection at the time editing
begins; -1 if not known.
|
int |
initialSelStart
The text offset of the start of the selection at the time editing
begins; -1 if not known.
|
int |
inputType
The content type of the text box, whose bits are defined by
InputType . |
CharSequence |
label
A label to show to the user describing the text they are writing.
|
String |
packageName
Name of the package that owns this editor.
|
String |
privateImeOptions
A string supplying additional information options that are
private to a particular IME implementation.
|
TYPE_CLASS_DATETIME, TYPE_CLASS_NUMBER, TYPE_CLASS_PHONE, TYPE_CLASS_TEXT, TYPE_DATETIME_VARIATION_DATE, TYPE_DATETIME_VARIATION_NORMAL, TYPE_DATETIME_VARIATION_TIME, TYPE_MASK_CLASS, TYPE_MASK_FLAGS, TYPE_MASK_VARIATION, TYPE_NULL, TYPE_NUMBER_FLAG_DECIMAL, TYPE_NUMBER_FLAG_SIGNED, TYPE_NUMBER_VARIATION_NORMAL, TYPE_NUMBER_VARIATION_PASSWORD, TYPE_TEXT_FLAG_AUTO_COMPLETE, TYPE_TEXT_FLAG_AUTO_CORRECT, TYPE_TEXT_FLAG_CAP_CHARACTERS, TYPE_TEXT_FLAG_CAP_SENTENCES, TYPE_TEXT_FLAG_CAP_WORDS, TYPE_TEXT_FLAG_IME_MULTI_LINE, TYPE_TEXT_FLAG_MULTI_LINE, TYPE_TEXT_FLAG_NO_SUGGESTIONS, TYPE_TEXT_VARIATION_EMAIL_ADDRESS, TYPE_TEXT_VARIATION_EMAIL_SUBJECT, TYPE_TEXT_VARIATION_FILTER, TYPE_TEXT_VARIATION_LONG_MESSAGE, TYPE_TEXT_VARIATION_NORMAL, TYPE_TEXT_VARIATION_PASSWORD, TYPE_TEXT_VARIATION_PERSON_NAME, TYPE_TEXT_VARIATION_PHONETIC, TYPE_TEXT_VARIATION_POSTAL_ADDRESS, TYPE_TEXT_VARIATION_SHORT_MESSAGE, TYPE_TEXT_VARIATION_URI, TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, TYPE_TEXT_VARIATION_WEB_EDIT_TEXT, TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS, TYPE_TEXT_VARIATION_WEB_PASSWORD
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
EditorInfo() |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
void |
dump(Printer pw,
String prefix)
Write debug output of this object.
|
void |
makeCompatible(int targetSdkVersion)
Ensure that the data in this EditorInfo is compatible with an application
that was developed against the given target API version.
|
void |
writeToParcel(Parcel dest,
int flags)
Used to package this object into a
Parcel . |
public int inputType
InputType
.public static final int IME_MASK_ACTION
imeOptions
that provide alternative actions
associated with the "enter" key. This both helps the IME provide
better feedback about what the enter key will do, and also allows it
to provide alternative mechanisms for providing that command.public static final int IME_ACTION_UNSPECIFIED
IME_MASK_ACTION
: no specific action has been
associated with this editor, let the editor come up with its own if
it can.public static final int IME_ACTION_NONE
IME_MASK_ACTION
: there is no available action.public static final int IME_ACTION_GO
IME_MASK_ACTION
: the action key performs a "go"
operation to take the user to the target of the text they typed.
Typically used, for example, when entering a URL.public static final int IME_ACTION_SEARCH
IME_MASK_ACTION
: the action key performs a "search"
operation, taking the user to the results of searching for the text
they have typed (in whatever context is appropriate).public static final int IME_ACTION_SEND
IME_MASK_ACTION
: the action key performs a "send"
operation, delivering the text to its target. This is typically used
when composing a message in IM or SMS where sending is immediate.public static final int IME_ACTION_NEXT
IME_MASK_ACTION
: the action key performs a "next"
operation, taking the user to the next field that will accept text.public static final int IME_ACTION_DONE
IME_MASK_ACTION
: the action key performs a "done"
operation, typically meaning there is nothing more to input and the
IME will be closed.public static final int IME_ACTION_PREVIOUS
IME_MASK_ACTION
: like IME_ACTION_NEXT
, but
for moving to the previous field. This will normally not be used to
specify an action (since it precludes IME_ACTION_NEXT
), but
can be returned to the app if it sets IME_FLAG_NAVIGATE_PREVIOUS
.public static final int IME_FLAG_NO_FULLSCREEN
imeOptions
: used to request that the IME never go
into fullscreen mode.
By default, IMEs may go into full screen mode when they think
it's appropriate, for example on small screens in landscape
orientation where displaying a software keyboard may occlude
such a large portion of the screen that the remaining part is
too small to meaningfully display the application UI.
If this flag is set, compliant IMEs will never go into full screen mode,
and always leave some space to display the application UI.
Applications need to be aware that the flag is not a guarantee, and
some IMEs may ignore it.public static final int IME_FLAG_NAVIGATE_PREVIOUS
imeOptions
: like IME_FLAG_NAVIGATE_NEXT
, but
specifies there is something interesting that a backward navigation
can focus on. If the user selects the IME's facility to backward
navigate, this will show up in the application as an IME_ACTION_PREVIOUS
at InputConnection.performEditorAction(int)
.public static final int IME_FLAG_NAVIGATE_NEXT
imeOptions
: used to specify that there is something
interesting that a forward navigation can focus on. This is like using
IME_ACTION_NEXT
, except allows the IME to be multiline (with
an enter key) as well as provide forward navigation. Note that some
IMEs may not be able to do this, especially when running on a small
screen where there is little space. In that case it does not need to
present a UI for this option. Like IME_ACTION_NEXT
, if the
user selects the IME's facility to forward navigate, this will show up
in the application at InputConnection.performEditorAction(int)
.public static final int IME_FLAG_NO_EXTRACT_UI
imeOptions
: used to specify that the IME does not need
to show its extracted text UI. For input methods that may be fullscreen,
often when in landscape mode, this allows them to be smaller and let part
of the application be shown behind, through transparent UI parts in the
fullscreen IME. The part of the UI visible to the user may not be responsive
to touch because the IME will receive touch events, which may confuse the
user; use IME_FLAG_NO_FULLSCREEN
instead for a better experience.
Using this flag is discouraged and it may become deprecated in the future.
Its meaning is unclear in some situations and it may not work appropriately
on older versions of the platform.public static final int IME_FLAG_NO_ACCESSORY_ACTION
imeOptions
: used in conjunction with one of the actions
masked by IME_MASK_ACTION
, this indicates that the action
should not be available as an accessory button on the right of the extracted
text when the input method is full-screen. Note that by setting this flag,
there can be cases where the action is simply never available to the
user. Setting this generally means that you think that in fullscreen mode,
where there is little space to show the text, it's not worth taking some
screen real estate to display the action and it should be used instead
to show more text.public static final int IME_FLAG_NO_ENTER_ACTION
imeOptions
: used in conjunction with one of the actions
masked by IME_MASK_ACTION
. If this flag is not set, IMEs will
normally replace the "enter" key with the action supplied. This flag
indicates that the action should not be available in-line as a replacement
for the "enter" key. Typically this is because the action has such a
significant impact or is not recoverable enough that accidentally hitting
it should be avoided, such as sending a message. Note that
TextView
will automatically set this flag for you
on multi-line text views.public static final int IME_FLAG_FORCE_ASCII
imeOptions
: used to request an IME that is capable of
inputting ASCII characters. The intention of this flag is to ensure that
the user can type Roman alphabet characters in a TextView
.
It is typically used for an account ID or password input. A lot of the time,
IMEs are already able to input ASCII even without being told so (such IMEs
already respect this flag in a sense), but there are cases when this is not
the default. For instance, users of languages using a different script like
Arabic, Greek, Hebrew or Russian typically have a keyboard that can't
input ASCII characters by default. Applications need to be
aware that the flag is not a guarantee, and some IMEs may not respect it.
However, it is strongly recommended for IME authors to respect this flag
especially when their IME could end up with a state where only languages
using non-ASCII are enabled.public static final int IME_NULL
imeOptions
.public int imeOptions
public String privateImeOptions
"com.example.myapp.SpecialMode=3"
. This field is can be
filled in from the android.R.attr#privateImeOptions
attribute of a TextView.public CharSequence actionLabel
actionId
). Remember the key where
this will be displayed is typically very small, and there are significant
localization challenges to make this fit in all supported languages. Also
you can not count absolutely on this being used, as some IMEs may
ignore this.public int actionId
actionLabel
has been given, this is the id for that command
when the user presses its button that is delivered back with
InputConnection.performEditorAction()
.public int initialSelStart
Also, this needs to be the cursor position right now,
not at some point in the past, even if input is starting in the same text field
as before. When the app is filling this object, input is about to start by
definition, and this value will override any value the app may have passed to
InputMethodManager.updateSelection(android.view.View, int, int, int, int)
before.
public int initialSelEnd
The text offset of the end of the selection at the time editing begins; -1 if not known. Keep in mind that, without knowing the cursor position, many IMEs will not be able to offer their full feature set and may behave in unpredictable ways: pass the actual cursor position here if possible at all.
Also, this needs to be the cursor position right now,
not at some point in the past, even if input is starting in the same text field
as before. When the app is filling this object, input is about to start by
definition, and this value will override any value the app may have passed to
InputMethodManager.updateSelection(android.view.View, int, int, int, int)
before.
public int initialCapsMode
TextUtils.CAP_MODE_CHARACTERS
,
TextUtils.CAP_MODE_WORDS
, and
TextUtils.CAP_MODE_SENTENCES
, though
you should generally just take a non-zero value to mean "start out in
caps mode".public CharSequence hintText
public CharSequence label
public String packageName
IME authors: In API level 22
Build.VERSION_CODES.LOLLIPOP_MR1
and prior, do not trust this package
name. The system had not verified the consistency between the package name here and
application's uid. Consider to use InputBinding.getUid()
, which is trustworthy.
Starting from Build.VERSION_CODES.M
, the system verifies the consistency
between this package name and application uid before EditorInfo
is passed to the
input method.
Editor authors: Starting from Build.VERSION_CODES.M
,
the application is no longer
able to establish input connections if the package name provided here is inconsistent with
application's uid.
public int fieldId
View.getId()
on the View that
is being edited.public String fieldName
public Bundle extras
android.R.attr#editorExtras
attribute of a TextView.public LocaleList hintLocales
null
means that no special language "hint" is needed.
Editor authors: Specify this only when you are confident that the user
will switch to certain languages in this context no matter what input method subtype is
currently selected. Otherwise, keep this null
. Explicit user actions and/or
preferences would be good signals to specify this special "hint", For example, a chat
application may be able to put the last used language at the top of hintLocales
based on whom the user is going to talk, by remembering what language is used in the last
conversation. Do not specify TextView.getTextLocales()
only because
it is used for text rendering.
public String[] contentMimeTypes
InputConnection.commitContent(InputContentInfo, int, Bundle)
.
null
or an empty array means that
InputConnection.commitContent(InputContentInfo, int, Bundle)
is not supported in this
editor.
public static final Parcelable.Creator<EditorInfo> CREATOR
public final void makeCompatible(int targetSdkVersion)
InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
,
InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
,
InputType.TYPE_NUMBER_VARIATION_NORMAL
,
InputType.TYPE_NUMBER_VARIATION_PASSWORD
.
This is called by the framework for input method implementations; you should not generally need to call it yourself.
targetSdkVersion
- The API version number that the compatible
application was developed against.public void writeToParcel(Parcel dest, int flags)
Parcel
.writeToParcel
in interface Parcelable
dest
- The Parcel
to be written.flags
- The flags used for parceling.public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR