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

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

Introduction

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

Prototype

public boolean isClickable() 

Source Link

Document

Gets whether this node is clickable.

Usage

From source file:Main.java

/**
 * Returns whether a node is clickable. That is, the node supports at least one of the
 * following://from w  w  w .j ava 2s  .  c  o m
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#isClickable()}</li>
 * <li>{@link AccessibilityNodeInfoCompat#ACTION_CLICK}</li>
 * </ul>
 *
 * @param node The node to examine.
 * @return {@code true} if node is clickable.
 */
public static boolean isClickable(AccessibilityNodeInfoCompat node) {
    if (node == null) {
        return false;
    }

    if (node.isClickable()) {
        return true;
    }

    return supportsAnyAction(node, AccessibilityNodeInfoCompat.ACTION_CLICK);
}

From source file:Main.java

/**
 * Returns whether a node is actionable. That is, the node supports one of
 * {@link AccessibilityNodeInfoCompat#isClickable()},
 * {@link AccessibilityNodeInfoCompat#isFocusable()}, or
 * {@link AccessibilityNodeInfoCompat#isLongClickable()}.
 *
 * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
 * @return {@code true} if node is actionable.
 *//*from  www. j  a v  a2 s.  c om*/
public static boolean isActionableForAccessibility(@Nullable AccessibilityNodeInfoCompat node) {
    if (node == null) {
        return false;
    }

    if (node.isClickable() || node.isLongClickable() || node.isFocusable()) {
        return true;
    }

    List actionList = node.getActionList();
    return actionList.contains(AccessibilityNodeInfoCompat.ACTION_CLICK)
            || actionList.contains(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK)
            || actionList.contains(AccessibilityNodeInfoCompat.ACTION_FOCUS);
}

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

/**
 * Returns whether a node is clickable. That is, the node supports at least one of the
 * following:/*  w  w  w. j av  a 2s . c  o  m*/
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#isClickable()}</li>
 * <li>{@link AccessibilityNodeInfoCompat#ACTION_CLICK}</li>
 * </ul>
 *
 * @param node The node to examine.
 * @return {@code true} if node is clickable.
 */
public static boolean isClickable(AccessibilityNodeInfoCompat node) {
    return node != null
            && (node.isClickable() || supportsAnyAction(node, AccessibilityNodeInfoCompat.ACTION_CLICK));
}

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

/**
 * Gets a description of the properties of a node.
 *//*  ww w . jav a2  s  . c om*/
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.
 *///from  w  ww  .j a  v  a  2 s. 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();
}