Search in sources :

Example 1 with AccessibilityNodeInfoCompat

use of android.support.v4.view.accessibility.AccessibilityNodeInfoCompat in project android-betterpickers by code-troopers.

the class TouchExplorationHelper method getNodeForParent.

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;
}
Also used : AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) LinkedList(java.util.LinkedList)

Example 2 with AccessibilityNodeInfoCompat

use of android.support.v4.view.accessibility.AccessibilityNodeInfoCompat in project HoloEverywhere by Prototik.

the class TouchExplorationHelper method createAccessibilityNodeInfo.

@Override
public AccessibilityNodeInfoCompat createAccessibilityNodeInfo(int virtualViewId) {
    if (virtualViewId == View.NO_ID) {
        return getNodeForParent();
    }
    final T item = getItemForId(virtualViewId);
    if (item == null) {
        return null;
    }
    final AccessibilityNodeInfoCompat node = AccessibilityNodeInfoCompat.obtain();
    populateNodeForItemInternal(item, node);
    return node;
}
Also used : AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)

Example 3 with AccessibilityNodeInfoCompat

use of android.support.v4.view.accessibility.AccessibilityNodeInfoCompat in project material-components-android by material-components.

the class BottomSheetDialog method wrapInBottomSheet.

private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
    final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(), R.layout.design_bottom_sheet_dialog, null);
    if (layoutResId != 0 && view == null) {
        view = getLayoutInflater().inflate(layoutResId, coordinator, false);
    }
    FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet);
    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setBottomSheetCallback(mBottomSheetCallback);
    mBehavior.setHideable(mCancelable);
    if (params == null) {
        bottomSheet.addView(view);
    } else {
        bottomSheet.addView(view, params);
    }
    // We treat the CoordinatorLayout as outside the dialog though it is technically inside
    coordinator.findViewById(R.id.touch_outside).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mCancelable && isShowing() && shouldWindowCloseOnTouchOutside()) {
                cancel();
            }
        }
    });
    // Handle accessibility events
    ViewCompat.setAccessibilityDelegate(bottomSheet, new AccessibilityDelegateCompat() {

        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            if (mCancelable) {
                info.addAction(AccessibilityNodeInfoCompat.ACTION_DISMISS);
                info.setDismissable(true);
            } else {
                info.setDismissable(false);
            }
        }

        @Override
        public boolean performAccessibilityAction(View host, int action, Bundle args) {
            if (action == AccessibilityNodeInfoCompat.ACTION_DISMISS && mCancelable) {
                cancel();
                return true;
            }
            return super.performAccessibilityAction(host, action, args);
        }
    });
    bottomSheet.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            // Consume the event and prevent it from falling through
            return true;
        }
    });
    return coordinator;
}
Also used : Bundle(android.os.Bundle) FrameLayout(android.widget.FrameLayout) AccessibilityDelegateCompat(android.support.v4.view.AccessibilityDelegateCompat) AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 4 with AccessibilityNodeInfoCompat

use of android.support.v4.view.accessibility.AccessibilityNodeInfoCompat in project stetho by facebook.

the class AccessibilityUtil method hasFocusableAncestor.

/**
   * Determines if any of the provided {@link View}'s and {@link AccessibilityNodeInfoCompat}'s
   * ancestors can receive accessibility focus
   *
   * @param view The {@link View} to evaluate
   * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
   * @return {@code true} if an ancestor of may receive accessibility focus
   */
public static boolean hasFocusableAncestor(@Nullable AccessibilityNodeInfoCompat node, @Nullable View view) {
    if (node == null || view == null) {
        return false;
    }
    ViewParent parentView = ViewCompat.getParentForAccessibility(view);
    if (!(parentView instanceof View)) {
        return false;
    }
    AccessibilityNodeInfoCompat parentNode = AccessibilityNodeInfoCompat.obtain();
    try {
        ViewCompat.onInitializeAccessibilityNodeInfo((View) parentView, parentNode);
        if (parentNode == null) {
            return false;
        }
        if (isAccessibilityFocusable(parentNode, (View) parentView)) {
            return true;
        }
        if (hasFocusableAncestor(parentNode, (View) parentView)) {
            return true;
        }
    } finally {
        parentNode.recycle();
    }
    return false;
}
Also used : ViewParent(android.view.ViewParent) AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) HorizontalScrollView(android.widget.HorizontalScrollView) ScrollView(android.widget.ScrollView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 5 with AccessibilityNodeInfoCompat

use of android.support.v4.view.accessibility.AccessibilityNodeInfoCompat in project stetho by facebook.

the class AccessibilityNodeInfoWrapper method getIsAccessibilityFocused.

public static boolean getIsAccessibilityFocused(View view) {
    AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
    boolean isAccessibilityFocused = node.isAccessibilityFocused();
    node.recycle();
    return isAccessibilityFocused;
}
Also used : AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)

Aggregations

AccessibilityNodeInfoCompat (android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)20 View (android.view.View)11 Bundle (android.os.Bundle)6 ActivityManager (android.app.ActivityManager)5 Context (android.content.Context)5 Point (android.graphics.Point)5 GridLayoutManager (android.support.v7.widget.GridLayoutManager)5 SpanSizeLookup (android.support.v7.widget.GridLayoutManager.SpanSizeLookup)5 RecyclerView (android.support.v7.widget.RecyclerView)5 Recycler (android.support.v7.widget.RecyclerView.Recycler)5 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 DocumentClipper (com.android.documentsui.DocumentClipper)5 State (com.android.documentsui.State)5 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)5 Nullable (android.support.annotation.Nullable)3 ViewParent (android.view.ViewParent)3 ViewGroup (android.view.ViewGroup)2 AdapterView (android.widget.AdapterView)2