Lenguaje

CustomDescription.Builder.BatchUpdate(IValidator, BatchUpdates) Método

Definición

Actualiza la plantilla de presentación cuando se cumple una condición aplicando una serie de operaciones de vista remota.

[Android.Runtime.Register("batchUpdate", "(Landroid/service/autofill/Validator;Landroid/service/autofill/BatchUpdates;)Landroid/service/autofill/CustomDescription$Builder;", "GetBatchUpdate_Landroid_service_autofill_Validator_Landroid_service_autofill_BatchUpdates_Handler", ApiSince=28)]
public virtual Android.Service.Autofill.CustomDescription.Builder BatchUpdate(Android.Service.Autofill.IValidator condition, Android.Service.Autofill.BatchUpdates updates);
[<Android.Runtime.Register("batchUpdate", "(Landroid/service/autofill/Validator;Landroid/service/autofill/BatchUpdates;)Landroid/service/autofill/CustomDescription$Builder;", "GetBatchUpdate_Landroid_service_autofill_Validator_Landroid_service_autofill_BatchUpdates_Handler", ApiSince=28)>]
abstract member BatchUpdate : Android.Service.Autofill.IValidator * Android.Service.Autofill.BatchUpdates -> Android.Service.Autofill.CustomDescription.Builder
override this.BatchUpdate : Android.Service.Autofill.IValidator * Android.Service.Autofill.BatchUpdates -> Android.Service.Autofill.CustomDescription.Builder

Parámetros

condition
IValidator

condición que se usa para desencadenar las actualizaciones. Este valor no puede ser nulo.

updates
BatchUpdates

acciones que se aplicarán a la presentación de la plantilla cuando se cumpla la condición. Este valor no puede ser nulo.

Devoluciones

este generador. Este valor no puede ser nulo.

Atributos

Comentarios

Actualiza la plantilla de presentación cuando se cumple una condición aplicando una serie de operaciones de vista remota. Esto permite la personalización dinámica de la parte de la interfaz de usuario de guardado controlada por el servicio autorrellenar. Esta personalización dinámica se basa en el contenido de las vistas de destino.

Las actualizaciones se aplican en la secuencia que se agregan, después de aplicar las transformaciones a las vistas secundarias.

RemoteViews template = new RemoteViews(pgkName, R.layout.my_full_template);

Pattern notEmptyPattern = Pattern.compile(".+");
Validator hasAddress = new RegexValidator(addressAutofillId, notEmptyPattern);
Validator hasCcNumber = new RegexValidator(ccNumberAutofillId, notEmptyPattern);

RemoteViews addressUpdates = new RemoteViews(pgkName, R.layout.my_full_template)
addressUpdates.setViewVisibility(R.id.address, View.VISIBLE);

// Make address visible
BatchUpdates addressBatchUpdates = new BatchUpdates.Builder()
    .updateTemplate(addressUpdates)
    .build();

RemoteViews ccUpdates = new RemoteViews(pgkName, R.layout.my_full_template)
ccUpdates.setViewVisibility(R.id.cc_number, View.VISIBLE);

// Mask credit card number (as .....LAST_4_DIGITS) and make it visible
BatchUpdates ccBatchUpdates = new BatchUpdates.Builder()
    .updateTemplate(ccUpdates)
    .transformChild(R.id.templateCcNumber, new CharSequenceTransformation
                    .Builder(ccNumberId, Pattern.compile("^.*(\\d\\d\\d\\d)$"), "...$1")
                    .build())
    .build();

CustomDescription customDescription = new CustomDescription.Builder(template)
    .batchUpdate(hasAddress, addressBatchUpdates)
    .batchUpdate(hasCcNumber, ccBatchUpdates)
    .build();

Otro enfoque consiste en agregar primero un elemento secundario y, a continuación, aplicar las transformaciones.

RemoteViews template = new RemoteViews(pgkName, R.layout.my_base_template);

RemoteViews addressPresentation = new RemoteViews(pgkName, R.layout.address)
RemoteViews addressUpdates = new RemoteViews(pgkName, R.layout.my_template)
addressUpdates.addView(R.id.parentId, addressPresentation);
BatchUpdates addressBatchUpdates = new BatchUpdates.Builder()
    .updateTemplate(addressUpdates)
    .build();

RemoteViews ccPresentation = new RemoteViews(pgkName, R.layout.cc)
RemoteViews ccUpdates = new RemoteViews(pgkName, R.layout.my_template)
ccUpdates.addView(R.id.parentId, ccPresentation);
BatchUpdates ccBatchUpdates = new BatchUpdates.Builder()
    .updateTemplate(ccUpdates)
    .transformChild(R.id.templateCcNumber, new CharSequenceTransformation
                    .Builder(ccNumberId, Pattern.compile("^.*(\\d\\d\\d\\d)$"), "...$1")
                    .build())
    .build();

CustomDescription customDescription = new CustomDescription.Builder(template)
    .batchUpdate(hasAddress, addressBatchUpdates)
    .batchUpdate(hasCcNumber, ccBatchUpdates)
    .build();

Referencia de Android para android.service.autofill.CustomDescription.Builder.batchUpdate.

Las partes de esta página son modificaciones basadas en el trabajo creado y compartido por el Android y se usan según los términos descritos en creative Creative Commons 2.5 Attribution License.

Se aplica a