List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat setFocusable
public void setFocusable(boolean focusable)
From source file:com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate.java
@Override protected void onPopulateNodeForVirtualView(int id, AccessibilityNodeInfoCompat node) { if (id == INVALID_ID) { throw new IllegalArgumentException("Invalid virtual view id"); }// ww w. ja va 2s. co m node.setContentDescription(getLocationDescriptionForIconDrop(id)); node.setBoundsInParent(getItemBounds(id)); node.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK); node.setClickable(true); node.setFocusable(true); }
From source file:com.facebook.litho.widget.TextSpec.java
@OnPopulateExtraAccessibilityNode static void onPopulateExtraAccessibilityNode(AccessibilityNodeInfoCompat node, int extraNodeIndex, int componentBoundsLeft, int componentBoundsTop, @Prop(resType = STRING) CharSequence text, @FromBoundsDefined Layout textLayout, @FromBoundsDefined ClickableSpan[] clickableSpans) { final Spanned spanned = (Spanned) text; final ClickableSpan span = clickableSpans[extraNodeIndex]; final int start = spanned.getSpanStart(span); final int end = spanned.getSpanEnd(span); final int startLine = textLayout.getLineForOffset(start); final int endLine = textLayout.getLineForOffset(end); // The bounds for multi-line strings should *only* include the first line. This is because // Talkback triggers its click at the center point of these bounds, and if that center point // is outside the spannable, it will click on something else. There is no harm in not outlining // the wrapped part of the string, as the text for the whole string will be read regardless of // the bounding box. final int selectionPathEnd = startLine == endLine ? end : textLayout.getLineVisibleEnd(startLine); textLayout.getSelectionPath(start, selectionPathEnd, sTempPath); sTempPath.computeBounds(sTempRectF, /* unused */true); sTempRect.set(componentBoundsLeft + (int) sTempRectF.left, componentBoundsTop + (int) sTempRectF.top, componentBoundsLeft + (int) sTempRectF.right, componentBoundsTop + (int) sTempRectF.bottom); if (sTempRect.isEmpty()) { // Text is not actually visible. // Override bounds so it doesn't crash ExploreByTouchHelper.java sTempRect.set(0, 0, 1, 1);/* ww w . ja v a2 s. c o m*/ node.setBoundsInParent(sTempRect); node.setContentDescription(""); // make node non-focusable return; } node.setBoundsInParent(sTempRect); node.setClickable(true); node.setFocusable(true); node.setEnabled(true); node.setVisibleToUser(true); if (span instanceof AccessibleClickableSpan) { node.setText(((AccessibleClickableSpan) span).getAccessibilityDescription()); } else { node.setText(spanned.subSequence(start, end)); } }