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

The following examples show how to use android.view.View#getParentForAccessibility() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * 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
/**
 * 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 Project: Dashchan   File: DrawerLayout.java    License: 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 Project: letv   File: ViewCompatJB.java    License: Apache License 2.0 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 5
Source Project: MiBandDecompiled   File: am.java    License: Apache License 2.0 4 votes vote down vote up
public static ViewParent e(View view)
{
    return view.getParentForAccessibility();
}
 
Example 6
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 7
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 8
Source Project: V.FlyoutTest   File: ViewCompatJB.java    License: MIT License 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}
 
Example 9
Source Project: guideshow   File: ViewCompatJB.java    License: MIT License 4 votes vote down vote up
public static ViewParent getParentForAccessibility(View view) {
    return view.getParentForAccessibility();
}