Example usage for android.view.accessibility AccessibilityNodeInfo isEditable

List of usage examples for android.view.accessibility AccessibilityNodeInfo isEditable

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo isEditable.

Prototype

public boolean isEditable() 

Source Link

Document

Gets if the node is editable.

Usage

From source file:com.google.android.apps.common.testing.accessibility.framework.EditableContentDescInfoCheck.java

@Override
public List<AccessibilityInfoCheckResult> runCheckOnInfo(AccessibilityNodeInfo info, Context context,
        Bundle metadata) {/*www  .  j a  v  a2 s.co m*/
    List<AccessibilityInfoCheckResult> results = new ArrayList<AccessibilityInfoCheckResult>(1);
    AccessibilityNodeInfoCompat compatInfo = new AccessibilityNodeInfoCompat(info);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (info.isEditable()) {
            if (!TextUtils.isEmpty(info.getContentDescription())) {
                results.add(
                        new AccessibilityInfoCheckResult(this.getClass(), AccessibilityCheckResultType.ERROR,
                                "Editable view should not have a contentDescription", info));
            }
        } else {
            results.add(new AccessibilityInfoCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN,
                    "Associated view must be editable", info));
        }
    } else {
        // Earlier API versions don't allow us to filter based on editable state, so we'll fall back
        // to using EditTexts instead.

        // TODO(caseyburkhardt): The missing context below will cause us to fail to resolve classes
        // defined within other packages.
        if (AccessibilityNodeInfoUtils.nodeMatchesAnyClassByType(null, compatInfo, EditText.class)) {
            if (!TextUtils.isEmpty(compatInfo.getContentDescription())) {
                results.add(
                        new AccessibilityInfoCheckResult(this.getClass(), AccessibilityCheckResultType.ERROR,
                                "EditText should not have a contentDescription", info));
            }
        } else {
            results.add(new AccessibilityInfoCheckResult(this.getClass(), AccessibilityCheckResultType.NOT_RUN,
                    "Associated view must be an EditText", info));
        }
    }
    return results;
}

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, AccessibilityNodeInfo fromInfo) {
    // Bookkeeping
    this.id = id;
    this.parentId = (parent != null) ? parent.getId() : null;

    // API 18+ properties
    this.resourceName = AT_18 ? fromInfo.getViewIdResourceName() : null;
    this.editable = AT_18 ? fromInfo.isEditable() : null;

    // API 16+ properties
    this.visibleToUser = AT_16 ? fromInfo.isVisibleToUser() : null;

    // Base properties
    this.className = fromInfo.getClassName();
    this.packageName = fromInfo.getPackageName();
    this.accessibilityClassName = fromInfo.getClassName();
    this.contentDescription = SpannableString.valueOf(fromInfo.getContentDescription());
    this.text = SpannableString.valueOf(fromInfo.getText());
    this.importantForAccessibility = true;
    this.clickable = fromInfo.isClickable();
    this.longClickable = fromInfo.isLongClickable();
    this.focusable = fromInfo.isFocusable();
    this.scrollable = fromInfo.isScrollable();
    this.canScrollForward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0);
    this.canScrollBackward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0);
    this.checkable = fromInfo.isCheckable();
    this.checked = fromInfo.isChecked();
    this.hasTouchDelegate = false; /* Touch delegates are not considered by AccessibilityServices */
    android.graphics.Rect tempRect = new android.graphics.Rect();
    fromInfo.getBoundsInScreen(tempRect);
    this.boundsInScreen = new Rect(tempRect);
    this.nonclippedHeight = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.nonclippedWidth = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.textSize = null;
    this.textColor = null;
    this.backgroundDrawableColor = null;
    this.typefaceStyle = null;
    this.enabled = fromInfo.isEnabled();
}