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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations