Java Code Examples for android.view.View#AUTOFILL_TYPE_DATE

The following examples show how to use android.view.View#AUTOFILL_TYPE_DATE . 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: Util.java    From input-samples with Apache License 2.0 5 votes vote down vote up
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
Source File: Util.java    From input-samples with Apache License 2.0 5 votes vote down vote up
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
Source File: Util.java    From android-AutofillFramework with Apache License 2.0 5 votes vote down vote up
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 4
Source File: Util.java    From android-AutofillFramework with Apache License 2.0 5 votes vote down vote up
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 5
Source File: DatasetAdapter.java    From input-samples with Apache License 2.0 4 votes vote down vote up
void bindValueToNode(AssistStructure.ViewNode viewNode,
        FilledAutofillField field, Dataset.Builder builder,
        MutableBoolean setValueAtLeastOnce) {
    AutofillId autofillId = viewNode.getAutofillId();
    if (autofillId == null) {
        logw("Autofill ID null for %s", viewNode.toString());
        return;
    }
    int autofillType = viewNode.getAutofillType();
    switch (autofillType) {
        case View.AUTOFILL_TYPE_LIST:
            CharSequence[] options = viewNode.getAutofillOptions();
            int listValue = -1;
            if (options != null) {
                listValue = indexOf(viewNode.getAutofillOptions(), field.getTextValue());
            }
            if (listValue != -1) {
                builder.setValue(autofillId, AutofillValue.forList(listValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_DATE:
            Long dateValue = field.getDateValue();
            if (dateValue != null) {
                builder.setValue(autofillId, AutofillValue.forDate(dateValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TEXT:
            String textValue = field.getTextValue();
            if (textValue != null) {
                builder.setValue(autofillId, AutofillValue.forText(textValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TOGGLE:
            Boolean toggleValue = field.getToggleValue();
            if (toggleValue != null) {
                builder.setValue(autofillId, AutofillValue.forToggle(toggleValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_NONE:
        default:
            logw("Invalid autofill type - %d", autofillType);
            break;
    }
}
 
Example 6
Source File: MultiplePartitionsActivity.java    From input-samples with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.multiple_partitions_activity);
    mCustomVirtualView = findViewById(R.id.custom_view);
    mCredentialsPartition =
            mCustomVirtualView.addPartition(getString(R.string.partition_credentials));
    mCredentialsPartition.addLine("username", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.username_label),
            "         ", false, View.AUTOFILL_HINT_USERNAME);
    mCredentialsPartition.addLine("password", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.password_label),
            "         ", true, View.AUTOFILL_HINT_PASSWORD);
    int ccExpirationType = View.AUTOFILL_TYPE_DATE;
    // TODO: add a checkbox to switch between text / date instead
    Intent intent = getIntent();
    if (intent != null) {
        int newType = intent.getIntExtra("dateType", -1);
        if (newType != -1) {
            ccExpirationType = newType;
            String typeMessage = getString(R.string.message_credit_card_expiration_type,
                    Util.getAutofillTypeAsString(ccExpirationType));
            // TODO: display type in a header or proper status widget
            Toast.makeText(getApplicationContext(), typeMessage, Toast.LENGTH_LONG).show();
        }
    }
    mCcPartition = mCustomVirtualView.addPartition(getString(R.string.partition_credit_card));
    mCcPartition.addLine("ccNumber", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_number_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_NUMBER);
    mCcPartition.addLine("ccDay", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_expiration_day_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY);
    mCcPartition.addLine("ccMonth", ccExpirationType,
            getString(R.string.credit_card_expiration_month_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH);
    mCcPartition.addLine("ccYear", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_expiration_year_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR);
    mCcPartition.addLine("ccDate", ccExpirationType,
            getString(R.string.credit_card_expiration_date_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE);
    mCcPartition.addLine("ccSecurityCode", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_security_code_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE);
    mAutofillManager = getSystemService(AutofillManager.class);
    findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            resetFields();
            mCustomVirtualView.resetPositions();
            mAutofillManager.cancel();
        }
    });
}
 
Example 7
Source File: DatasetAdapter.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
void bindValueToNode(AssistStructure.ViewNode viewNode,
        FilledAutofillField field, Dataset.Builder builder,
        MutableBoolean setValueAtLeastOnce) {
    AutofillId autofillId = viewNode.getAutofillId();
    if (autofillId == null) {
        logw("Autofill ID null for %s", viewNode.toString());
        return;
    }
    int autofillType = viewNode.getAutofillType();
    switch (autofillType) {
        case View.AUTOFILL_TYPE_LIST:
            CharSequence[] options = viewNode.getAutofillOptions();
            int listValue = -1;
            if (options != null) {
                listValue = indexOf(viewNode.getAutofillOptions(), field.getTextValue());
            }
            if (listValue != -1) {
                builder.setValue(autofillId, AutofillValue.forList(listValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_DATE:
            Long dateValue = field.getDateValue();
            if (dateValue != null) {
                builder.setValue(autofillId, AutofillValue.forDate(dateValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TEXT:
            String textValue = field.getTextValue();
            if (textValue != null) {
                builder.setValue(autofillId, AutofillValue.forText(textValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TOGGLE:
            Boolean toggleValue = field.getToggleValue();
            if (toggleValue != null) {
                builder.setValue(autofillId, AutofillValue.forToggle(toggleValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_NONE:
        default:
            logw("Invalid autofill type - %d", autofillType);
            break;
    }
}
 
Example 8
Source File: MultiplePartitionsActivity.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.multiple_partitions_activity);
    mCustomVirtualView = findViewById(R.id.custom_view);
    mCredentialsPartition =
            mCustomVirtualView.addPartition(getString(R.string.partition_credentials));
    mCredentialsPartition.addLine("username", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.username_label),
            "         ", false, View.AUTOFILL_HINT_USERNAME);
    mCredentialsPartition.addLine("password", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.password_label),
            "         ", true, View.AUTOFILL_HINT_PASSWORD);
    int ccExpirationType = View.AUTOFILL_TYPE_DATE;
    // TODO: add a checkbox to switch between text / date instead
    Intent intent = getIntent();
    if (intent != null) {
        int newType = intent.getIntExtra("dateType", -1);
        if (newType != -1) {
            ccExpirationType = newType;
            String typeMessage = getString(R.string.message_credit_card_expiration_type,
                    Util.getAutofillTypeAsString(ccExpirationType));
            // TODO: display type in a header or proper status widget
            Toast.makeText(getApplicationContext(), typeMessage, Toast.LENGTH_LONG).show();
        }
    }
    mCcPartition = mCustomVirtualView.addPartition(getString(R.string.partition_credit_card));
    mCcPartition.addLine("ccNumber", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_number_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_NUMBER);
    mCcPartition.addLine("ccDay", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_expiration_day_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY);
    mCcPartition.addLine("ccMonth", ccExpirationType,
            getString(R.string.credit_card_expiration_month_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH);
    mCcPartition.addLine("ccYear", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_expiration_year_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR);
    mCcPartition.addLine("ccDate", ccExpirationType,
            getString(R.string.credit_card_expiration_date_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE);
    mCcPartition.addLine("ccSecurityCode", View.AUTOFILL_TYPE_TEXT,
            getString(R.string.credit_card_security_code_label),
            "         ", true, View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE);
    mAutofillManager = getSystemService(AutofillManager.class);
    findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            resetFields();
            mCustomVirtualView.resetPositions();
            mAutofillManager.cancel();
        }
    });
}