android.view.View#AUTOFILL_HINT_USERNAME源码实例Demo

下面列出了android.view.View#AUTOFILL_HINT_USERNAME 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: input-samples   文件: DebugService.java
/**
 * 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;
}
 
源代码2 项目: android-AutofillFramework   文件: DebugService.java
/**
 * 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;
}
 
 方法所在类
 同类方法