Java Code Examples for android.view.View#getParentForAccessibility()

The following examples show how to use android.view.View#getParentForAccessibility() . 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 File: ViewAccessibilityUtils.java    From Accessibility-Test-Framework-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Determines if the supplied {@link View} has an ancestor which meets the criteria for gaining
 * accessibility focus.
 *
 * <p>NOTE: This method only evaluates ancestors which may be considered important for
 * accessibility and explicitly does not evaluate the supplied {@code view}.
 *
 * @param view The {@link View} to evaluate
 * @return {@code true} if an ancestor of {@code view} may gain accessibility focus, {@code false}
 *     otherwise
 */
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) // Calls View#getParentForAccessibility
private static boolean hasFocusableAncestor(View view) {
  if (view == null) {
    return false;
  }

  ViewParent parent = view.getParentForAccessibility();
  if (!(parent instanceof View)) {
    return false;
  }

  if (isAccessibilityFocusable((View) parent)) {
    return true;
  }

  return hasFocusableAncestor((View) parent);
}
 
Example 2
Source File: ViewAccessibilityUtils.java    From Accessibility-Test-Framework-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Determines if the supplied {@link View} is a top-level item within a scrollable container.
 *
 * @param view The {@link View} to evaluate
 * @return {@code true} if {@code view} is a top-level view within a scrollable container, {@code
 *     false} otherwise
 */
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) // Calls View#getParentForAccessibility
private static boolean isChildOfScrollableContainer(View view) {
  if (view == null) {
    return false;
  }

  ViewParent viewParent = view.getParentForAccessibility();
  if ((viewParent == null) || !(viewParent instanceof View)) {
    return false;
  }

  View parent = (View) viewParent;
  if (parent.isScrollContainer()) {
    return true;
  }

  // Specifically check for parents that are AdapterView, ScrollView, or HorizontalScrollView, but
  // exclude Spinners, which are a special case of AdapterView.
  return (((parent instanceof AdapterView)
          || (parent instanceof ScrollView)
          || (parent instanceof HorizontalScrollView))
      && !(parent instanceof Spinner));
}
 
Example 3
Source File: DrawerLayout.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
	if (CAN_HIDE_DESCENDANTS) {
		super.onInitializeAccessibilityNodeInfo(host, info);
	} else {
		// Obtain a node for the host, then manually generate the list
		// of children to only include non-obscured views.
		final AccessibilityNodeInfo superNode = AccessibilityNodeInfo.obtain(info);
		super.onInitializeAccessibilityNodeInfo(host, superNode);

		info.setSource(host);
		final ViewParent parent = host.getParentForAccessibility();
		if (parent instanceof View) {
			info.setParent((View) parent);
		}
		copyNodeInfoNoChildren(info, superNode);
		superNode.recycle();

		addChildrenForAccessibility(info, (ViewGroup) host);
	}

	info.setClassName(DrawerLayout.class.getName());

	// This view reports itself as focusable so that it can intercept
	// the back button, but we should prevent this view from reporting
	// itself as focusable to accessibility services.
	info.setFocusable(false);
	info.setFocused(false);
	if (C.API_LOLLIPOP) {
		info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_FOCUS);
		info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLEAR_FOCUS);
	}
}
 
Example 4
Source File: ViewCompatJB.java    From letv with Apache License 2.0 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 5
Source File: am.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static ViewParent e(View view)
{
    return view.getParentForAccessibility();
}
 
Example 6
Source File: ViewCompatJB.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 7
Source File: ViewCompatJB.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 8
Source File: ViewCompatJB.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 9
Source File: ViewCompatJB.java    From guideshow with MIT License 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}