Builder
class Builder
| kotlin.Any | |
| ↳ | android.agenticon.AgentTaskEvent.Builder |
Builder for AgentTaskEvent.
Summary
| Public constructors | |
|---|---|
Builder(other: AgentTaskEvent.Builder)Creates a new Builder from another Builder. |
|
Builder(text: CharSequence)Creates a new Builder with a given non-empty text for the event. |
|
Builder(leadingIcons: MutableList<Icon!>, trailingIcons: MutableList<Icon!>)Creates a new Builder with given lists of leading and trailing icons. |
|
| Public methods | |
|---|---|
| AgentTaskEvent |
build()Creates the |
| AgentTaskEvent.Builder |
setBackground(background: Icon?)Sets the background for the event. |
| AgentTaskEvent.Builder |
setClickAction(action: PendingIntent?)Sets the click action. |
| AgentTaskEvent.Builder |
setContentDescription(contentDescription: CharSequence?)Sets the content description to be used by the built |
| AgentTaskEvent.Builder |
setLeadingIcons(leadingIcons: MutableList<Icon!>)Set the leading icons to show in the event |
| AgentTaskEvent.Builder |
setText(text: CharSequence?)Sets the text to show. |
| AgentTaskEvent.Builder |
setTrailingIcons(trailingIcons: MutableList<Icon!>)Set the trailing icons to show in the event |
Public constructors
Builder
Builder(other: AgentTaskEvent.Builder)
Creates a new Builder from another Builder.
| Parameters | |
|---|---|
other |
AgentTaskEvent.Builder: a Builder to copy. This value cannot be null. |
Builder
Builder(text: CharSequence)
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. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the text is empty. |
Builder
Builder(
leadingIcons: MutableList<Icon!>,
trailingIcons: MutableList<Icon!>)
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 getMaxAllowedLeadingIcons() or getMaxAllowedTrailingIcons(), that list will be truncated to that size.
| Parameters | |
|---|---|
leadingIcons |
MutableList<Icon!>: a list of leading icons for the event. This value cannot be null. |
trailingIcons |
MutableList<Icon!>: a list of trailing icons for the event. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if both lists are empty |
java.lang.NullPointerException |
if any of the lists contain null elements. |
Public methods
build
fun build(): AgentTaskEvent
Creates the AgentTaskEvent instance.
The lists of icons may be truncated if more than getMaxAllowedLeadingIcons() or getMaxAllowedTrailingIcons() icons were set respectively.
| Return | |
|---|---|
AgentTaskEvent |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if the event text and the lists of icons are all empty |
setBackground
fun setBackground(background: Icon?): AgentTaskEvent.Builder
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. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder |
setClickAction
fun setClickAction(action: PendingIntent?): AgentTaskEvent.Builder
Sets the click action.
If the PendingIntent was created with PendingIntent.FLAG_MUTABLE, as well as android.content.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:
- If
StatusBarManager.isAgentTaskLaunchSupported()istrue, the value will be used as is ifnon-null. If the value isnull, the default set usingStatusBarManager.ACTION_AGENT_TASK_MAINwill be used as the click action for this event. - If
StatusBarManager.isAgentTaskLaunchSupported()isfalse, this value will be ignored by the implementation, regardless of whether it'snullor not.
| Parameters | |
|---|---|
action |
PendingIntent?: a PendingIntent targeting an android.app.Activity This value may be null. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if action does not target an android.app.Activity. |
setContentDescription
fun setContentDescription(contentDescription: CharSequence?): AgentTaskEvent.Builder
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 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. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder |
setLeadingIcons
fun setLeadingIcons(leadingIcons: MutableList<Icon!>): AgentTaskEvent.Builder
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 getMaxAllowedLeadingIcons() elements, it will be truncated to that size.
| Parameters | |
|---|---|
leadingIcons |
MutableList<Icon!>: the icons to show at the start side of the event. This value cannot be null. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the list contains null elements. |
setText
fun setText(text: CharSequence?): AgentTaskEvent.Builder
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. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder |
setTrailingIcons
fun setTrailingIcons(trailingIcons: MutableList<Icon!>): AgentTaskEvent.Builder
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 getMaxAllowedTrailingIcons() elements, it will be truncated to that size.
| Parameters | |
|---|---|
trailingIcons |
MutableList<Icon!>: the icons to show at the end side of the event. This value cannot be null. |
| Return | |
|---|---|
AgentTaskEvent.Builder |
this Builder This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the list contains null elements. |