Java Code Examples for android.view.View.AUTOFILL_TYPE_LIST

The following are Jave code examples for showing how to use AUTOFILL_TYPE_LIST of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: android-AutofillFramework   File: Util.java   Source Code and License Vote up 5 votes
public static String getTypeAsString(int type) {
    switch (type) {
        case View.AUTOFILL_TYPE_TEXT:
            return "TYPE_TEXT";
        case View.AUTOFILL_TYPE_LIST:
            return "TYPE_LIST";
        case View.AUTOFILL_TYPE_NONE:
            return "TYPE_NONE";
        case View.AUTOFILL_TYPE_TOGGLE:
            return "TYPE_TOGGLE";
        case View.AUTOFILL_TYPE_DATE:
            return "TYPE_DATE";
    }
    return "UNKNOWN_TYPE";
}
 
Example 2
Project: android-AutofillFramework   File: Util.java   Source Code and License Vote up 5 votes
public static String getAutofillTypeAsString(int type) {
    switch (type) {
        case View.AUTOFILL_TYPE_TEXT:
            return "TYPE_TEXT";
        case View.AUTOFILL_TYPE_LIST:
            return "TYPE_LIST";
        case View.AUTOFILL_TYPE_NONE:
            return "TYPE_NONE";
        case View.AUTOFILL_TYPE_TOGGLE:
            return "TYPE_TOGGLE";
        case View.AUTOFILL_TYPE_DATE:
            return "TYPE_DATE";
    }
    return "UNKNOWN_TYPE";
}
 
Example 3
Project: android-AutofillFramework   File: FilledAutofillFieldCollection.java   Source Code and License Vote up 4 votes
/**
 * Populates a {@link Dataset.Builder} with appropriate values for each {@link AutofillId}
 * in a {@code AutofillFieldMetadataCollection}.
 * <p>
 * In other words, it constructs an autofill
 * {@link Dataset.Builder} by applying saved values (from this {@code FilledAutofillFieldCollection})
 * to Views specified in a {@code AutofillFieldMetadataCollection}, which represents the current
 * page the user is on.
 */
public boolean applyToFields(AutofillFieldMetadataCollection autofillFieldMetadataCollection,
        Dataset.Builder datasetBuilder) {
    boolean setValueAtLeastOnce = false;
    List<String> allHints = autofillFieldMetadataCollection.getAllHints();
    for (int hintIndex = 0; hintIndex < allHints.size(); hintIndex++) {
        String hint = allHints.get(hintIndex);
        List<AutofillFieldMetadata> fillableAutofillFields =
                autofillFieldMetadataCollection.getFieldsForHint(hint);
        if (fillableAutofillFields == null) {
            continue;
        }
        for (int autofillFieldIndex = 0; autofillFieldIndex < fillableAutofillFields.size(); autofillFieldIndex++) {
            FilledAutofillField filledAutofillField = mHintMap.get(hint);
            if (filledAutofillField == null) {
                continue;
            }
            AutofillFieldMetadata autofillFieldMetadata = fillableAutofillFields.get(autofillFieldIndex);
            AutofillId autofillId = autofillFieldMetadata.getId();
            int autofillType = autofillFieldMetadata.getAutofillType();
            switch (autofillType) {
                case View.AUTOFILL_TYPE_LIST:
                    int listValue = autofillFieldMetadata.getAutofillOptionIndex(filledAutofillField.getTextValue());
                    if (listValue != -1) {
                        datasetBuilder.setValue(autofillId, AutofillValue.forList(listValue));
                        setValueAtLeastOnce = true;
                    }
                    break;
                case View.AUTOFILL_TYPE_DATE:
                    Long dateValue = filledAutofillField.getDateValue();
                    if (dateValue != null) {
                        datasetBuilder.setValue(autofillId, AutofillValue.forDate(dateValue));
                        setValueAtLeastOnce = true;
                    }
                    break;
                case View.AUTOFILL_TYPE_TEXT:
                    String textValue = filledAutofillField.getTextValue();
                    if (textValue != null) {
                        datasetBuilder.setValue(autofillId, AutofillValue.forText(textValue));
                        setValueAtLeastOnce = true;
                    }
                    break;
                case View.AUTOFILL_TYPE_TOGGLE:
                    Boolean toggleValue = filledAutofillField.getToggleValue();
                    if (toggleValue != null) {
                        datasetBuilder.setValue(autofillId, AutofillValue.forToggle(toggleValue));
                        setValueAtLeastOnce = true;
                    }
                    break;
                case View.AUTOFILL_TYPE_NONE:
                default:
                    logw("Invalid autofill type - %d", autofillType);
                    break;
            }
        }
    }
    return setValueAtLeastOnce;
}