android.support.v4.view.ViewCompat#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS源码实例Demo

下面列出了android.support.v4.view.ViewCompat#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: stetho   文件: AccessibilityUtil.java
/**
 * Returns whether the supplied {@link View} and {@link AccessibilityNodeInfoCompat} would
 * produce spoken feedback if it were accessibility focused.  NOTE: not all speaking nodes are
 * focusable.
 *
 * @param view The {@link View} to evaluate
 * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
 * @return {@code true} if it meets the criterion for producing spoken feedback
 */
public static boolean isSpeakingNode(
    @Nullable AccessibilityNodeInfoCompat node,
    @Nullable View view) {
  if (node == null || view == null) {
    return false;
  }

  if (!node.isVisibleToUser()) {
    return false;
  }

  int important = ViewCompat.getImportantForAccessibility(view);
  if (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS ||
      (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO &&
          node.getChildCount() <= 0)) {
    return false;
  }

  return node.isCheckable() || hasText(node) || hasNonActionableSpeakingDescendants(node, view);
}
 
private static boolean includeChildForAccessibility(View child) {
    // If the child is not important for accessibility we make
    // sure this hides the entire subtree rooted at it as the
    // IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDATS is not
    // supported on older platforms but we want to hide the entire
    // content and not opened drawers if a drawer is opened.
    return ViewCompat.getImportantForAccessibility(child)
            != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
            && ViewCompat.getImportantForAccessibility(child)
            != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
}
 
源代码3 项目: stetho   文件: AccessibilityNodeInfoWrapper.java
public static String getIgnoredReasons(View view) {
  int important = ViewCompat.getImportantForAccessibility(view);

  if (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO) {
    return "View has importantForAccessibility set to 'NO'.";
  }

  if (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
    return "View has importantForAccessibility set to 'NO_HIDE_DESCENDANTS'.";
  }

  ViewParent parent = view.getParent();
  while (parent instanceof View) {
    if (ViewCompat.getImportantForAccessibility((View) parent)
            == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
      return "An ancestor View has importantForAccessibility set to 'NO_HIDE_DESCENDANTS'.";
    }
    parent = parent.getParent();
  }

  AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
  try {
    if (!node.isVisibleToUser()) {
      return "View is not visible.";
    }

    if (AccessibilityUtil.isAccessibilityFocusable(node, view)) {
      return "View is actionable, but has no description.";
    }

    if (AccessibilityUtil.hasText(node)) {
      return "View is not actionable, and an ancestor View has co-opted its description.";
    }

    return "View is not actionable and has no description.";
  } finally {
    node.recycle();
  }
}
 
源代码4 项目: adt-leanback-support   文件: DrawerLayout.java
private static boolean includeChildForAccessibility(View child) {
    // If the child is not important for accessibility we make
    // sure this hides the entire subtree rooted at it as the
    // IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDATS is not
    // supported on older platforms but we want to hide the entire
    // content and not opened drawers if a drawer is opened.
    return ViewCompat.getImportantForAccessibility(child)
            != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                && ViewCompat.getImportantForAccessibility(child)
            != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
}
 
源代码5 项目: something.apk   文件: MarginDrawerLayout.java
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;
        }
    }
}
 
源代码6 项目: android-recipes-app   文件: DrawerLayout.java
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;
        }
    }
}
 
源代码7 项目: V.FlyoutTest   文件: DrawerLayout.java
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;
        }
    }
}
 
源代码8 项目: guideshow   文件: DrawerLayout.java
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;
        }
    }
}
 
源代码9 项目: u2020   文件: DebugDrawerLayout.java
private static boolean includeChildForAccessibility(View child) {
  // If the child is not important for accessibility we make
  // sure this hides the entire subtree rooted at it as the
  // IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDATS is not
  // supported on older platforms but we want to hide the entire
  // content and not opened drawers if a drawer is opened.
  return ViewCompat.getImportantForAccessibility(child)
      != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
      && ViewCompat.getImportantForAccessibility(child)
      != ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
}
 
源代码10 项目: stetho   文件: AccessibilityNodeInfoWrapper.java
public static boolean getIgnored(View view) {
  int important = ViewCompat.getImportantForAccessibility(view);
  if (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO ||
      important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
    return true;
  }

  // Go all the way up the tree to make sure no parent has hidden its descendants
  ViewParent parent = view.getParent();
  while (parent instanceof View) {
    if (ViewCompat.getImportantForAccessibility((View) parent)
        == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
      return true;
    }
    parent = parent.getParent();
  }

  AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
  try {
    if (!node.isVisibleToUser()) {
      return true;
    }

    if (AccessibilityUtil.isAccessibilityFocusable(node, view)) {
      if (node.getChildCount() <= 0) {
        // Leaves that are accessibility focusable are never ignored, even if they don't have a
        // speakable description
        return false;
      } else if (AccessibilityUtil.isSpeakingNode(node, view)) {
        // Node is focusable and has something to speak
        return false;
      }

      // Node is focusable and has nothing to speak
      return true;
    }

    // If this node has no focusable ancestors, but it still has text,
    // then it should receive focus from navigation and be read aloud.
    if (!AccessibilityUtil.hasFocusableAncestor(node, view) && AccessibilityUtil.hasText(node)) {
      return false;
    }

    return true;
  } finally {
    node.recycle();
  }
}
 
源代码11 项目: TurboLauncher   文件: AppsCustomizePagedView.java
private void updateAccessibilityFlags() {
    int accessible = mState == State.NORMAL ?
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES :
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
    setImportantForAccessibility(accessible);
}
 
源代码12 项目: TurboLauncher   文件: Workspace.java
private void updateAccessibilityFlags() {
    int accessible = mState == State.NORMAL ?
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES :
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
    setImportantForAccessibility(accessible);
}
 
 同类方法