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

The following examples show how to use android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#setClassName() . 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: OrientedViewPager.java    From FlippableStackView with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (mOrientation == Orientation.VERTICAL) {
        if (internalCanScrollVertically(1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
        }
        if (internalCanScrollVertically(-1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
        }
    } else {
        if (canScrollHorizontally(1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
        }
        if (canScrollHorizontally(-1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
        }
    }
}
 
Example 2
Source File: DrawerLayout.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This should really be in AccessibilityNodeInfoCompat, but there unfortunately
 * seem to be a few elements that are not easily cloneable using the underlying API.
 * Leave it private here as it's not general-purpose useful.
 */
private void copyNodeInfoNoChildren(AccessibilityNodeInfoCompat dest,
        AccessibilityNodeInfoCompat src) {
    final Rect rect = mTmpRect;

    src.getBoundsInParent(rect);
    dest.setBoundsInParent(rect);

    src.getBoundsInScreen(rect);
    dest.setBoundsInScreen(rect);

    dest.setVisibleToUser(src.isVisibleToUser());
    dest.setPackageName(src.getPackageName());
    dest.setClassName(src.getClassName());
    dest.setContentDescription(src.getContentDescription());

    dest.setEnabled(src.isEnabled());
    dest.setClickable(src.isClickable());
    dest.setFocusable(src.isFocusable());
    dest.setFocused(src.isFocused());
    dest.setAccessibilityFocused(src.isAccessibilityFocused());
    dest.setSelected(src.isSelected());
    dest.setLongClickable(src.isLongClickable());

    dest.addAction(src.getActions());
}
 
Example 3
Source File: DirectionalViewpager.java    From BookReader with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(DirectionalViewpager.class.getName());
    info.setScrollable(canScroll());
    if (isHorizontal()) {
        if (canScrollHorizontally(1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
        }
        if (canScrollHorizontally(-1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
        }
    } else {
        if (internalCanScrollVertically(1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
        }
        if (internalCanScrollVertically(-1)) {
            info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
        }
    }
}
 
Example 4
Source File: DrawerLayout.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
/**
 * This should really be in AccessibilityNodeInfoCompat, but there unfortunately
 * seem to be a few elements that are not easily cloneable using the underlying API.
 * Leave it private here as it's not general-purpose useful.
 */
private void copyNodeInfoNoChildren(AccessibilityNodeInfoCompat dest,
        AccessibilityNodeInfoCompat src) {
    final Rect rect = mTmpRect;

    src.getBoundsInParent(rect);
    dest.setBoundsInParent(rect);

    src.getBoundsInScreen(rect);
    dest.setBoundsInScreen(rect);

    dest.setVisibleToUser(src.isVisibleToUser());
    dest.setPackageName(src.getPackageName());
    dest.setClassName(src.getClassName());
    dest.setContentDescription(src.getContentDescription());

    dest.setEnabled(src.isEnabled());
    dest.setClickable(src.isClickable());
    dest.setFocusable(src.isFocusable());
    dest.setFocused(src.isFocused());
    dest.setAccessibilityFocused(src.isAccessibilityFocused());
    dest.setSelected(src.isSelected());
    dest.setLongClickable(src.isLongClickable());

    dest.addAction(src.getActions());
}
 
Example 5
Source File: DebugDrawerLayout.java    From u2020 with Apache License 2.0 6 votes vote down vote up
/**
 * This should really be in AccessibilityNodeInfoCompat, but there unfortunately
 * seem to be a few elements that are not easily cloneable using the underlying API.
 * Leave it private here as it's not general-purpose useful.
 */
private void copyNodeInfoNoChildren(AccessibilityNodeInfoCompat dest,
    AccessibilityNodeInfoCompat src) {
  final Rect rect = mTmpRect;

  src.getBoundsInParent(rect);
  dest.setBoundsInParent(rect);

  src.getBoundsInScreen(rect);
  dest.setBoundsInScreen(rect);

  dest.setVisibleToUser(src.isVisibleToUser());
  dest.setPackageName(src.getPackageName());
  dest.setClassName(src.getClassName());
  dest.setContentDescription(src.getContentDescription());

  dest.setEnabled(src.isEnabled());
  dest.setClickable(src.isClickable());
  dest.setFocusable(src.isFocusable());
  dest.setFocused(src.isFocused());
  dest.setAccessibilityFocused(src.isAccessibilityFocused());
  dest.setSelected(src.isSelected());
  dest.setLongClickable(src.isLongClickable());

  dest.addAction(src.getActions());
}
 
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: VerticalViewPager.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(VerticalViewPager.class.getName());
    info.setScrollable(canScroll());
    if (canScrollVertically1(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollVertically1(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 8
Source File: RecyclerViewAccessibilityDelegate.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(RecyclerView.class.getName());
    if (!shouldIgnore() && mRecyclerView.getLayoutManager() != null) {
        mRecyclerView.getLayoutManager().onInitializeAccessibilityNodeInfo(info);
    }
}
 
Example 9
Source File: VerticalViewPager.java    From VerticalViewPager with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(VerticalViewPager.class.getName());
    info.setScrollable(mAdapter != null && mAdapter.getCount() > 1);
    if (mAdapter != null && mCurItem >= 0 && mCurItem < mAdapter.getCount() - 1) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (mAdapter != null && mCurItem > 0 && mCurItem < mAdapter.getCount()) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 10
Source File: ViewPager.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (canScrollHorizontally(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollHorizontally(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 11
Source File: ViewPager.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (ViewPager.this.canScrollHorizontally(1)) {
        info.addAction(4096);
    }
    if (ViewPager.this.canScrollHorizontally(-1)) {
        info.addAction(8192);
    }
}
 
Example 12
Source File: ViewPagerEx.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPagerEx.class.getName());
    info.setScrollable(canScroll());
    if (canScrollHorizontally(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollHorizontally(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 13
Source File: ViewPager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (canScrollForward()) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollBackward()) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 14
Source File: VerticalViewPager.java    From InfiniteCycleViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (internalCanScrollVertically(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (internalCanScrollVertically(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 15
Source File: ViewPager.java    From guideshow with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (canScrollHorizontally(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollHorizontally(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 16
Source File: VelocityViewPager.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(VelocityViewPager.class.getName());
    info.setScrollable(canScroll());
    if (canScrollHorizontally(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (canScrollHorizontally(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 17
Source File: VerticalViewPager.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(ViewPager.class.getName());
    info.setScrollable(canScroll());
    if (internalCanScrollVertically(1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (internalCanScrollVertically(-1)) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 18
Source File: VerticalViewPager.java    From VerticalViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    info.setClassName(VerticalViewPager.class.getName());
    info.setScrollable(mAdapter != null && mAdapter.getCount() > 1);
    if (mAdapter != null && mCurItem >= 0 && mCurItem < mAdapter.getCount() - 1) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
    }
    if (mAdapter != null && mCurItem > 0 && mCurItem < mAdapter.getCount()) {
        info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
    }
}
 
Example 19
Source File: ExploreByTouchHelper.java    From android-recipes-app with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * specified item. Automatically manages accessibility focus actions.
 * <p>
 * Allows the implementing class to specify most node properties, but
 * overrides the following:
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#setPackageName}
 * <li>{@link AccessibilityNodeInfoCompat#setClassName}
 * <li>{@link AccessibilityNodeInfoCompat#setParent(View)}
 * <li>{@link AccessibilityNodeInfoCompat#setSource(View, int)}
 * <li>{@link AccessibilityNodeInfoCompat#setVisibleToUser}
 * <li>{@link AccessibilityNodeInfoCompat#setBoundsInScreen(Rect)}
 * </ul>
 * <p>
 * Uses the bounds of the parent view and the parent-relative bounding
 * rectangle specified by
 * {@link AccessibilityNodeInfoCompat#getBoundsInParent} to automatically
 * update the following properties:
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#setVisibleToUser}
 * <li>{@link AccessibilityNodeInfoCompat#setBoundsInParent}
 * </ul>
 *
 * @param virtualViewId The virtual view id for item for which to construct
 *            a node.
 * @return An {@link AccessibilityNodeInfoCompat} for the specified item.
 */
private AccessibilityNodeInfoCompat createNodeForChild(int virtualViewId) {
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain();

    // Ensure the client has good defaults.
    node.setEnabled(true);
    node.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the node.
    onPopulateNodeForVirtualView(virtualViewId, node);

    // Make sure the developer is following the rules.
    if ((node.getText() == null) && (node.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateNodeForVirtualViewId()");
    }

    node.getBoundsInParent(mTempParentRect);
    if (mTempParentRect.isEmpty()) {
        throw new RuntimeException("Callbacks must set parent bounds in "
                + "populateNodeForVirtualViewId()");
    }

    final int actions = node.getActions();
    if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) {
        throw new RuntimeException("Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in "
                + "populateNodeForVirtualViewId()");
    }
    if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
        throw new RuntimeException("Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in "
                + "populateNodeForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    node.setPackageName(mView.getContext().getPackageName());
    node.setSource(mView, virtualViewId);
    node.setParent(mView);

    // Manage internal accessibility focus state.
    if (mFocusedVirtualViewId == virtualViewId) {
        node.setAccessibilityFocused(true);
        node.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    } else {
        node.setAccessibilityFocused(false);
        node.addAction(AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS);
    }

    // Set the visibility based on the parent bound.
    if (intersectVisibleToUser(mTempParentRect)) {
        node.setVisibleToUser(true);
        node.setBoundsInParent(mTempParentRect);
    }

    // Calculate screen-relative bound.
    mView.getLocationOnScreen(mTempGlobalRect);
    final int offsetX = mTempGlobalRect[0];
    final int offsetY = mTempGlobalRect[1];
    mTempScreenRect.set(mTempParentRect);
    mTempScreenRect.offset(offsetX, offsetY);
    node.setBoundsInScreen(mTempScreenRect);

    return node;
}
 
Example 20
Source File: ExploreByTouchHelper.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * specified item. Automatically manages accessibility focus actions.
 * <p>
 * Allows the implementing class to specify most node properties, but
 * overrides the following:
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#setPackageName}
 * <li>{@link AccessibilityNodeInfoCompat#setClassName}
 * <li>{@link AccessibilityNodeInfoCompat#setParent(View)}
 * <li>{@link AccessibilityNodeInfoCompat#setSource(View, int)}
 * <li>{@link AccessibilityNodeInfoCompat#setVisibleToUser}
 * <li>{@link AccessibilityNodeInfoCompat#setBoundsInScreen(Rect)}
 * </ul>
 * <p>
 * Uses the bounds of the parent view and the parent-relative bounding
 * rectangle specified by
 * {@link AccessibilityNodeInfoCompat#getBoundsInParent} to automatically
 * update the following properties:
 * <ul>
 * <li>{@link AccessibilityNodeInfoCompat#setVisibleToUser}
 * <li>{@link AccessibilityNodeInfoCompat#setBoundsInParent}
 * </ul>
 *
 * @param virtualViewId The virtual view id for item for which to construct
 *            a node.
 * @return An {@link AccessibilityNodeInfoCompat} for the specified item.
 */
private AccessibilityNodeInfoCompat createNodeForChild(int virtualViewId) {
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain();

    // Ensure the client has good defaults.
    node.setEnabled(true);
    node.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the node.
    onPopulateNodeForVirtualView(virtualViewId, node);

    // Make sure the developer is following the rules.
    if ((node.getText() == null) && (node.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateNodeForVirtualViewId()");
    }

    node.getBoundsInParent(mTempParentRect);
    if (mTempParentRect.isEmpty()) {
        throw new RuntimeException("Callbacks must set parent bounds in "
                + "populateNodeForVirtualViewId()");
    }

    final int actions = node.getActions();
    if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) {
        throw new RuntimeException("Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in "
                + "populateNodeForVirtualViewId()");
    }
    if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
        throw new RuntimeException("Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in "
                + "populateNodeForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    node.setPackageName(mView.getContext().getPackageName());
    node.setSource(mView, virtualViewId);
    node.setParent(mView);

    // Manage internal accessibility focus state.
    if (mFocusedVirtualViewId == virtualViewId) {
        node.setAccessibilityFocused(true);
        node.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    } else {
        node.setAccessibilityFocused(false);
        node.addAction(AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS);
    }

    // Set the visibility based on the parent bound.
    if (intersectVisibleToUser(mTempParentRect)) {
        node.setVisibleToUser(true);
        node.setBoundsInParent(mTempParentRect);
    }

    // Calculate screen-relative bound.
    mView.getLocationOnScreen(mTempGlobalRect);
    final int offsetX = mTempGlobalRect[0];
    final int offsetY = mTempGlobalRect[1];
    mTempScreenRect.set(mTempParentRect);
    mTempScreenRect.offset(offsetX, offsetY);
    node.setBoundsInScreen(mTempScreenRect);

    return node;
}