Example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isSelected

List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isSelected

Introduction

In this page you can find the example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Gets whether this node is selected.

Usage

From source file:com.android.talkback.speechrules.NodeSpeechRuleProcessor.java

/**
 * Appends meta-data about node's disabled state (if actionable).
 * <p>/*from ww w.j  a  v  a 2s  . com*/
 * This should only be applied to the root node of a tree.
 */
private void appendRootMetadataToBuilder(AccessibilityNodeInfoCompat node,
        SpannableStringBuilder descriptionBuilder) {
    // Append state for actionable but disabled nodes.
    if (AccessibilityNodeInfoUtils.isActionableForAccessibility(node) && !node.isEnabled()) {
        StringBuilderUtils.appendWithSeparator(descriptionBuilder, mContext.getString(R.string.value_disabled));
    }

    // Append the control's selected state.
    if (node.isSelected()) {
        StringBuilderUtils.appendWithSeparator(descriptionBuilder, mContext.getString(R.string.value_selected));
    }
}

From source file:com.googlecode.eyesfree.utils.TreeDebug.java

/**
 * Gets a description of the properties of a node.
 *//*from   ww  w  .j  av  a 2  s .  c o m*/
public static CharSequence nodeDebugDescription(AccessibilityNodeInfoCompat node) {
    StringBuilder sb = new StringBuilder();
    sb.append(node.getWindowId());

    if (node.getClassName() != null) {
        appendSimpleName(sb, node.getClassName());
    } else {
        sb.append("??");
    }

    if (!node.isVisibleToUser()) {
        sb.append(":invisible");
    }

    if (node.getText() != null) {
        sb.append(":");
        sb.append(node.getText().toString().trim());
    }

    if (node.getContentDescription() != null) {
        sb.append(":");
        sb.append(node.getContentDescription().toString().trim());
    }

    int actions = node.getActions();
    if (actions != 0) {
        sb.append(":");
        if ((actions & AccessibilityNodeInfoCompat.ACTION_FOCUS) != 0) {
            sb.append("F");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("A");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("a");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) != 0) {
            sb.append("-");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) != 0) {
            sb.append("+");
        }
    }

    if (node.isCheckable()) {
        sb.append(":");
        if (node.isChecked()) {
            sb.append("(X)");
        } else {
            sb.append("( )");
        }
    }

    if (node.isFocusable()) {
        sb.append(":focusable");
    }

    if (node.isFocused()) {
        sb.append(":focused");
    }

    if (node.isSelected()) {
        sb.append(":selected");
    }

    if (node.isClickable()) {
        sb.append(":clickable");
    }

    if (node.isLongClickable()) {
        sb.append(":longClickable");
    }

    if (node.isAccessibilityFocused()) {
        sb.append(":accessibilityFocused");
    }

    if (!node.isEnabled()) {
        sb.append(":disabled");
    }

    return sb.toString();
}

From source file:com.android.utils.TreeDebug.java

/**
 * Gets a description of the properties of a node.
 *//*  ww  w .  java2s  . c  o  m*/
private static CharSequence nodeDebugDescription(AccessibilityNodeInfoCompat node) {
    StringBuilder sb = new StringBuilder();
    sb.append(node.getWindowId());

    if (node.getClassName() != null) {
        appendSimpleName(sb, node.getClassName());
    } else {
        sb.append("??");
    }

    if (!node.isVisibleToUser()) {
        sb.append(":invisible");
    }

    Rect rect = new Rect();
    node.getBoundsInScreen(rect);
    sb.append(":");
    sb.append("(").append(rect.left).append(", ").append(rect.top).append(" - ").append(rect.right).append(", ")
            .append(rect.bottom).append(")");

    if (node.getText() != null) {
        sb.append(":");
        sb.append(node.getText().toString().trim());
    }

    if (node.getContentDescription() != null) {
        sb.append(":");
        sb.append(node.getContentDescription().toString().trim());
    }

    int actions = node.getActions();
    if (actions != 0) {
        sb.append(":");
        if ((actions & AccessibilityNodeInfoCompat.ACTION_FOCUS) != 0) {
            sb.append("F");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("A");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("a");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) != 0) {
            sb.append("-");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_CLICK) != 0) {
            sb.append("C");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_LONG_CLICK) != 0) {
            sb.append("L");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) != 0) {
            sb.append("+");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_EXPAND) != 0) {
            sb.append("e");
        }
        if ((actions & AccessibilityNodeInfoCompat.ACTION_COLLAPSE) != 0) {
            sb.append("c");
        }
    }

    if (node.isCheckable()) {
        sb.append(":");
        if (node.isChecked()) {
            sb.append("(X)");
        } else {
            sb.append("( )");
        }
    }

    if (node.isFocusable()) {
        sb.append(":focusable");
    }

    if (node.isFocused()) {
        sb.append(":focused");
    }

    if (node.isSelected()) {
        sb.append(":selected");
    }

    if (node.isClickable()) {
        sb.append(":clickable");
    }

    if (node.isLongClickable()) {
        sb.append(":longClickable");
    }

    if (node.isAccessibilityFocused()) {
        sb.append(":accessibilityFocused");
    }

    if (!node.isEnabled()) {
        sb.append(":disabled");
    }

    if (node.getCollectionInfo() != null) {
        sb.append(":collection");
        sb.append("#R");
        sb.append(node.getCollectionInfo().getRowCount());
        sb.append("C");
        sb.append(node.getCollectionInfo().getColumnCount());
    }

    if (node.getCollectionItemInfo() != null) {
        if (node.getCollectionItemInfo().isHeading()) {
            sb.append(":heading");
        } else {
            sb.append(":item");
        }

        sb.append("#r");
        sb.append(node.getCollectionItemInfo().getRowIndex());
        sb.append("c");
        sb.append(node.getCollectionItemInfo().getColumnIndex());
    }

    return sb.toString();
}