ContentInfoCompat

public final class ContentInfoCompat
extends Object

java.lang.Object
   ↳ androidx.core.view.ContentInfoCompat


Holds all the relevant data for a request to OnReceiveContentListener. This is a backward-compatible wrapper for the platform class ContentInfo.

Summary

Nested classes

class ContentInfoCompat.Builder

Builder for ContentInfoCompat

Constants

int FLAG_CONVERT_TO_PLAIN_TEXT

Flag requesting that the content should be converted to plain text prior to inserting.

int SOURCE_APP

Specifies that the operation was triggered by the app that contains the target view.

int SOURCE_AUTOFILL

Specifies that the operation was triggered by the autofill framework.

int SOURCE_CLIPBOARD

Specifies that the operation was triggered by a paste from the clipboard (e.g.

int SOURCE_DRAG_AND_DROP

Specifies that the operation was triggered by the drag/drop framework.

int SOURCE_INPUT_METHOD

Specifies that the operation was triggered from the soft keyboard (also known as input method editor or IME).

int SOURCE_PROCESS_TEXT

Specifies that the operation was triggered by a result from a PROCESS_TEXT action in the selection menu.

Public methods

ClipData getClip()

The data to be inserted.

Bundle getExtras()

Optional additional metadata.

int getFlags()

Optional flags that control the insertion behavior.

Uri getLinkUri()

Optional http/https URI for the content that may be provided by the IME.

int getSource()

The source of the operation.

static Pair<ContentInfoContentInfo> partition(ContentInfo payload, Predicate<ClipData.Item> itemPredicate)

Partitions content based on the given predicate.

Pair<ContentInfoCompatContentInfoCompat> partition(Predicate<ClipData.Item> itemPredicate)

Partitions this content based on the given predicate.

ContentInfo toContentInfo()

Provides the ContentInfo represented by this object.

static ContentInfoCompat toContentInfoCompat(ContentInfo platContentInfo)

Provides a backward-compatible wrapper for ContentInfo.

String toString()

Inherited methods

Constants

FLAG_CONVERT_TO_PLAIN_TEXT

public static final int FLAG_CONVERT_TO_PLAIN_TEXT

Flag requesting that the content should be converted to plain text prior to inserting.

Constant Value: 1 (0x00000001)

SOURCE_APP

public static final int SOURCE_APP

Specifies that the operation was triggered by the app that contains the target view.

Constant Value: 0 (0x00000000)

SOURCE_AUTOFILL

public static final int SOURCE_AUTOFILL

Specifies that the operation was triggered by the autofill framework. See https://developer.android.com/guide/topics/text/autofill for more info.

Constant Value: 4 (0x00000004)

SOURCE_CLIPBOARD

public static final int SOURCE_CLIPBOARD

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).

Constant Value: 1 (0x00000001)

SOURCE_DRAG_AND_DROP

public static final int SOURCE_DRAG_AND_DROP

Specifies that the operation was triggered by the drag/drop framework. See https://developer.android.com/guide/topics/ui/drag-drop for more info.

Constant Value: 3 (0x00000003)

SOURCE_INPUT_METHOD

public static final int SOURCE_INPUT_METHOD

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.

Constant Value: 2 (0x00000002)

SOURCE_PROCESS_TEXT

public static final int SOURCE_PROCESS_TEXT

Specifies that the operation was triggered by a result from a PROCESS_TEXT action in the selection menu.

Constant Value: 5 (0x00000005)

Public methods

getClip

public ClipData getClip ()

The data to be inserted.

Returns
ClipData

getExtras

public Bundle getExtras ()

Optional additional metadata. If the source is SOURCE_INPUT_METHOD, this will include the opts passed by the IME.

Returns
Bundle

getFlags

public int getFlags ()

Optional flags that control the insertion behavior. See FLAG_ constants.

Returns
int

getLinkUri

public 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.

Returns
Uri

getSource

public int getSource ()

The source of the operation. See SOURCE_ constants. Future versions of Android may pass additional values.

Returns
int

partition

public static Pair<ContentInfoContentInfo> partition (ContentInfo payload, 
                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
payload ContentInfo

itemPredicate Predicate: The predicate to test each ClipData.Item to determine which partition to place it into.

Returns
Pair<ContentInfoContentInfo> 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

public Pair<ContentInfoCompatContentInfoCompat> partition (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
itemPredicate Predicate: The predicate to test each ClipData.Item to determine which partition to place it into.

Returns
Pair<ContentInfoCompatContentInfoCompat> 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

public 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
ContentInfo platform class object

toContentInfoCompat

public static ContentInfoCompat toContentInfoCompat (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
platContentInfo ContentInfo: platform class to wrap, must not be null

Returns
ContentInfoCompat wrapped class

toString

public String toString ()

Returns
String