private static List removePrefixes()

in AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/AutofillHints.java [102:132]


    private static List<String> removePrefixes(@NonNull List<String> hints) {
        List<String> hintsWithoutPrefixes = new ArrayList<>();
        String nextHint = null;
        for (int i = 0; i < hints.size(); i++) {
            String hint = hints.get(i);
            if (i < hints.size() - 1) {
                nextHint = hints.get(i + 1);
            }
            // First convert the compound W3C autofill hints
            if (isW3cSectionPrefix(hint) && i < hints.size() - 1) {
                i++;
                hint = hints.get(i);
                logd("Hint is a W3C section prefix; using %s instead", hint);
                if (i < hints.size() - 1) {
                    nextHint = hints.get(i + 1);
                }
            }
            if (isW3cTypePrefix(hint) && nextHint != null && isW3cTypeHint(nextHint)) {
                hint = nextHint;
                i++;
                logd("Hint is a W3C type prefix; using %s instead", hint);
            }
            if (isW3cAddressType(hint) && nextHint != null) {
                hint = nextHint;
                i++;
                logd("Hint is a W3C address prefix; using %s instead", hint);
            }
            hintsWithoutPrefixes.add(hint);
        }
        return hintsWithoutPrefixes;
    }