Java Code Examples for android.view.View#AUTOFILL_HINT_USERNAME

The following examples show how to use android.view.View#AUTOFILL_HINT_USERNAME . 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: DebugService.java    From input-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Uses heuristics to infer an autofill hint from a {@code string}.
 *
 * @return standard autofill hint, or {@code null} when it could not be inferred.
 */
@Nullable
protected String inferHint(ViewNode node, @Nullable String actualHint) {
    if (actualHint == null) return null;

    String hint = actualHint.toLowerCase();
    if (hint.contains("label") || hint.contains("container")) {
        Log.v(TAG, "Ignoring 'label/container' hint: " + hint);
        return null;
    }

    if (hint.contains("password")) return View.AUTOFILL_HINT_PASSWORD;
    if (hint.contains("username")
            || (hint.contains("login") && hint.contains("id")))
        return View.AUTOFILL_HINT_USERNAME;
    if (hint.contains("email")) return View.AUTOFILL_HINT_EMAIL_ADDRESS;
    if (hint.contains("name")) return View.AUTOFILL_HINT_NAME;
    if (hint.contains("phone")) return View.AUTOFILL_HINT_PHONE;

    // When everything else fails, return the full string - this is helpful to help app
    // developers visualize when autofill is triggered when it shouldn't (for example, in a
    // chat conversation window), so they can mark the root view of such activities with
    // android:importantForAutofill=noExcludeDescendants
    if (node.isEnabled() && node.getAutofillType() != View.AUTOFILL_TYPE_NONE) {
        Log.v(TAG, "Falling back to " + actualHint);
        return actualHint;
    }
    return null;
}
 
Example 2
Source File: DebugService.java    From android-AutofillFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Uses heuristics to infer an autofill hint from a {@code string}.
 *
 * @return standard autofill hint, or {@code null} when it could not be inferred.
 */
@Nullable
protected String inferHint(ViewNode node, @Nullable String actualHint) {
    if (actualHint == null) return null;

    String hint = actualHint.toLowerCase();
    if (hint.contains("label") || hint.contains("container")) {
        Log.v(TAG, "Ignoring 'label/container' hint: " + hint);
        return null;
    }

    if (hint.contains("password")) return View.AUTOFILL_HINT_PASSWORD;
    if (hint.contains("username")
            || (hint.contains("login") && hint.contains("id")))
        return View.AUTOFILL_HINT_USERNAME;
    if (hint.contains("email")) return View.AUTOFILL_HINT_EMAIL_ADDRESS;
    if (hint.contains("name")) return View.AUTOFILL_HINT_NAME;
    if (hint.contains("phone")) return View.AUTOFILL_HINT_PHONE;

    // When everything else fails, return the full string - this is helpful to help app
    // developers visualize when autofill is triggered when it shouldn't (for example, in a
    // chat conversation window), so they can mark the root view of such activities with
    // android:importantForAutofill=noExcludeDescendants
    if (node.isEnabled() && node.getAutofillType() != View.AUTOFILL_TYPE_NONE) {
        Log.v(TAG, "Falling back to " + actualHint);
        return actualHint;
    }
    return null;
}