private AccessibilityNodeInfoCompat populateNodeForItemInternal(
      T item, AccessibilityNodeInfoCompat node) {
    final int virtualDescendantId = getIdForItem(item);

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

    // Allow the client to populate the node.
    populateNodeForItem(item, node);

    if (TextUtils.isEmpty(node.getText()) && TextUtils.isEmpty(node.getContentDescription())) {
      throw new RuntimeException(
          "You must add text or a content description in populateNodeForItem()");
    }

    // Don't allow the client to override these properties.
    node.setPackageName(mParentView.getContext().getPackageName());
    node.setClassName(item.getClass().getName());
    node.setParent(mParentView);
    node.setSource(mParentView, virtualDescendantId);

    if (mFocusedItemId == virtualDescendantId) {
      node.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
    } else {
      node.addAction(AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS);
    }

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

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

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

    return node;
  }
 private AccessibilityNodeInfoCompat createNodeForChild(int i) {
   AccessibilityNodeInfoCompat accessibilitynodeinfocompat = AccessibilityNodeInfoCompat.obtain();
   accessibilitynodeinfocompat.setEnabled(true);
   accessibilitynodeinfocompat.setClassName(DEFAULT_CLASS_NAME);
   onPopulateNodeForVirtualView(i, accessibilitynodeinfocompat);
   if (accessibilitynodeinfocompat.getText() == null
       && accessibilitynodeinfocompat.getContentDescription() == null) {
     throw new RuntimeException(
         "Callbacks must add text or a content description in populateNodeForVirtualViewId()");
   }
   accessibilitynodeinfocompat.getBoundsInParent(mTempParentRect);
   if (mTempParentRect.isEmpty()) {
     throw new RuntimeException(
         "Callbacks must set parent bounds in populateNodeForVirtualViewId()");
   }
   int j = accessibilitynodeinfocompat.getActions();
   if ((j & 0x40) != 0) {
     throw new RuntimeException(
         "Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
   }
   if ((j & 0x80) != 0) {
     throw new RuntimeException(
         "Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()");
   }
   accessibilitynodeinfocompat.setPackageName(mView.getContext().getPackageName());
   accessibilitynodeinfocompat.setSource(mView, i);
   accessibilitynodeinfocompat.setParent(mView);
   if (mFocusedVirtualViewId == i) {
     accessibilitynodeinfocompat.setAccessibilityFocused(true);
     accessibilitynodeinfocompat.addAction(128);
   } else {
     accessibilitynodeinfocompat.setAccessibilityFocused(false);
     accessibilitynodeinfocompat.addAction(64);
   }
   if (intersectVisibleToUser(mTempParentRect)) {
     accessibilitynodeinfocompat.setVisibleToUser(true);
     accessibilitynodeinfocompat.setBoundsInParent(mTempParentRect);
   }
   mView.getLocationOnScreen(mTempGlobalRect);
   i = mTempGlobalRect[0];
   j = mTempGlobalRect[1];
   mTempScreenRect.set(mTempParentRect);
   mTempScreenRect.offset(i, j);
   accessibilitynodeinfocompat.setBoundsInScreen(mTempScreenRect);
   return accessibilitynodeinfocompat;
 }
示例#3
0
 @Override
 public void onInitializeAccessibilityNodeInfo(View object, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
     AccessibilityNodeInfoCompat accessibilityNodeInfoCompat2 = AccessibilityNodeInfoCompat.obtain(accessibilityNodeInfoCompat);
     super.onInitializeAccessibilityNodeInfo((View)object, accessibilityNodeInfoCompat2);
     this.copyNodeInfoNoChildren(accessibilityNodeInfoCompat, accessibilityNodeInfoCompat2);
     accessibilityNodeInfoCompat2.recycle();
     accessibilityNodeInfoCompat.setClassName((CharSequence)SlidingPaneLayout.class.getName());
     accessibilityNodeInfoCompat.setSource((View)object);
     object = ViewCompat.getParentForAccessibility((View)object);
     if (object instanceof View) {
         accessibilityNodeInfoCompat.setParent((View)object);
     }
     int n = SlidingPaneLayout.this.getChildCount();
     for (int i = 0; i < n; ++i) {
         object = SlidingPaneLayout.this.getChildAt(i);
         if (this.filter((View)object) || object.getVisibility() != 0) continue;
         ViewCompat.setImportantForAccessibility((View)object, 1);
         accessibilityNodeInfoCompat.addChild((View)object);
     }
 }
示例#4
0
 public final void onInitializeAccessibilityNodeInfo(
     View view, AccessibilityNodeInfoCompat accessibilitynodeinfocompat) {
   AccessibilityNodeInfoCompat accessibilitynodeinfocompat1 =
       AccessibilityNodeInfoCompat.obtain(accessibilitynodeinfocompat);
   super.onInitializeAccessibilityNodeInfo(view, accessibilitynodeinfocompat1);
   accessibilitynodeinfocompat.setClassName(
       com / roidapp / baselib / view / FixedDrawerLayout.getName());
   accessibilitynodeinfocompat.setSource(view);
   Object obj = ViewCompat.getParentForAccessibility(view);
   if (obj instanceof View) {
     accessibilitynodeinfocompat.setParent((View) obj);
   }
   obj = b;
   accessibilitynodeinfocompat1.getBoundsInParent(((Rect) (obj)));
   accessibilitynodeinfocompat.setBoundsInParent(((Rect) (obj)));
   accessibilitynodeinfocompat1.getBoundsInScreen(((Rect) (obj)));
   accessibilitynodeinfocompat.setBoundsInScreen(((Rect) (obj)));
   accessibilitynodeinfocompat.setVisibleToUser(accessibilitynodeinfocompat1.isVisibleToUser());
   accessibilitynodeinfocompat.setPackageName(accessibilitynodeinfocompat1.getPackageName());
   accessibilitynodeinfocompat.setClassName(accessibilitynodeinfocompat1.getClassName());
   accessibilitynodeinfocompat.setContentDescription(
       accessibilitynodeinfocompat1.getContentDescription());
   accessibilitynodeinfocompat.setEnabled(accessibilitynodeinfocompat1.isEnabled());
   accessibilitynodeinfocompat.setClickable(accessibilitynodeinfocompat1.isClickable());
   accessibilitynodeinfocompat.setFocusable(accessibilitynodeinfocompat1.isFocusable());
   accessibilitynodeinfocompat.setFocused(accessibilitynodeinfocompat1.isFocused());
   accessibilitynodeinfocompat.setAccessibilityFocused(
       accessibilitynodeinfocompat1.isAccessibilityFocused());
   accessibilitynodeinfocompat.setSelected(accessibilitynodeinfocompat1.isSelected());
   accessibilitynodeinfocompat.setLongClickable(accessibilitynodeinfocompat1.isLongClickable());
   accessibilitynodeinfocompat.addAction(accessibilitynodeinfocompat1.getActions());
   accessibilitynodeinfocompat1.recycle();
   view = (ViewGroup) view;
   int j = view.getChildCount();
   for (int i = 0; i < j; i++) {
     View view1 = view.getChildAt(i);
     if (FixedDrawerLayout.h(view1)) {
       accessibilitynodeinfocompat.addChild(view1);
     }
   }
 }