/**
* Checks address completion status in the given profile.
*
* If the country code is not set or invalid, but all fields for the default locale's country
* code are present, then the profile is deemed "complete." AutoflllAddress.toPaymentAddress()
* will use the default locale to fill in a blank country code before sending the address to the
* renderer.
*
* @param profile The autofill profile containing the address information.
* @return int The completion status.
*/
@CompletionStatus
public static int checkAddressCompletionStatus(AutofillProfile profile) {
int invalidFieldsCount = 0;
int completionStatus = COMPLETE;
if (!PhoneNumberUtils.isGlobalPhoneNumber(
PhoneNumberUtils.stripSeparators(profile.getPhoneNumber().toString()))) {
completionStatus = INVALID_PHONE_NUMBER;
invalidFieldsCount++;
}
List<Integer> requiredFields = AutofillProfileBridge.getRequiredAddressFields(
AutofillAddress.getCountryCode(profile));
for (int fieldId : requiredFields) {
if (fieldId == AddressField.RECIPIENT || fieldId == AddressField.COUNTRY) continue;
if (!TextUtils.isEmpty(getProfileField(profile, fieldId))) continue;
completionStatus = INVALID_ADDRESS;
invalidFieldsCount++;
break;
}
if (TextUtils.isEmpty(profile.getFullName())) {
completionStatus = INVALID_RECIPIENT;
invalidFieldsCount++;
}
if (invalidFieldsCount > 1) {
completionStatus = INVALID_MULTIPLE_FIELDS;
}
return completionStatus;
}
AutofillAddress.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:chromium-for-android-56-debug-video
作者:
评论列表
文章目录