Java Code Examples for android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#addChild()

The following examples show how to use android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#addChild() . 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: 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 2
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 3
Source File: ExploreByTouchHelper.java    From brailleback with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * parent view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent view.
 */
private AccessibilityNodeInfoCompat getNodeForRoot() {
    // The root node is identical to the parent node, except that it is a
    // child of the parent view and is populated with virtual descendants.
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(mHost);
    ViewCompat.onInitializeAccessibilityNodeInfo(mHost, node);

    // Add the virtual descendants.
    final LinkedList<Integer> virtualViewIds = new LinkedList<Integer>();
    getVisibleVirtualViewIds(virtualViewIds);

    for (Integer virtualViewId : virtualViewIds) {
        node.addChild(mHost, virtualViewId);
    }

    // Set up the node as a child of the parent.
    node.setParent(mHost);
    node.setSource(mHost, ROOT_ID);

    return node;
}
 
Example 4
Source File: DrawerLayout.java    From CodenameOne with GNU General Public License v2.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.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 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: DebugDrawerLayout.java    From u2020 with Apache License 2.0 5 votes vote down vote up
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat info, ViewGroup v) {
  final int childCount = v.getChildCount();
  for (int i = 0; i < childCount; i++) {
    final View child = v.getChildAt(i);
    if (includeChildForAccessibility(child)) {
      info.addChild(child);
    }
  }
}
 
Example 7
Source File: ExploreByTouchHelper.java    From letv with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfoCompat createNodeForHost() {
    AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(this.mView);
    ViewCompat.onInitializeAccessibilityNodeInfo(this.mView, node);
    onPopulateNodeForHost(node);
    LinkedList<Integer> virtualViewIds = new LinkedList();
    getVisibleVirtualViews(virtualViewIds);
    Iterator i$ = virtualViewIds.iterator();
    while (i$.hasNext()) {
        node.addChild(this.mView, ((Integer) i$.next()).intValue());
    }
    return node;
}
 
Example 8
Source File: DrawerLayout.java    From guideshow with MIT License 5 votes vote down vote up
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat info, ViewGroup v) {
    final int childCount = v.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = v.getChildAt(i);
        if (filter(child)) {
            continue;
        }

        // Adding children that are marked as not important for
        // accessibility will break the hierarchy, so we need to check
        // that value and re-parent views if necessary.
        final int importance = ViewCompat.getImportantForAccessibility(child);
        switch (importance) {
            case ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS:
                // Always skip NO_HIDE views and their descendants.
                break;
            case ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO:
                // Re-parent children of NO view groups, skip NO views.
                if (child instanceof ViewGroup) {
                    addChildrenForAccessibility(info, (ViewGroup) child);
                }
                break;
            case ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO:
                // Force AUTO views to YES and add them.
                ViewCompat.setImportantForAccessibility(
                        child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            case ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES:
                info.addChild(child);
                break;
        }
    }
}
 
Example 9
Source File: DrawerLayout.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat info, ViewGroup v) {
    final int childCount = v.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = v.getChildAt(i);
        if (includeChildForAccessibility(child)) {
            info.addChild(child);
        }
    }
}
 
Example 10
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 11
Source File: ExploreByTouchHelper.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * host view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent node.
 */
private AccessibilityNodeInfoCompat createNodeForHost() {
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(mView);
    ViewCompat.onInitializeAccessibilityNodeInfo(mView, node);

    // Add the virtual descendants.
    final LinkedList<Integer> virtualViewIds = new LinkedList<Integer>();
    getVisibleVirtualViews(virtualViewIds);

    for (Integer childVirtualViewId : virtualViewIds) {
        node.addChild(mView, childVirtualViewId);
    }

    return node;
}
 
Example 12
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 13
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 14
Source File: TouchExplorationHelper.java    From DateTimepicker with Apache License 2.0 5 votes vote down vote up
private AccessibilityNodeInfoCompat getNodeForParent() {
    final AccessibilityNodeInfoCompat info = AccessibilityNodeInfoCompat.obtain(mParentView);
    ViewCompat.onInitializeAccessibilityNodeInfo(mParentView, info);

    final LinkedList<T> items = new LinkedList<T>();
    getVisibleItems(items);

    for (T item : items) {
        final int virtualDescendantId = getIdForItem(item);
        info.addChild(mParentView, virtualDescendantId);
    }

    return info;
}
 
Example 15
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 16
Source File: DebugDrawerLayout.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat info, ViewGroup v) {
	final int childCount = v.getChildCount();
	for (int i = 0; i < childCount; i++) {
		final View child = v.getChildAt(i);
		if (includeChildForAccessibility(child)) {
			info.addChild(child);
		}
	}
}
 
Example 17
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 18
Source File: ExploreByTouchHelper.java    From brailleback with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * parent view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent view.
 */
private AccessibilityNodeInfoCompat getNodeForHost() {
    // Since we don't want the parent to be focusable, but we can't remove
    // actions from a node, copy over the necessary fields.
    final AccessibilityNodeInfoCompat result = AccessibilityNodeInfoCompat.obtain(mHost);
    final AccessibilityNodeInfoCompat source = AccessibilityNodeInfoCompat.obtain(mHost);
    ViewCompat.onInitializeAccessibilityNodeInfo(mHost, source);

    // Copy over parent and screen bounds.
    source.getBoundsInParent(mTempParentRect);
    source.getBoundsInScreen(mTempScreenRect);
    result.setBoundsInParent(mTempParentRect);
    result.setBoundsInScreen(mTempScreenRect);

    // Set up the parent view, if applicable.
    final ViewParent parent = ViewCompat.getParentForAccessibility(mHost);
    if (parent instanceof View) {
        result.setParent((View) parent);
    }

    // Populate the minimum required fields.
    result.setVisibleToUser(source.isVisibleToUser());
    result.setPackageName(source.getPackageName());
    result.setClassName(source.getClassName());

    // Add the fake root node.
    result.addChild(mHost, ROOT_ID);

    return result;
}
 
Example 19
Source File: ExploreByTouchHelper.java    From guideshow with MIT License 5 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * host view populated with its virtual descendants.
 *
 * @return An {@link AccessibilityNodeInfoCompat} for the parent node.
 */
private AccessibilityNodeInfoCompat createNodeForHost() {
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain(mView);
    ViewCompat.onInitializeAccessibilityNodeInfo(mView, node);

    // Add the virtual descendants.
    final LinkedList<Integer> virtualViewIds = new LinkedList<Integer>();
    getVisibleVirtualViews(virtualViewIds);

    for (Integer childVirtualViewId : virtualViewIds) {
        node.addChild(mView, childVirtualViewId);
    }

    return node;
}
 
Example 20
Source File: DrawerLayout.java    From letv with Apache License 2.0 5 votes vote down vote up
private void addChildrenForAccessibility(AccessibilityNodeInfoCompat info, ViewGroup v) {
    int childCount = v.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = v.getChildAt(i);
        if (DrawerLayout.includeChildForAccessibility(child)) {
            info.addChild(child);
        }
    }
}