Builder
class Builder
| kotlin.Any | |
| ↳ | android.agenticon.AgentTaskState.Builder |
Builder for AgentTaskState.
Summary
| Public constructors | |
|---|---|
Builder(other: AgentTaskState.Builder)Creates a new Builder from another Builder. |
|
Builder(icon: Icon, contentDescription: CharSequence)Creates a new Builder. |
|
| Public methods | |
|---|---|
| AgentTaskState |
build()Creates the |
| AgentTaskState.Builder |
setClickAction(action: PendingIntent?)Sets the click action. |
| AgentTaskState.Builder |
setIconAndContentDescription(icon: Icon, contentDescription: CharSequence)Sets the icon and content description. |
| AgentTaskState.Builder |
setShouldInterruptPreviousAnimation(shouldInterruptPreviousAnimation: Boolean)Sets whether this new state should interrupt the animation from the previous state. |
| AgentTaskState.Builder |
setShouldLoopAnimation(shouldLoopAnimation: Boolean)Indicates that this state's icon animation should be looped on repeat. |
Public constructors
Builder
Builder(other: AgentTaskState.Builder)
Creates a new Builder from another Builder.
| Parameters | |
|---|---|
other |
AgentTaskState.Builder: a Builder to copy. This value cannot be null. |
Builder
Builder(
icon: Icon,
contentDescription: CharSequence)
Creates a new Builder.
| Parameters | |
|---|---|
icon |
Icon: the icon to display. This value cannot be null. |
contentDescription |
CharSequence: the content description for accessibility. This value cannot be null. |
Public methods
build
fun build(): AgentTaskState
Creates the AgentTaskState instance.
| Return | |
|---|---|
AgentTaskState |
This value cannot be null. |
setClickAction
fun setClickAction(action: PendingIntent?): AgentTaskState.Builder
Sets the click action.
The PendingIntent should target an android.app.Activity.
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, then the state icon will not be clickable. - 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 | |
|---|---|
AgentTaskState.Builder |
this Builder |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if action does not target an android.app.Activity. |
setIconAndContentDescription
fun setIconAndContentDescription(
icon: Icon,
contentDescription: CharSequence
): AgentTaskState.Builder
Sets the icon and content description.
The icon should be a monochrome icon that will be tinted for contrast purposes.
The icon can be an animation. In that case, the animation must be finite in duration. This animation will be played to completion before switching to the next AgentTaskState. This behavior can be interrupted by sending a new AgentTaskState with shouldInterruptPreviousAnimation() set to true.
Infinite animation behavior is unspecified.
| Parameters | |
|---|---|
icon |
Icon: representing the next state to show. This value cannot be null. |
contentDescription |
CharSequence: associated with the icon. This value cannot be null. |
| Return | |
|---|---|
AgentTaskState.Builder |
this Builder This value cannot be null. |
setShouldInterruptPreviousAnimation
fun setShouldInterruptPreviousAnimation(shouldInterruptPreviousAnimation: Boolean): AgentTaskState.Builder
Sets whether this new state should interrupt the animation from the previous state.
If the previous state's icon is an animation, when this is true, this new AgentTaskState will interrupt that animation, immediately moving to the new state (and icon), without waiting for the previous animation to complete.
If the previous icon is not animated, this value is ignored.
| Parameters | |
|---|---|
shouldInterruptPreviousAnimation |
Boolean: true if this new state's icon should interrupt the animation from the previous state's icon |
| Return | |
|---|---|
AgentTaskState.Builder |
this Builder This value cannot be null. |
setShouldLoopAnimation
fun setShouldLoopAnimation(shouldLoopAnimation: Boolean): AgentTaskState.Builder
Indicates that this state's icon animation should be looped on repeat.
If this value is true:
- If the icon provided in
getIconhas a finite animation, then the finite animation will be re-played. The amount of repetitions will be determined by the system depending on system health, battery life, and other factors. The icon animation will be played to completion before switching to the nextAgentTaskState. This behavior can be interrupted by sending a newAgentTaskStatewithshouldInterruptPreviousAnimation()set totrue. - If the icon provided in
getIconhas a infinite animation, then the infinite animation will be played. The total animation time will be determined by the system depending on system health, battery life, and other factors. When the animation is stopped by the system or when a newAgentTaskStateis sent, the infinite animation can be stopped at any frame. - If the icon provided in
getIconis not animated, this value is ignored.
If this value is false:
- If the icon provided in
getIconhas a finite animation, then the finite animation will be played once and will be played to the end of the animation, though longer animations may be cut short depending on system constraints. - If the icon provided in
getIconhas a infinite animation, then the infinite animation will be played for a short period of time, around 3 seconds. When the animation is stopped by the system or when a newAgentTaskStateis sent, the infinite animation can be stopped at any frame. - If the icon provided in
getIconis not animated, this value is ignored.
| Return | |
|---|---|
AgentTaskState.Builder |
this Builder This value cannot be null. |