use of org.chromium.chrome.browser.widget.CompatibilityTextInputLayout in project AndroidChromium by JackyAndroid.
the class AutofillProfileEditor method resetFormFields.
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]);
}
}
}
Aggregations