SignInTemplate.Builder


@RequiresCarApi(value = 2)
class SignInTemplate.Builder


A builder of SignInTemplate.

Summary

Public constructors

Returns a Builder instance.

Public functions

SignInTemplate.Builder
addAction(action: Action)

Adds an Action to display alongside the sign-in content.

SignInTemplate

Constructs the template defined by this builder.

SignInTemplate.Builder

Sets the ActionStrip for this template.

SignInTemplate.Builder

Sets additional text, such as disclaimers, links to terms of services, to show in the template.

SignInTemplate.Builder
setHeaderAction(headerAction: Action)

Sets the Action that will be displayed in the header of the template.

SignInTemplate.Builder

Sets the text to show as instructions of the template.

SignInTemplate.Builder
setLoading(isLoading: Boolean)

Sets whether the template is in a loading state.

SignInTemplate.Builder

Sets the title of the template.

Public constructors

Builder

Added in 1.0.0
Builder(signInMethod: SignInTemplate.SignInMethod)

Returns a Builder instance.

Parameters
signInMethod: SignInTemplate.SignInMethod

the sign-in method to use in this template

Throws
java.lang.NullPointerException

if the signInMethod is null

Public functions

addAction

Added in 1.0.0
fun addAction(action: Action): SignInTemplate.Builder

Adds an Action to display alongside the sign-in content.

Requirements This template allows up to 2 Actions in its body, and they must use a androidx.car.app.model.ParkedOnlyOnClickListener.

Each action's title color can be customized with ForegroundCarColorSpan instances. Any other span is not supported.

Throws
java.lang.NullPointerException

if action is null

java.lang.IllegalArgumentException

if action does not meet the requirements

build

Added in 1.0.0
fun build(): SignInTemplate

Constructs the template defined by this builder.

Requirements

If none of the header Action, the header title or the action strip have been set on the template, the header is hidden.

Throws
java.lang.IllegalStateException

if the template does not have either a title or header Action set

setActionStrip

Added in 1.0.0
fun setActionStrip(actionStrip: ActionStrip): SignInTemplate.Builder

Sets the ActionStrip for this template.

Unless set with this method, the template will not have an action strip.

Requirements This template allows up to 2 Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via setTitle. Otherwise, only Actions with icons are allowed.
Throws
java.lang.IllegalArgumentException

if actionStrip does not meet the requirements

java.lang.NullPointerException

if actionStrip is null

setAdditionalText

Added in 1.0.0
fun setAdditionalText(additionalText: CharSequence): SignInTemplate.Builder

Sets additional text, such as disclaimers, links to terms of services, to show in the template.

Unless set with this method, the template will not have additional text.

androidx.car.app.model.ClickableSpan, androidx.car.app.model.DistanceSpan, and androidx.car.app.model.DurationSpan are supported in the input string.

Throws
java.lang.NullPointerException

if additionalText is null

java.lang.IllegalArgumentException

if additionalText contains unsupported spans

See also
CarText

setHeaderAction

Added in 1.0.0
fun setHeaderAction(headerAction: Action): SignInTemplate.Builder

Sets the Action that will be displayed in the header of the template.

Unless set with this method, the template will not have a header action.

Requirements This template only supports either one of APP_ICON and BACK as a header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the template's requirements

java.lang.NullPointerException

if headerAction is null

setInstructions

Added in 1.0.0
fun setInstructions(instructions: CharSequence): SignInTemplate.Builder

Sets the text to show as instructions of the template.

Unless set with this method, the template will not have instructions.

androidx.car.app.model.DistanceSpan, androidx.car.app.model.DurationSpan, and androidx.car.app.model.ForegroundCarColorSpan are supported in the input string.

Throws
java.lang.NullPointerException

if instructions is null

java.lang.IllegalArgumentException

if instructions contains unsupported spans

See also
CarText

for details on text handling and span support.

setLoading

Added in 1.1.0
fun setLoading(isLoading: Boolean): SignInTemplate.Builder

Sets whether the template is in a loading state.

If set to true, the UI will display a loading indicator instead of the SignInMethod. The caller is expected to call invalidate once loading is complete.

setTitle

Added in 1.0.0
fun setTitle(title: CharSequence): SignInTemplate.Builder

Sets the title of the template.

Unless set with this method, the template will not have a title.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans