CustomDescription.Builder.BatchUpdate(IValidator, BatchUpdates) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Updates the presentation template when a condition is satisfied by applying a series of remote view operations.
[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
Parameters
- condition
- IValidator
condition used to trigger the updates. This value cannot be null.
- updates
- BatchUpdates
actions to be applied to the template presentation when the condition is satisfied. This value cannot be null.
Returns
this builder. This value cannot be null.
- Attributes
Remarks
Updates the presentation template when a condition is satisfied by applying a series of remote view operations. This allows dynamic customization of the portion of the save UI that is controlled by the autofill service. Such dynamic customization is based on the content of target views.
The updates are applied in the sequence they are added, after the transformations are applied to the children views.
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();
Another approach is to add a child first, then apply the transformations.
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();
Android reference for android.service.autofill.CustomDescription.Builder.batchUpdate.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.