ContentInfoCompat
public final class ContentInfoCompat
Holds all the relevant data for a request to OnReceiveContentListener. This is a backward-compatible wrapper for the platform class ContentInfo.
Summary
Nested types |
|---|
public final class ContentInfoCompat.BuilderBuilder for |
Constants |
|
|---|---|
static final int |
Flag requesting that the content should be converted to plain text prior to inserting. |
static final int |
SOURCE_APP = 0Specifies that the operation was triggered by the app that contains the target view. |
static final int |
SOURCE_AUTOFILL = 4Specifies that the operation was triggered by the autofill framework. |
static final int |
SOURCE_CLIPBOARD = 1Specifies that the operation was triggered by a paste from the clipboard (e.g. "Paste" or "Paste as plain text" action in the insertion/selection menu). |
static final int |
Specifies that the operation was triggered by the drag/drop framework. |
static final int |
Specifies that the operation was triggered from the soft keyboard (also known as input method editor or IME). |
static final int |
Specifies that the operation was triggered by a result from a |
Public methods |
|
|---|---|
@NonNull ClipData |
getClip()The data to be inserted. |
@Nullable Bundle |
Optional additional metadata. |
int |
getFlags()Optional flags that control the insertion behavior. |
@Nullable Uri |
Optional http/https URI for the content that may be provided by the IME. |
int |
The source of the operation. |
@NonNull Pair<ContentInfoCompat, ContentInfoCompat> |
partition(@NonNull Predicate<ClipData.Item> itemPredicate)Partitions this content based on the given predicate. |
static @NonNull Pair<ContentInfo, ContentInfo> |
@RequiresApi(value = 31)Partitions content based on the given predicate. |
@NonNull ContentInfo |
@RequiresApi(value = 31)Provides the |
static @NonNull ContentInfoCompat |
@RequiresApi(value = 31)Provides a backward-compatible wrapper for |
@NonNull String |
toString() |
Constants
FLAG_CONVERT_TO_PLAIN_TEXT
public static final int FLAG_CONVERT_TO_PLAIN_TEXT = 1
Flag requesting that the content should be converted to plain text prior to inserting.
SOURCE_APP
public static final int SOURCE_APP = 0
Specifies that the operation was triggered by the app that contains the target view.
SOURCE_AUTOFILL
public static final int SOURCE_AUTOFILL = 4
Specifies that the operation was triggered by the autofill framework. See https://developer.android.com/guide/topics/text/autofill for more info.
SOURCE_CLIPBOARD
public static final int SOURCE_CLIPBOARD = 1
Specifies that the operation was triggered by a paste from the clipboard (e.g. "Paste" or "Paste as plain text" action in the insertion/selection menu).
SOURCE_DRAG_AND_DROP
public static final int SOURCE_DRAG_AND_DROP = 3
Specifies that the operation was triggered by the drag/drop framework. See https://developer.android.com/guide/topics/ui/drag-drop for more info.
SOURCE_INPUT_METHOD
public static final int SOURCE_INPUT_METHOD = 2
Specifies that the operation was triggered from the soft keyboard (also known as input method editor or IME). See https://developer.android.com/guide/topics/text/image-keyboard for more info.
SOURCE_PROCESS_TEXT
public static final int SOURCE_PROCESS_TEXT = 5
Specifies that the operation was triggered by a result from a PROCESS_TEXT action in the selection menu.
Public methods
getExtras
public @Nullable Bundle getExtras()
Optional additional metadata. If the source is SOURCE_INPUT_METHOD, this will include the opts passed by the IME.
getFlags
public int getFlags()
Optional flags that control the insertion behavior. See FLAG_ constants.
getLinkUri
public @Nullable Uri getLinkUri()
Optional http/https URI for the content that may be provided by the IME. This is only populated if the source is SOURCE_INPUT_METHOD and if a non-empty linkUri was passed by the IME.
getSource
public int getSource()
The source of the operation. See SOURCE_ constants. Future versions of Android may pass additional values.
partition
public @NonNull Pair<ContentInfoCompat, ContentInfoCompat> partition(@NonNull Predicate<ClipData.Item> itemPredicate)
Partitions this content based on the given predicate.
This function classifies the content and organizes it into a pair, grouping the items that matched vs didn't match the predicate.
Except for the ClipData items, the returned objects will contain all the same metadata as this ContentInfoCompat.
| Parameters | |
|---|---|
@NonNull Predicate<ClipData.Item> itemPredicate |
The predicate to test each |
| Returns | |
|---|---|
@NonNull Pair<ContentInfoCompat, ContentInfoCompat> |
A pair containing the partitioned content. The pair's first object will have the content that matched the predicate, or null if none of the items matched. The pair's second object will have the content that didn't match the predicate, or null if all of the items matched. |
partition
@RequiresApi(value = 31)
public static @NonNull Pair<ContentInfo, ContentInfo> partition(
@NonNull ContentInfo payload,
@NonNull Predicate<ClipData.Item> itemPredicate
)
Partitions content based on the given predicate.
This function classifies the content and organizes it into a pair, grouping the items that matched vs didn't match the predicate.
Except for the ClipData items, the returned objects will contain all the same metadata as the passed-in ContentInfo.
| Parameters | |
|---|---|
@NonNull ContentInfo payload |
payload to add to returned pair. |
@NonNull Predicate<ClipData.Item> itemPredicate |
The predicate to test each |
| Returns | |
|---|---|
@NonNull Pair<ContentInfo, ContentInfo> |
A pair containing the partitioned content. The pair's first object will have the content that matched the predicate, or null if none of the items matched. The pair's second object will have the content that didn't match the predicate, or null if all of the items matched. |
toContentInfo
@RequiresApi(value = 31)
public @NonNull ContentInfo toContentInfo()
Provides the ContentInfo represented by this object.
This method is not supported on devices running SDK <= 30 since the platform class will not be available.
| Returns | |
|---|---|
@NonNull ContentInfo |
platform class object |
| See also | |
|---|---|
toContentInfoCompat |
toContentInfoCompat
@RequiresApi(value = 31)
public static @NonNull ContentInfoCompat toContentInfoCompat(@NonNull ContentInfo platContentInfo)
Provides a backward-compatible wrapper for ContentInfo.
This method is not supported on devices running SDK <= 30 since the platform class will not be available.
| Parameters | |
|---|---|
@NonNull ContentInfo platContentInfo |
platform class to wrap, must not be null |
| Returns | |
|---|---|
@NonNull ContentInfoCompat |
wrapped class |