org.chromium.chrome.browser.widget.CompatibilityTextInputLayout Java Examples

The following examples show how to use org.chromium.chrome.browser.widget.CompatibilityTextInputLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutofillProfileEditor.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    mInflater = inflater;
    mAddressFields = new CompatibilityTextInputLayout[AddressField.NUM_FIELDS];

    mPhoneText = (EditText) v.findViewById(R.id.phone_number_edit);
    mPhoneLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.phone_number_label);
    mEmailText = (EditText) v.findViewById(R.id.email_address_edit);
    mEmailLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.email_address_label);
    mWidgetRoot = (ViewGroup) v.findViewById(R.id.autofill_profile_widget_root);
    mCountriesDropdown = (Spinner) v.findViewById(R.id.countries);

    mAutofillProfileBridge = new AutofillProfileBridge();

    populateCountriesDropdown();
    createAndPopulateEditFields();
    initializeButtons(v);

    return v;
}
 
Example #2
Source File: AutofillLocalCardEditor.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    mNameLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_name_label);
    mNameText = (EditText) v.findViewById(R.id.credit_card_name_edit);
    mNumberLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_number_label);
    mNumberText = (EditText) v.findViewById(R.id.credit_card_number_edit);

    // Set text watcher to format credit card number
    mNumberText.addTextChangedListener(new CreditCardNumberFormattingTextWatcher());

    mExpirationMonth = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_month_spinner);
    mExpirationYear = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_year_spinner);

    addSpinnerAdapters();
    addCardDataToEditFields();
    initializeButtons(v);
    return v;
}
 
Example #3
Source File: AutofillProfileEditor.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    mInflater = inflater;
    mAddressFields = new CompatibilityTextInputLayout[AddressField.NUM_FIELDS];

    mPhoneText = (EditText) v.findViewById(R.id.phone_number_edit);
    mPhoneLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.phone_number_label);
    mEmailText = (EditText) v.findViewById(R.id.email_address_edit);
    mEmailLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.email_address_label);
    mWidgetRoot = (ViewGroup) v.findViewById(R.id.autofill_profile_widget_root);
    mCountriesDropdown = (Spinner) v.findViewById(R.id.spinner);

    TextView countriesLabel = (TextView) v.findViewById(R.id.spinner_label);
    countriesLabel.setText(v.getContext().getString(R.string.autofill_profile_editor_country));

    mAutofillProfileBridge = new AutofillProfileBridge();

    populateCountriesDropdown();
    createAndPopulateEditFields();
    initializeButtons(v);

    return v;
}
 
Example #4
Source File: AutofillLocalCardEditor.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    mNameLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_name_label);
    mNameText = (EditText) v.findViewById(R.id.credit_card_name_edit);
    mNumberLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_number_label);
    mNumberText = (EditText) v.findViewById(R.id.credit_card_number_edit);

    // Set text watcher to format credit card number
    mNumberText.addTextChangedListener(new CreditCardNumberFormattingTextWatcher());

    mExpirationMonth = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_month_spinner);
    mExpirationYear = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_year_spinner);

    addSpinnerAdapters();
    addCardDataToEditFields();
    initializeButtons(v);
    return v;
}
 
Example #5
Source File: AutofillProfileEditor.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    mInflater = inflater;
    mAddressFields = new CompatibilityTextInputLayout[AddressField.NUM_FIELDS];

    mPhoneText = (EditText) v.findViewById(R.id.phone_number_edit);
    mPhoneLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.phone_number_label);
    mEmailText = (EditText) v.findViewById(R.id.email_address_edit);
    mEmailLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.email_address_label);
    mWidgetRoot = (ViewGroup) v.findViewById(R.id.autofill_profile_widget_root);
    mCountriesDropdown = (Spinner) v.findViewById(R.id.spinner);

    TextView countriesLabel = (TextView) v.findViewById(R.id.spinner_label);
    countriesLabel.setText(v.getContext().getString(R.string.autofill_profile_editor_country));

    mAutofillProfileBridge = new AutofillProfileBridge();

    populateCountriesDropdown();
    createAndPopulateEditFields();
    initializeButtons(v);

    return v;
}
 
Example #6
Source File: AutofillProfileEditor.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean allFieldsEmpty() {
    if (!TextUtils.isEmpty(mPhoneText.getText())
            || !TextUtils.isEmpty(mEmailText.getText())) {
        return false;
    }
    for (CompatibilityTextInputLayout field : mAddressFields) {
        if (field != null && !TextUtils.isEmpty(field.getEditText().getText())) {
            return false;
        }
    }

    return true;
}
 
Example #7
Source File: AutofillProfileEditor.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private boolean allFieldsEmpty() {
    if (!TextUtils.isEmpty(mPhoneText.getText())
            || !TextUtils.isEmpty(mEmailText.getText())) {
        return false;
    }
    for (CompatibilityTextInputLayout field : mAddressFields) {
        if (field != null && !TextUtils.isEmpty(field.getEditText().getText())) {
            return false;
        }
    }

    return true;
}
 
Example #8
Source File: AutofillProfileEditor.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private boolean allFieldsEmpty() {
    if (!TextUtils.isEmpty(mPhoneText.getText())
            || !TextUtils.isEmpty(mEmailText.getText())) {
        return false;
    }
    for (CompatibilityTextInputLayout field : mAddressFields) {
        if (field != null && !TextUtils.isEmpty(field.getEditText().getText())) {
            return false;
        }
    }

    return true;
}
 
Example #9
Source File: AutofillLocalCardEditor.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // Allow screenshots of the credit card number in Canary, Dev, and developer builds.
    if (ChromeVersionInfo.isBetaBuild() || ChromeVersionInfo.isStableBuild()) {
        WindowManager.LayoutParams attributes = getActivity().getWindow().getAttributes();
        attributes.flags |= WindowManager.LayoutParams.FLAG_SECURE;
        getActivity().getWindow().setAttributes(attributes);
    }

    View v = super.onCreateView(inflater, container, savedInstanceState);

    mNameLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_name_label);
    mNameText = (EditText) v.findViewById(R.id.credit_card_name_edit);
    mNumberLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_number_label);
    mNumberText = (EditText) v.findViewById(R.id.credit_card_number_edit);

    // Set text watcher to format credit card number
    mNumberText.addTextChangedListener(new CreditCardNumberFormattingTextWatcher());

    mExpirationMonth = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_month_spinner);
    mExpirationYear = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_year_spinner);

    addSpinnerAdapters();
    addCardDataToEditFields();
    initializeButtons(v);
    return v;
}
 
Example #10
Source File: AutofillProfileEditor.java    From delion with Apache License 2.0 4 votes vote down vote up
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.setContentDescription(field.label);
        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]);
        }
    }
}
 
Example #11
Source File: AutofillProfileEditor.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
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]);
        }
    }
}
 
Example #12
Source File: AutofillProfileEditor.java    From 365browser with Apache License 2.0 4 votes vote down vote up
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]);
        }
    }
}