AgentTaskEvent.Builder


public static final class AgentTaskEvent.Builder
extends Object

java.lang.Object
   ↳ android.agenticon.AgentTaskEvent.Builder


Builder for AgentTaskEvent.

Summary

Public constructors

Builder(AgentTaskEvent.Builder other)

Creates a new Builder from another Builder.

Builder(CharSequence text)

Creates a new Builder with a given non-empty text for the event.

Builder(List<Icon> leadingIcons, List<Icon> trailingIcons)

Creates a new Builder with given lists of leading and trailing icons.

Public methods

AgentTaskEvent build()

Creates the AgentTaskEvent instance.

AgentTaskEvent.Builder setBackground(Icon background)

Sets the background for the event.

AgentTaskEvent.Builder setClickAction(PendingIntent action)

Sets the click action.

AgentTaskEvent.Builder setContentDescription(CharSequence contentDescription)

Sets the content description to be used by the built AgentTaskEvent

This should describe the whole element (including any icons or text).

AgentTaskEvent.Builder setLeadingIcons(List<Icon> leadingIcons)

Set the leading icons to show in the event

The list can be empty.

AgentTaskEvent.Builder setText(CharSequence text)

Sets the text to show.

AgentTaskEvent.Builder setTrailingIcons(List<Icon> trailingIcons)

Set the trailing icons to show in the event

The list can be empty.

Inherited methods

Public constructors

Builder

Added in version 37.2
public Builder (AgentTaskEvent.Builder other)

Creates a new Builder from another Builder.

Parameters
other AgentTaskEvent.Builder: a Builder to copy.
This value cannot be null.

Builder

Added in version 37.2
public Builder (CharSequence text)

Creates a new Builder with a given non-empty text for the event.

In this case, the lists of icons are empty by default.

Parameters
text CharSequence: the text to show.
This value cannot be null.

Throws
IllegalArgumentException if the text is empty.

Builder

Added in version 37.2
public Builder (List<Icon> leadingIcons, 
                List<Icon> trailingIcons)

Creates a new Builder with given lists of leading and trailing icons.

In this case, the text to show is empty by default.

At least one of the two lists must be non-empty.

The icons will be shown as is, with no tinting (only scaling to size).

If any of the list has more elements than the corresponding AgentTaskEvent.getMaxAllowedLeadingIcons() or AgentTaskEvent.getMaxAllowedTrailingIcons(), that list will be truncated to that size.

Parameters
leadingIcons List: a list of leading icons for the event.
This value cannot be null.

trailingIcons List: a list of trailing icons for the event.
This value cannot be null.

Throws
IllegalArgumentException if both lists are empty
NullPointerException if any of the lists contain null elements.

Public methods

build

Added in version 37.2
public AgentTaskEvent build ()

Creates the AgentTaskEvent instance.

The lists of icons may be truncated if more than AgentTaskEvent.getMaxAllowedLeadingIcons() or AgentTaskEvent.getMaxAllowedTrailingIcons() icons were set respectively.

Returns
AgentTaskEvent This value cannot be null.

Throws
IllegalStateException if the event text and the lists of icons are all empty

setBackground

Added in version 37.2
public AgentTaskEvent.Builder setBackground (Icon background)

Sets the background for the event.

This drawable will be masked to an appropriate shape and size, without changing the underlying proportions of the drawable. The mask will be centered on the scaled drawable. It is recommended for the drawable to be "wide", to ensure that top and bottom are not cropped.

If null, the background will be chosen by the implementation.

Parameters
background Icon: a drawable to use for the background of the event.
This value may be null.

Returns
AgentTaskEvent.Builder this Builder

setClickAction

Added in version 37.2
public AgentTaskEvent.Builder setClickAction (PendingIntent action)

Sets the click action.

If the PendingIntent was created with PendingIntent.FLAG_MUTABLE, as well as Intent.FILL_IN_SOURCE_BOUNDS, then the source bounds will be filled in with the coordinates on screen of the UI element that triggered this intent.

Based on the value of StatusBarManager.isAgentTaskLaunchSupported(), this value will be used differently by the implementation:

Parameters
action PendingIntent: a PendingIntent targeting an Activity
This value may be null.

Returns
AgentTaskEvent.Builder this Builder

Throws
IllegalArgumentException if action does not target an Activity.

setContentDescription

Added in version 37.2
public AgentTaskEvent.Builder setContentDescription (CharSequence contentDescription)

Sets the content description to be used by the built AgentTaskEvent

This should describe the whole element (including any icons or text). If null, it will fall back to AgentTaskEvent.getText() if possible or the implementation will use a suitable description.

Parameters
contentDescription CharSequence: the content description to be set for this object.
This value may be null.

Returns
AgentTaskEvent.Builder this Builder

setLeadingIcons

Added in version 37.2
public AgentTaskEvent.Builder setLeadingIcons (List<Icon> leadingIcons)

Set the leading icons to show in the event

The list can be empty. Events must have text, icons, or both.

The icons will be shown as is, with no tinting (only scaling to size).

If the list has more than AgentTaskEvent.getMaxAllowedLeadingIcons() elements, it will be truncated to that size.

Parameters
leadingIcons List: the icons to show at the start side of the event.
This value cannot be null.

Returns
AgentTaskEvent.Builder this Builder
This value cannot be null.

Throws
NullPointerException if the list contains null elements.

setText

Added in version 37.2
public AgentTaskEvent.Builder setText (CharSequence text)

Sets the text to show.

If null, the event will show no text. Events must have either text, or icons, or both.

Parameters
text CharSequence: the text to show as part of this event. It's recommended that it be short to fit in a reduced space.
This value may be null.

Returns
AgentTaskEvent.Builder this Builder

setTrailingIcons

Added in version 37.2
public AgentTaskEvent.Builder setTrailingIcons (List<Icon> trailingIcons)

Set the trailing icons to show in the event

The list can be empty. Events must have text, icons, or both.

The icons will be shown as is, with no tinting (only scaling to size).

If the list has more than AgentTaskEvent.getMaxAllowedTrailingIcons() elements, it will be truncated to that size.

Parameters
trailingIcons List: the icons to show at the end side of the event.
This value cannot be null.

Returns
AgentTaskEvent.Builder this Builder
This value cannot be null.

Throws
NullPointerException if the list contains null elements.