当前位置: 首页>>代码示例>>Java>>正文


Java AddressUiComponent类代码示例

本文整理汇总了Java中org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent的典型用法代码示例。如果您正苦于以下问题:Java AddressUiComponent类的具体用法?Java AddressUiComponent怎么用?Java AddressUiComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AddressUiComponent类属于org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge包,在下文中一共展示了AddressUiComponent类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: commitChanges

import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent; //导入依赖的package包/类
/** Saves the edited profile on disk. */
private void commitChanges(AutofillProfile profile) {
    // Country code and phone number are always required and are always collected from the
    // editor model.
    profile.setCountryCode(mCountryField.getValue().toString());
    profile.setPhoneNumber(mPhoneField.getValue().toString());

    // Autofill profile bridge normalizes the language code for the autofill profile.
    profile.setLanguageCode(mAutofillProfileBridge.getCurrentBestLanguageCode());

    // Collect data from all visible fields and store it in the autofill profile.
    Set<Integer> visibleFields = new HashSet<>();
    for (int i = 0; i < mAddressUiComponents.size(); i++) {
        AddressUiComponent component = mAddressUiComponents.get(i);
        visibleFields.add(component.id);
        if (component.id != AddressField.COUNTRY) {
            setProfileField(profile, component.id, mAddressFields.get(component.id).getValue());
        }
    }

    // Clear the fields that are hidden from the user interface, so
    // AutofillAddress.toPaymentAddress() will send them to the renderer as empty strings.
    for (Map.Entry<Integer, EditorFieldModel> entry : mAddressFields.entrySet()) {
        if (!visibleFields.contains(entry.getKey())) {
            setProfileField(profile, entry.getKey(), "");
        }
    }

    // Calculate the label for this profile. The label's format depends on the country and
    // language code for the profile.
    PersonalDataManager pdm = PersonalDataManager.getInstance();
    // TODO(crbug.com/666048): New billing address label is wrong.
    profile.setLabel(pdm.getAddressLabelForPaymentRequest(profile));

    // Save the edited autofill profile locally.
    profile.setGUID(pdm.setProfileToLocal(profile));
    profile.setIsLocal(true);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:39,代码来源:AddressEditor.java

示例2: addAddressTextFieldsToEditor

import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent; //导入依赖的package包/类
/**
 * Adds text fields to the editor model based on the country and language code of the profile
 * that's being edited.
 */
private void addAddressTextFieldsToEditor(
        EditorModel container, String countryCode, String languageCode) {
    mAddressUiComponents = mAutofillProfileBridge.getAddressUiComponents(countryCode,
            languageCode);

    for (int i = 0; i < mAddressUiComponents.size(); i++) {
        AddressUiComponent component = mAddressUiComponents.get(i);

        // The country field is a dropdown, so there's no need to add a text field for it.
        if (component.id == AddressField.COUNTRY) continue;

        EditorFieldModel field = mAddressFields.get(component.id);
        // Labels depend on country, e.g., state is called province in some countries. These are
        // already localized.
        field.setLabel(component.label);
        field.setIsFullLine(component.isFullLine);

        // Libaddressinput formats do not always require the full name (RECIPIENT), but
        // PaymentRequest does.
        if (component.isRequired || component.id == AddressField.RECIPIENT) {
            field.setRequiredErrorMessage(mContext.getString(
                    R.string.payments_field_required_validation_message));
        } else {
            field.setRequiredErrorMessage(null);
        }

        container.addField(field);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:34,代码来源:AddressEditor.java

示例3: commitChanges

import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent; //导入依赖的package包/类
/** Saves the edited profile on disk. */
private void commitChanges(AutofillProfile profile) {
    // Country code and phone number are always required and are always collected from the
    // editor model.
    profile.setCountryCode(mCountryField.getValue().toString());
    profile.setPhoneNumber(mPhoneField.getValue().toString());

    // Autofill profile bridge normalizes the language code for the autofill profile.
    profile.setLanguageCode(mAutofillProfileBridge.getCurrentBestLanguageCode());

    // Collect data from all visible fields and store it in the autofill profile.
    Set<Integer> visibleFields = new HashSet<>();
    for (int i = 0; i < mAddressUiComponents.size(); i++) {
        AddressUiComponent component = mAddressUiComponents.get(i);
        visibleFields.add(component.id);
        if (component.id != AddressField.COUNTRY) {
            setProfileField(profile, component.id, mAddressFields.get(component.id).getValue());
        }
    }

    // Clear the fields that are hidden from the user interface, so
    // AutofillAddress.toPaymentAddress() will send them to the renderer as empty strings.
    for (Map.Entry<Integer, EditorFieldModel> entry : mAddressFields.entrySet()) {
        if (!visibleFields.contains(entry.getKey())) {
            setProfileField(profile, entry.getKey(), "");
        }
    }

    // Save the edited autofill profile locally.
    profile.setGUID(PersonalDataManager.getInstance().setProfileToLocal(mProfile));
    profile.setIsLocal(true);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:33,代码来源:AddressEditor.java

示例4: addAddressFieldsToEditor

import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent; //导入依赖的package包/类
/**
 * Adds fields to the editor model based on the country and language code of
 * the profile that's being edited.
 */
private void addAddressFieldsToEditor(
        String countryCode, String languageCode, String[] adminAreas) {
    mAddressUiComponents =
            mAutofillProfileBridge.getAddressUiComponents(countryCode, languageCode);
    // In terms of order, country must be the first field.
    mEditor.addField(mCountryField);
    for (int i = 0; i < mAddressUiComponents.size(); i++) {
        AddressUiComponent component = mAddressUiComponents.get(i);

        EditorFieldModel field = mAddressFields.get(component.id);
        // Labels depend on country, e.g., state is called province in some countries. These are
        // already localized.
        field.setLabel(component.label);
        field.setIsFullLine(component.isFullLine || component.id == AddressField.LOCALITY
                || component.id == AddressField.DEPENDENT_LOCALITY);

        if (component.id == AddressField.ADMIN_AREA && field.isDropdownField()) {
            field.setDropdownKeyValues(
                    mAutofillProfileBridge.getAdminAreaDropdownList(adminAreas));
        }

        // Libaddressinput formats do not always require the full name (RECIPIENT), but
        // PaymentRequest does.
        if (component.isRequired || component.id == AddressField.RECIPIENT) {
            field.setRequiredErrorMessage(mContext.getString(
                    R.string.payments_field_required_validation_message));
        } else {
            field.setRequiredErrorMessage(null);
        }
        mEditor.addField(field);
    }
    // Phone number must be the last field.
    mEditor.addField(mPhoneField);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:39,代码来源:AddressEditor.java

示例5: resetFormFields

import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent; //导入依赖的package包/类
private void resetFormFields(int countryCodeIndex, boolean autoFocusFirstField) {
    // Save field text so we can restore it after updating the fields for the current country,
    // and reset mAddressFields.
    String[] fieldText = new String[mAddressFields.length];
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null) {
            fieldText[i] = mAddressFields[i].getEditText().getText().toString();
            mAddressFields[i] = null;
        }
    }

    // Remove all address form fields.
    mWidgetRoot.removeAllViews();

    // Get address fields for the selected country.
    List<AddressUiComponent> fields = mAutofillProfileBridge.getAddressUiComponents(
            mCountryCodes.get(countryCodeIndex),
            mLanguageCodeString);
    if (!mUseSavedProfileLanguage) {
        mLanguageCodeString = mAutofillProfileBridge.getCurrentBestLanguageCode();
    }

    // Create form fields and focus the first field if autoFocusFirstField is true.
    boolean firstField = true;
    for (AddressUiComponent field : fields) {
        CompatibilityTextInputLayout fieldFloatLabel =
                (CompatibilityTextInputLayout) mInflater.inflate(
                        R.layout.preference_address_float_label_layout, mWidgetRoot, false);
        fieldFloatLabel.setHint(field.label);

        EditText fieldEditText = fieldFloatLabel.getEditText();
        fieldEditText.addTextChangedListener(this);
        if (field.id == AddressField.STREET_ADDRESS) {
            fieldEditText.setSingleLine(false);
        }

        mAddressFields[field.id] = fieldFloatLabel;
        mWidgetRoot.addView(fieldFloatLabel);

        if (firstField && autoFocusFirstField) {
            fieldEditText.requestFocus();
            firstField = false;
        }
    }

    // Add back saved field text.
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null && fieldText[i] != null
                && !TextUtils.isEmpty(fieldText[i])) {
            mAddressFields[i].getEditText().setText(fieldText[i]);
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:AutofillProfileEditor.java


注:本文中的org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.AddressUiComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。