android.view.ViewStructure.HtmlInfo Java Examples

The following examples show how to use android.view.ViewStructure.HtmlInfo. 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 Project: input-samples   Author: android   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
private static void dumpNode(StringBuilder builder, String prefix, ViewNode node, int childNumber) {
    builder.append(prefix)
            .append("child #").append(childNumber).append("\n");

    builder.append(prefix)
            .append("autoFillId: ").append(node.getAutofillId())
            .append("\tidEntry: ").append(node.getIdEntry())
            .append("\tid: ").append(node.getId())
            .append("\tclassName: ").append(node.getClassName())
            .append('\n');

    builder.append(prefix)
            .append("focused: ").append(node.isFocused())
            .append("\tvisibility").append(node.getVisibility())
            .append("\tchecked: ").append(node.isChecked())
            .append("\twebDomain: ").append(node.getWebDomain())
            .append("\thint: ").append(node.getHint())
            .append('\n');

    HtmlInfo htmlInfo = node.getHtmlInfo();

    if (htmlInfo != null) {
        builder.append(prefix)
                .append("HTML TAG: ").append(htmlInfo.getTag())
                .append(" attrs: ").append(htmlInfo.getAttributes())
                .append('\n');
    }

    String[] afHints = node.getAutofillHints();
    CharSequence[] options = node.getAutofillOptions();
    builder.append(prefix).append("afType: ").append(getTypeAsString(node.getAutofillType()))
            .append("\tafValue:")
            .append(getAutofillValueAndTypeAsString(node.getAutofillValue()))
            .append("\tafOptions:").append(options == null ? "N/A" : Arrays.toString(options))
            .append("\tafHints: ").append(afHints == null ? "N/A" : Arrays.toString(afHints))
            .append("\tinputType:").append(node.getInputType())
            .append('\n');

    int numberChildren = node.getChildCount();
    builder.append(prefix).append("# children: ").append(numberChildren)
            .append("\ttext: ").append(node.getText())
            .append('\n');

    final String prefix2 = prefix + "  ";
    for (int i = 0; i < numberChildren; i++) {
        dumpNode(builder, prefix2, node.getChildAt(i), i);
    }
    logv(builder.toString());
}
 
Example #2
Source Project: input-samples   Author: android   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
private static void dumpNode(String prefix, ViewNode node) {
    StringBuilder builder = new StringBuilder();
    builder.append(prefix)
            .append("autoFillId: ").append(node.getAutofillId())
            .append("\tidEntry: ").append(node.getIdEntry())
            .append("\tid: ").append(node.getId())
            .append("\tclassName: ").append(node.getClassName())
            .append('\n');

    builder.append(prefix)
            .append("focused: ").append(node.isFocused())
            .append("\tvisibility").append(node.getVisibility())
            .append("\tchecked: ").append(node.isChecked())
            .append("\twebDomain: ").append(node.getWebDomain())
            .append("\thint: ").append(node.getHint())
            .append('\n');

    HtmlInfo htmlInfo = node.getHtmlInfo();

    if (htmlInfo != null) {
        builder.append(prefix)
                .append("HTML TAG: ").append(htmlInfo.getTag())
                .append(" attrs: ").append(htmlInfo.getAttributes())
                .append('\n');
    }

    String[] afHints = node.getAutofillHints();
    CharSequence[] options = node.getAutofillOptions();
    builder.append(prefix).append("afType: ").append(getAutofillTypeAsString(node.getAutofillType()))
            .append("\tafValue:")
            .append(getAutofillValueAndTypeAsString(node.getAutofillValue()))
            .append("\tafOptions:").append(options == null ? "N/A" : Arrays.toString(options))
            .append("\tafHints: ").append(afHints == null ? "N/A" : Arrays.toString(afHints))
            .append("\tinputType:").append(node.getInputType())
            .append('\n');

    int numberChildren = node.getChildCount();
    builder.append(prefix).append("# children: ").append(numberChildren)
            .append("\ttext: ").append(node.getText())
            .append('\n');

    Log.v(TAG, builder.toString());
    final String prefix2 = prefix + "  ";
    for (int i = 0; i < numberChildren; i++) {
        Log.v(TAG, prefix + "child #" + i);
        dumpNode(prefix2, node.getChildAt(i));
    }
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: AssistStructure.java    License: Apache License 2.0 4 votes vote down vote up
ViewNode(ParcelTransferReader reader, int nestingLevel) {
    final Parcel in = reader.readParcel(VALIDATE_VIEW_TOKEN, nestingLevel);
    reader.mNumReadViews++;
    final PooledStringReader preader = reader.mStringReader;
    mClassName = preader.readString();
    mFlags = in.readInt();
    final int flags = mFlags;
    if ((flags&FLAGS_HAS_ID) != 0) {
        mId = in.readInt();
        if (mId != View.NO_ID) {
            mIdEntry = preader.readString();
            if (mIdEntry != null) {
                mIdType = preader.readString();
                mIdPackage = preader.readString();
            }
        }
    }

    if ((flags&FLAGS_HAS_AUTOFILL_DATA) != 0) {
        mSanitized = in.readInt() == 1;
        mAutofillId = in.readParcelable(null);
        mAutofillType = in.readInt();
        mAutofillHints = in.readStringArray();
        mAutofillValue = in.readParcelable(null);
        mAutofillOptions = in.readCharSequenceArray();
        final Parcelable p = in.readParcelable(null);
        if (p instanceof HtmlInfo) {
            mHtmlInfo = (HtmlInfo) p;
        }
        mMinEms = in.readInt();
        mMaxEms = in.readInt();
        mMaxLength = in.readInt();
        mTextIdEntry = preader.readString();
        mImportantForAutofill = in.readInt();
    }
    if ((flags&FLAGS_HAS_LARGE_COORDS) != 0) {
        mX = in.readInt();
        mY = in.readInt();
        mWidth = in.readInt();
        mHeight = in.readInt();
    } else {
        int val = in.readInt();
        mX = val&0x7fff;
        mY = (val>>16)&0x7fff;
        val = in.readInt();
        mWidth = val&0x7fff;
        mHeight = (val>>16)&0x7fff;
    }
    if ((flags&FLAGS_HAS_SCROLL) != 0) {
        mScrollX = in.readInt();
        mScrollY = in.readInt();
    }
    if ((flags&FLAGS_HAS_MATRIX) != 0) {
        mMatrix = new Matrix();
        in.readFloatArray(reader.mTmpMatrix);
        mMatrix.setValues(reader.mTmpMatrix);
    }
    if ((flags&FLAGS_HAS_ELEVATION) != 0) {
        mElevation = in.readFloat();
    }
    if ((flags&FLAGS_HAS_ALPHA) != 0) {
        mAlpha = in.readFloat();
    }
    if ((flags&FLAGS_HAS_CONTENT_DESCRIPTION) != 0) {
        mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
    }
    if ((flags&FLAGS_HAS_TEXT) != 0) {
        mText = new ViewNodeText(in, (flags&FLAGS_HAS_COMPLEX_TEXT) == 0);
    }
    if ((flags&FLAGS_HAS_INPUT_TYPE) != 0) {
        mInputType = in.readInt();
    }
    if ((flags&FLAGS_HAS_URL) != 0) {
        mWebScheme = in.readString();
        mWebDomain = in.readString();
    }
    if ((flags&FLAGS_HAS_LOCALE_LIST) != 0) {
        mLocaleList = in.readParcelable(null);
    }
    if ((flags&FLAGS_HAS_EXTRAS) != 0) {
        mExtras = in.readBundle();
    }
    if ((flags&FLAGS_HAS_CHILDREN) != 0) {
        final int NCHILDREN = in.readInt();
        if (DEBUG_PARCEL_TREE || DEBUG_PARCEL_CHILDREN) Log.d(TAG,
                "Preparing to read " + NCHILDREN
                        + " children: @ #" + reader.mNumReadViews
                        + ", level " + nestingLevel);
        mChildren = new ViewNode[NCHILDREN];
        for (int i=0; i<NCHILDREN; i++) {
            mChildren[i] = new ViewNode(reader, nestingLevel + 1);
        }
    }
}
 
Example #4
Source Project: android_9.0.0_r45   Author: lulululbj   File: AssistStructure.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HtmlInfo.Builder newHtmlInfoBuilder(@NonNull String tagName) {
    return new HtmlInfoNodeBuilder(tagName);
}
 
Example #5
Source Project: android_9.0.0_r45   Author: lulululbj   File: AssistStructure.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setHtmlInfo(@NonNull HtmlInfo htmlInfo) {
    mNode.mHtmlInfo = htmlInfo;
}
 
Example #6
Source Project: android_9.0.0_r45   Author: lulululbj   File: AssistStructure.java    License: Apache License 2.0 4 votes vote down vote up
void dump(String prefix, ViewNode node, boolean showSensitive) {
    Log.i(TAG, prefix + "View [" + node.getLeft() + "," + node.getTop()
            + " " + node.getWidth() + "x" + node.getHeight() + "]" + " " + node.getClassName());
    int id = node.getId();
    if (id != 0) {
        StringBuilder sb = new StringBuilder();
        sb.append(prefix); sb.append("  ID: #"); sb.append(Integer.toHexString(id));
        String entry = node.getIdEntry();
        if (entry != null) {
            String type = node.getIdType();
            String pkg = node.getIdPackage();
            sb.append(" "); sb.append(pkg); sb.append(":"); sb.append(type);
            sb.append("/"); sb.append(entry);
        }
        Log.i(TAG, sb.toString());
    }
    int scrollX = node.getScrollX();
    int scrollY = node.getScrollY();
    if (scrollX != 0 || scrollY != 0) {
        Log.i(TAG, prefix + "  Scroll: " + scrollX + "," + scrollY);
    }
    Matrix matrix = node.getTransformation();
    if (matrix != null) {
        Log.i(TAG, prefix + "  Transformation: " + matrix);
    }
    float elevation = node.getElevation();
    if (elevation != 0) {
        Log.i(TAG, prefix + "  Elevation: " + elevation);
    }
    float alpha = node.getAlpha();
    if (alpha != 0) {
        Log.i(TAG, prefix + "  Alpha: " + elevation);
    }
    CharSequence contentDescription = node.getContentDescription();
    if (contentDescription != null) {
        Log.i(TAG, prefix + "  Content description: " + contentDescription);
    }
    CharSequence text = node.getText();
    if (text != null) {
        final String safeText = node.isSanitized() || showSensitive ? text.toString()
                : "REDACTED[" + text.length() + " chars]";
        Log.i(TAG, prefix + "  Text (sel " + node.getTextSelectionStart() + "-"
                + node.getTextSelectionEnd() + "): " + safeText);
        Log.i(TAG, prefix + "  Text size: " + node.getTextSize() + " , style: #"
                + node.getTextStyle());
        Log.i(TAG, prefix + "  Text color fg: #" + Integer.toHexString(node.getTextColor())
                + ", bg: #" + Integer.toHexString(node.getTextBackgroundColor()));
        Log.i(TAG, prefix + "  Input type: " + node.getInputType());
        Log.i(TAG, prefix + "  Resource id: " + node.getTextIdEntry());
    }
    String webDomain = node.getWebDomain();
    if (webDomain != null) {
        Log.i(TAG, prefix + "  Web domain: " + webDomain);
    }
    HtmlInfo htmlInfo = node.getHtmlInfo();
    if (htmlInfo != null) {
        Log.i(TAG, prefix + "  HtmlInfo: tag=" + htmlInfo.getTag()
                + ", attr="+ htmlInfo.getAttributes());
    }

    LocaleList localeList = node.getLocaleList();
    if (localeList != null) {
        Log.i(TAG, prefix + "  LocaleList: " + localeList);
    }
    String hint = node.getHint();
    if (hint != null) {
        Log.i(TAG, prefix + "  Hint: " + hint);
    }
    Bundle extras = node.getExtras();
    if (extras != null) {
        Log.i(TAG, prefix + "  Extras: " + extras);
    }
    if (node.isAssistBlocked()) {
        Log.i(TAG, prefix + "  BLOCKED");
    }
    AutofillId autofillId = node.getAutofillId();
    if (autofillId == null) {
        Log.i(TAG, prefix + " NO autofill ID");
    } else {
        Log.i(TAG, prefix + "Autofill info: id= " + autofillId
                + ", type=" + node.getAutofillType()
                + ", options=" + Arrays.toString(node.getAutofillOptions())
                + ", hints=" + Arrays.toString(node.getAutofillHints())
                + ", value=" + node.getAutofillValue()
                + ", sanitized=" + node.isSanitized()
                + ", importantFor=" + node.getImportantForAutofill());
    }

    final int NCHILDREN = node.getChildCount();
    if (NCHILDREN > 0) {
        Log.i(TAG, prefix + "  Children:");
        String cprefix = prefix + "    ";
        for (int i=0; i<NCHILDREN; i++) {
            ViewNode cnode = node.getChildAt(i);
            dump(cprefix, cnode, showSensitive);
        }
    }
}
 
Example #7
Source Project: android-AutofillFramework   Author: googlearchive   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
private static void dumpNode(StringBuilder builder, String prefix, ViewNode node, int childNumber) {
    builder.append(prefix)
            .append("child #").append(childNumber).append("\n");

    builder.append(prefix)
            .append("autoFillId: ").append(node.getAutofillId())
            .append("\tidEntry: ").append(node.getIdEntry())
            .append("\tid: ").append(node.getId())
            .append("\tclassName: ").append(node.getClassName())
            .append('\n');

    builder.append(prefix)
            .append("focused: ").append(node.isFocused())
            .append("\tvisibility").append(node.getVisibility())
            .append("\tchecked: ").append(node.isChecked())
            .append("\twebDomain: ").append(node.getWebDomain())
            .append("\thint: ").append(node.getHint())
            .append('\n');

    HtmlInfo htmlInfo = node.getHtmlInfo();

    if (htmlInfo != null) {
        builder.append(prefix)
                .append("HTML TAG: ").append(htmlInfo.getTag())
                .append(" attrs: ").append(htmlInfo.getAttributes())
                .append('\n');
    }

    String[] afHints = node.getAutofillHints();
    CharSequence[] options = node.getAutofillOptions();
    builder.append(prefix).append("afType: ").append(getTypeAsString(node.getAutofillType()))
            .append("\tafValue:")
            .append(getAutofillValueAndTypeAsString(node.getAutofillValue()))
            .append("\tafOptions:").append(options == null ? "N/A" : Arrays.toString(options))
            .append("\tafHints: ").append(afHints == null ? "N/A" : Arrays.toString(afHints))
            .append("\tinputType:").append(node.getInputType())
            .append('\n');

    int numberChildren = node.getChildCount();
    builder.append(prefix).append("# children: ").append(numberChildren)
            .append("\ttext: ").append(node.getText())
            .append('\n');

    final String prefix2 = prefix + "  ";
    for (int i = 0; i < numberChildren; i++) {
        dumpNode(builder, prefix2, node.getChildAt(i), i);
    }
    logv(builder.toString());
}
 
Example #8
Source Project: android-AutofillFramework   Author: googlearchive   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
private static void dumpNode(String prefix, ViewNode node) {
    StringBuilder builder = new StringBuilder();
    builder.append(prefix)
            .append("autoFillId: ").append(node.getAutofillId())
            .append("\tidEntry: ").append(node.getIdEntry())
            .append("\tid: ").append(node.getId())
            .append("\tclassName: ").append(node.getClassName())
            .append('\n');

    builder.append(prefix)
            .append("focused: ").append(node.isFocused())
            .append("\tvisibility").append(node.getVisibility())
            .append("\tchecked: ").append(node.isChecked())
            .append("\twebDomain: ").append(node.getWebDomain())
            .append("\thint: ").append(node.getHint())
            .append('\n');

    HtmlInfo htmlInfo = node.getHtmlInfo();

    if (htmlInfo != null) {
        builder.append(prefix)
                .append("HTML TAG: ").append(htmlInfo.getTag())
                .append(" attrs: ").append(htmlInfo.getAttributes())
                .append('\n');
    }

    String[] afHints = node.getAutofillHints();
    CharSequence[] options = node.getAutofillOptions();
    builder.append(prefix).append("afType: ").append(getAutofillTypeAsString(node.getAutofillType()))
            .append("\tafValue:")
            .append(getAutofillValueAndTypeAsString(node.getAutofillValue()))
            .append("\tafOptions:").append(options == null ? "N/A" : Arrays.toString(options))
            .append("\tafHints: ").append(afHints == null ? "N/A" : Arrays.toString(afHints))
            .append("\tinputType:").append(node.getInputType())
            .append('\n');

    int numberChildren = node.getChildCount();
    builder.append(prefix).append("# children: ").append(numberChildren)
            .append("\ttext: ").append(node.getText())
            .append('\n');

    Log.v(TAG, builder.toString());
    final String prefix2 = prefix + "  ";
    for (int i = 0; i < numberChildren; i++) {
        Log.v(TAG, prefix + "child #" + i);
        dumpNode(prefix2, node.getChildAt(i));
    }
}
 
Example #9
Source Project: android_9.0.0_r45   Author: lulululbj   File: ViewStructure.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link HtmlInfo.Builder} for the given HTML tag.
 *
 * @param tagName name of the HTML tag.
 * @return a new builder.
 */
public abstract HtmlInfo.Builder newHtmlInfoBuilder(@NonNull String tagName);
 
Example #10
Source Project: android_9.0.0_r45   Author: lulululbj   File: ViewStructure.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the HTML properties of this node when it represents an HTML element.
 *
 * <p>Should only be set when the node is used for autofill purposes - it will be ignored
 * when used for assist.
 *
 * @param htmlInfo HTML properties.
 */
public abstract void setHtmlInfo(@NonNull HtmlInfo htmlInfo);
 
Example #11
Source Project: android_9.0.0_r45   Author: lulululbj   File: ViewStructure.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Builds the {@link HtmlInfo} object.
 *
 * @return a new {@link HtmlInfo} instance.
 */
public abstract HtmlInfo build();
 
Example #12
Source Project: android_9.0.0_r45   Author: lulululbj   File: AssistStructure.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the HTML properties associated with this view.
 *
 * <p>It's only relevant when the {@link AssistStructure} is used for autofill purposes,
 * not for assist purposes.
 *
 * @return the HTML properties associated with this view, or {@code null} if the
 * structure was created for assist purposes.
 */
@Nullable public HtmlInfo getHtmlInfo() {
    return mHtmlInfo;
}