Java Code Examples for android.support.v4.view.ViewCompat#getParentForAccessibility()

The following examples show how to use android.support.v4.view.ViewCompat#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: DrawerLayout.java    From letv with Apache License 2.0 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    if (DrawerLayout.CAN_HIDE_DESCENDANTS) {
        super.onInitializeAccessibilityNodeInfo(host, info);
    } else {
        AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
        super.onInitializeAccessibilityNodeInfo(host, superNode);
        info.setSource(host);
        ViewParent parent = ViewCompat.getParentForAccessibility(host);
        if (parent instanceof View) {
            info.setParent((View) parent);
        }
        copyNodeInfoNoChildren(info, superNode);
        superNode.recycle();
        addChildrenForAccessibility(info, (ViewGroup) host);
    }
    info.setClassName(DrawerLayout.class.getName());
    info.setFocusable(false);
    info.setFocused(false);
    info.removeAction(AccessibilityActionCompat.ACTION_FOCUS);
    info.removeAction(AccessibilityActionCompat.ACTION_CLEAR_FOCUS);
}
 
Example 2
Source File: DrawerLayout.java    From android-recipes-app with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

    info.setClassName(DrawerLayout.class.getName());
    info.setSource(host);
    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    copyNodeInfoNoChildren(info, superNode);

    superNode.recycle();

    addChildrenForAccessibility(info, (ViewGroup) host);
}
 
Example 3
Source File: KlyphDrawerLayout.java    From Klyph with MIT License 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

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

    superNode.recycle();

    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child)) {
            info.addChild(child);
        }
    }
}
 
Example 4
Source File: DrawerLayout.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

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

    superNode.recycle();

    addChildrenForAccessibility(info, (ViewGroup) host);
}
 
Example 5
Source File: f.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilitynodeinfocompat)
{
    AccessibilityNodeInfoCompat accessibilitynodeinfocompat1 = AccessibilityNodeInfoCompat.obtain(accessibilitynodeinfocompat);
    super.onInitializeAccessibilityNodeInfo(view, accessibilitynodeinfocompat1);
    accessibilitynodeinfocompat.setSource(view);
    android.view.ViewParent viewparent = ViewCompat.getParentForAccessibility(view);
    if (viewparent instanceof View)
    {
        accessibilitynodeinfocompat.setParent((View)viewparent);
    }
    a(accessibilitynodeinfocompat, accessibilitynodeinfocompat1);
    accessibilitynodeinfocompat1.recycle();
    int i = b.getChildCount();
    for (int j = 0; j < i; j++)
    {
        View view1 = b.getChildAt(j);
        if (!a(view1))
        {
            accessibilitynodeinfocompat.addChild(view1);
        }
    }

}
 
Example 6
Source File: H.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilitynodeinfocompat)
{
    AccessibilityNodeInfoCompat accessibilitynodeinfocompat1 = AccessibilityNodeInfoCompat.obtain(accessibilitynodeinfocompat);
    super.onInitializeAccessibilityNodeInfo(view, accessibilitynodeinfocompat1);
    a(accessibilitynodeinfocompat, accessibilitynodeinfocompat1);
    accessibilitynodeinfocompat1.recycle();
    accessibilitynodeinfocompat.setClassName(android/support/v4/widget/SlidingPaneLayout.getName());
    accessibilitynodeinfocompat.setSource(view);
    android.view.ViewParent viewparent = ViewCompat.getParentForAccessibility(view);
    if (viewparent instanceof View)
    {
        accessibilitynodeinfocompat.setParent((View)viewparent);
    }
    int i = b.getChildCount();
    for (int j = 0; j < i; j++)
    {
        View view1 = b.getChildAt(j);
        if (!a(view1) && view1.getVisibility() == 0)
        {
            ViewCompat.setImportantForAccessibility(view1, 1);
            accessibilitynodeinfocompat.addChild(view1);
        }
    }

}
 
Example 7
Source File: SlidingPaneLayout.java    From letv with Apache License 2.0 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();
    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);
    ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    int childCount = SlidingPaneLayout.this.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = SlidingPaneLayout.this.getChildAt(i);
        if (!filter(child) && child.getVisibility() == 0) {
            ViewCompat.setImportantForAccessibility(child, 1);
            info.addChild(child);
        }
    }
}
 
Example 8
Source File: SlidingPaneLayout.java    From guideshow with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 9
Source File: AccessibilityUtil.java    From stetho with MIT License 5 votes vote down vote up
/**
 * Determines if any of the provided {@link View}'s and {@link AccessibilityNodeInfoCompat}'s
 * ancestors can receive accessibility focus
 *
 * @param view The {@link View} to evaluate
 * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
 * @return {@code true} if an ancestor of may receive accessibility focus
 */
public static boolean hasFocusableAncestor(
    @Nullable AccessibilityNodeInfoCompat node,
    @Nullable View view) {
  if (node == null || view == null) {
    return false;
  }

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

  AccessibilityNodeInfoCompat parentNode = AccessibilityNodeInfoCompat.obtain();
  try {
    ViewCompat.onInitializeAccessibilityNodeInfo((View) parentView, parentNode);
    if (parentNode == null) {
      return false;
    }

    if (isAccessibilityFocusable(parentNode, (View) parentView)) {
      return true;
    }

    if (hasFocusableAncestor(parentNode, (View) parentView)) {
      return true;
    }
  } finally {
    parentNode.recycle();
  }
  return false;
}
 
Example 10
Source File: SlidingPaneLayout.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == View.VISIBLE) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 11
Source File: TranslucentDrawerLayout.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat 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 AccessibilityNodeInfoCompat superNode =
                AccessibilityNodeInfoCompat.obtain(info);
        super.onInitializeAccessibilityNodeInfo(host, superNode);

        info.setSource(host);
        final ViewParent parent = ViewCompat.getParentForAccessibility(host);
        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);
    info.removeAction(AccessibilityActionCompat.ACTION_FOCUS);
    info.removeAction(AccessibilityActionCompat.ACTION_CLEAR_FOCUS);
}
 
Example 12
Source File: SwipeBackLayout.java    From AndroidProjects with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SwipeBackLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 13
Source File: SlidingPaneLayout.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 14
Source File: DebugDrawerLayout.java    From u2020 with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat 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 AccessibilityNodeInfoCompat superNode =
        AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

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

    addChildrenForAccessibility(info, (ViewGroup) host);
  }

  info.setClassName(DebugDrawerLayout.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);
}
 
Example 15
Source File: SlidingPaneLayout.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 16
Source File: SlidingLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 17
Source File: SlidingPaneLayout.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 18
Source File: SlideFrameLayout.java    From AccountBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlideFrameLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 19
Source File: SlideLayout.java    From SlideActivity with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlideLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 20
Source File: SlidingUpPaneLayout.java    From SlidingUpPaneLayout with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(SlidingUpPaneLayout.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}