Java Code Examples for android.view.accessibility.AccessibilityNodeInfo.CollectionInfo

The following are top voted examples for showing how to use android.view.accessibility.AccessibilityNodeInfo.CollectionInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: talkback   File: CollectionStateTest.java   View source code 6 votes vote down vote up
private AccessibilityNodeInfo createList(String name,
        int numItems,
        int headingIndex,
        List<AccessibilityNodeInfo> items) {
    AccessibilityNodeInfo list = AccessibilityNodeInfo.obtain();
    list.setContentDescription(name);
    list.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(numItems, 1, false));

    ShadowAccessibilityNodeInfo shadow = getShadow(list);
    for (int i = 0; i < numItems; ++i) {
        AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
        item.setContentDescription("Item " + i);
        item.setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo.obtain(i, 1, 1, 1,
                i == headingIndex));

        shadow.addChild(item);
        items.add(item);
    }

    return list;
}
 
Example 2
Project: talkback   File: CollectionStateTest.java   View source code 5 votes vote down vote up
private AccessibilityNodeInfo createGrid(String name, int rows, int cols) {
    AccessibilityNodeInfo grid = AccessibilityNodeInfo.obtain();
    grid.setContentDescription(name);
    grid.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(rows, cols, false));

    return grid;
}
 
Example 3
Project: boohee_v5.6   File: AccessibilityNodeInfoCompatApi21.java   View source code 4 votes vote down vote up
public static Object obtainCollectionInfo(int rowCount, int columnCount, boolean hierarchical, int selectionMode) {
    return CollectionInfo.obtain(rowCount, columnCount, hierarchical, selectionMode);
}
 
Example 4
Project: FMTech   File: AccessibilityNodeInfoCompat.java   View source code 4 votes vote down vote up
public final Object obtainCollectionInfo(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3)
{
  return AccessibilityNodeInfo.CollectionInfo.obtain(paramInt1, paramInt2, false, 0);
}
 
Example 5
Project: FMTech   File: AccessibilityNodeInfoCompat.java   View source code 4 votes vote down vote up
public Object obtainCollectionInfo(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3)
{
  return AccessibilityNodeInfo.CollectionInfo.obtain(paramInt1, paramInt2, false);
}
 
Example 6
Project: FMTech   File: AccessibilityNodeInfoCompat.java   View source code 4 votes vote down vote up
public final void setCollectionInfo(Object paramObject1, Object paramObject2)
{
  ((AccessibilityNodeInfo)paramObject1).setCollectionInfo((AccessibilityNodeInfo.CollectionInfo)paramObject2);
}
 
Example 7
Project: talkback   File: ShadowAccessibilityNodeInfo.java   View source code 4 votes vote down vote up
@Implementation
public CollectionInfo getCollectionInfo() {
    return collectionInfo;
}
 
Example 8
Project: talkback   File: ShadowAccessibilityNodeInfo.java   View source code 4 votes vote down vote up
@Implementation
public void setCollectionInfo(CollectionInfo collectionInfo) {
    this.collectionInfo = collectionInfo;
}
 
Example 9
Project: talkback   File: CollectionStateTest.java   View source code 4 votes vote down vote up
@Test
public void testNested_mostlyHierarchical() {
    AccessibilityNodeInfo root = AccessibilityNodeInfo.obtain();
    root.setClassName(WEBVIEW_CLASS_NAME);

    AccessibilityNodeInfo list1 = AccessibilityNodeInfo.obtain();
    list1.setCollectionInfo(CollectionInfo.obtain(2, 1, true /* hierarchical */));
    getShadow(root).addChild(list1);

    AccessibilityNodeInfo list2 = AccessibilityNodeInfo.obtain();
    list2.setCollectionInfo(CollectionInfo.obtain(2, 1, true  /* hierarchical */));
    list2.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list1).addChild(list2);

    AccessibilityNodeInfo list3 = AccessibilityNodeInfo.obtain();
    list3.setCollectionInfo(CollectionInfo.obtain(2, 1, false  /* hierarchical */));
    list3.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list2).addChild(list3);

    AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
    item.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list3).addChild(item);

    try {
        // list2 is inside of list1
        AccessibilityNodeInfoCompat listCompat2 = new AccessibilityNodeInfoCompat(list2);
        mCollectionState.updateCollectionInformation(listCompat2, null);
        assertEquals(0, mCollectionState.getCollectionLevel());

        // list3 is inside of list2
        AccessibilityNodeInfoCompat listCompat3 = new AccessibilityNodeInfoCompat(list3);
        mCollectionState.updateCollectionInformation(listCompat3, null);
        assertEquals(1, mCollectionState.getCollectionLevel());

        // item is inside of list3
        AccessibilityNodeInfoCompat itemCompat = new AccessibilityNodeInfoCompat(item);
        mCollectionState.updateCollectionInformation(itemCompat, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list3 not hierarchical!

        AccessibilityNodeInfoCompat rootCompat = new AccessibilityNodeInfoCompat(root);
        forceInternalRecycle(rootCompat);
    } finally {
        root.recycle();
        list1.recycle();
        list2.recycle();
        list3.recycle();
        item.recycle();
    }
}
 
Example 10
Project: talkback   File: CollectionStateTest.java   View source code 4 votes vote down vote up
@Test
public void testNested_mostlyNonHierarchical() {
    AccessibilityNodeInfo root = AccessibilityNodeInfo.obtain();
    root.setClassName(WEBVIEW_CLASS_NAME);

    AccessibilityNodeInfo list1 = AccessibilityNodeInfo.obtain();
    list1.setCollectionInfo(CollectionInfo.obtain(2, 1, false /* hierarchical */));
    getShadow(root).addChild(list1);

    AccessibilityNodeInfo list2 = AccessibilityNodeInfo.obtain();
    list2.setCollectionInfo(CollectionInfo.obtain(2, 1, false  /* hierarchical */));
    list2.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list1).addChild(list2);

    AccessibilityNodeInfo list3 = AccessibilityNodeInfo.obtain();
    list3.setCollectionInfo(CollectionInfo.obtain(2, 1, true  /* hierarchical */));
    list3.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list2).addChild(list3);

    AccessibilityNodeInfo item = AccessibilityNodeInfo.obtain();
    item.setCollectionItemInfo(CollectionItemInfo.obtain(0, 1, 0, 1, false));
    getShadow(list3).addChild(item);

    try {
        // list2 is inside of list1
        AccessibilityNodeInfoCompat listCompat2 = new AccessibilityNodeInfoCompat(list2);
        mCollectionState.updateCollectionInformation(listCompat2, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list1 not hierarchical!

        // list3 is inside of list2
        AccessibilityNodeInfoCompat listCompat3 = new AccessibilityNodeInfoCompat(list3);
        mCollectionState.updateCollectionInformation(listCompat3, null);
        assertEquals(-1, mCollectionState.getCollectionLevel()); // list2 not hierarchical!

        // item is inside of list3
        AccessibilityNodeInfoCompat itemCompat = new AccessibilityNodeInfoCompat(item);
        mCollectionState.updateCollectionInformation(itemCompat, null);
        assertEquals(0, mCollectionState.getCollectionLevel());

        AccessibilityNodeInfoCompat rootCompat = new AccessibilityNodeInfoCompat(root);
        forceInternalRecycle(rootCompat);
    } finally {
        root.recycle();
        list1.recycle();
        list2.recycle();
        list3.recycle();
        item.recycle();
    }
}