InputSignInMethod.Builder

public static final class InputSignInMethod.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.model.signin.InputSignInMethod.Builder


A builder of InputSignInMethod.

Summary

Public constructors

Builder(InputSignInMethod.OnInputCompletedListener listener)

Returns an InputSignInMethod.Builder instance.

Public methods

InputSignInMethod build()

Builds an InputSignInMethod instance.

InputSignInMethod.Builder setDefaultValue(String defaultValue)

Sets the default value for this input.

InputSignInMethod.Builder setInputType(int inputType)

Sets the input type.

InputSignInMethod.Builder setKeyboardType(int keyboardType)

Sets the keyboard type to display when this input box gets focused.

InputSignInMethod.Builder setMessage(CharSequence message)

Sets the message associated with this input box.

InputSignInMethod.Builder setPrompt(CharSequence instructions)

Sets the text explaining to the user what should be entered in this input box.

InputSignInMethod.Builder setShowKeyboardByDefault(boolean showKeyboardByDefault)

Sets whether keyboard should be opened by default when this template is presented.

Inherited methods

Public constructors

Builder

public Builder (InputSignInMethod.OnInputCompletedListener listener)

Returns an InputSignInMethod.Builder instance.

Note that the listener relates to UI events and will be executed on the main thread using Looper.getMainLooper().

Parameters
listener InputSignInMethod.OnInputCompletedListener: the InputSignInMethod.OnInputCompletedListener to be notified of input events

Throws
NullPointerException if listener is null

Public methods

build

public InputSignInMethod build ()

Builds an InputSignInMethod instance.

Returns
InputSignInMethod

setDefaultValue

public InputSignInMethod.Builder setDefaultValue (String defaultValue)

Sets the default value for this input.

Unless set with this method, the input box will not have a default value.

For InputSignInMethod.INPUT_TYPE_PASSWORD input types, in order to indicate that is not empty it is recommended to use a special value rather the actual credential. Any user input on a InputSignInMethod.INPUT_TYPE_PASSWORD input box will replace this default value instead of appending to it.

Parameters
defaultValue String

Returns
InputSignInMethod.Builder

Throws
NullPointerException if defaultValue is null

setInputType

public InputSignInMethod.Builder setInputType (int inputType)

Sets the input type.

This must be one of InputSignInMethod.INPUT_TYPE_DEFAULT or InputSignInMethod.INPUT_TYPE_PASSWORD

If not set, InputSignInMethod.INPUT_TYPE_DEFAULT will be assumed.

Parameters
inputType int

Returns
InputSignInMethod.Builder

Throws
IllegalArgumentException if the provided input type is not supported

setKeyboardType

public InputSignInMethod.Builder setKeyboardType (int keyboardType)

Sets the keyboard type to display when this input box gets focused.

This must be one of InputSignInMethod.KEYBOARD_DEFAULT, InputSignInMethod.KEYBOARD_PHONE, InputSignInMethod.KEYBOARD_NUMBER, or InputSignInMethod.KEYBOARD_EMAIL. A host might fall back to InputSignInMethod.KEYBOARD_DEFAULT if they do not support a particular keyboard type. If not provided, InputSignInMethod.KEYBOARD_DEFAULT will be used.

Parameters
keyboardType int

Returns
InputSignInMethod.Builder

Throws
IllegalArgumentException if the provided type is not supported

setMessage

public InputSignInMethod.Builder setMessage (CharSequence message)

Sets the message associated with this input box.

For example, this can be used to indicate formatting errors, wrong username or password or any other situation related to the user input.

Requirements

Messages can have only up to 2 lines of text, amd additional texts beyond the second line may be truncated.

Spans are supported in the input string.

Parameters
message CharSequence

Returns
InputSignInMethod.Builder

Throws
NullPointerException if message is null

setPrompt

public InputSignInMethod.Builder setPrompt (CharSequence instructions)

Sets the text explaining to the user what should be entered in this input box.

Unless set with this method, the sign-in method will not show any prompt.

Spans are supported in the input string.

Parameters
instructions CharSequence

Returns
InputSignInMethod.Builder

Throws
NullPointerException if prompt is null

setShowKeyboardByDefault

public InputSignInMethod.Builder setShowKeyboardByDefault (boolean showKeyboardByDefault)

Sets whether keyboard should be opened by default when this template is presented. By default, keyboard will only be opened if the user focuses on the input box.

Parameters
showKeyboardByDefault boolean

Returns
InputSignInMethod.Builder