use of android.view.accessibility.AccessibilityNodeProvider in project android_frameworks_base by DirtyUnicorns.
the class ViewRootImpl method requestSendAccessibilityEvent.
@Override
public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (mView == null || mStopped || mPausedForTransition) {
return false;
}
// Intercept accessibility focus events fired by virtual nodes to keep
// track of accessibility focus position in such nodes.
final int eventType = event.getEventType();
switch(eventType) {
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
{
final long sourceNodeId = event.getSourceNodeId();
final int accessibilityViewId = AccessibilityNodeInfo.getAccessibilityViewId(sourceNodeId);
View source = mView.findViewByAccessibilityId(accessibilityViewId);
if (source != null) {
AccessibilityNodeProvider provider = source.getAccessibilityNodeProvider();
if (provider != null) {
final int virtualNodeId = AccessibilityNodeInfo.getVirtualDescendantId(sourceNodeId);
final AccessibilityNodeInfo node;
if (virtualNodeId == AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
node = provider.createAccessibilityNodeInfo(AccessibilityNodeProvider.HOST_VIEW_ID);
} else {
node = provider.createAccessibilityNodeInfo(virtualNodeId);
}
setAccessibilityFocus(source, node);
}
}
}
break;
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
{
final long sourceNodeId = event.getSourceNodeId();
final int accessibilityViewId = AccessibilityNodeInfo.getAccessibilityViewId(sourceNodeId);
View source = mView.findViewByAccessibilityId(accessibilityViewId);
if (source != null) {
AccessibilityNodeProvider provider = source.getAccessibilityNodeProvider();
if (provider != null) {
setAccessibilityFocus(null, null);
}
}
}
break;
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
{
handleWindowContentChangedEvent(event);
}
break;
}
mAccessibilityManager.sendAccessibilityEvent(event);
return true;
}
use of android.view.accessibility.AccessibilityNodeProvider in project cornerstone by Onskreen.
the class ViewRootImpl method requestSendAccessibilityEvent.
public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (mView == null) {
return false;
}
// Intercept accessibility focus events fired by virtual nodes to keep
// track of accessibility focus position in such nodes.
final int eventType = event.getEventType();
switch(eventType) {
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
{
final long sourceNodeId = event.getSourceNodeId();
final int accessibilityViewId = AccessibilityNodeInfo.getAccessibilityViewId(sourceNodeId);
View source = mView.findViewByAccessibilityId(accessibilityViewId);
if (source != null) {
AccessibilityNodeProvider provider = source.getAccessibilityNodeProvider();
if (provider != null) {
AccessibilityNodeInfo node = provider.createAccessibilityNodeInfo(AccessibilityNodeInfo.getVirtualDescendantId(sourceNodeId));
setAccessibilityFocus(source, node);
}
}
}
break;
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
{
final long sourceNodeId = event.getSourceNodeId();
final int accessibilityViewId = AccessibilityNodeInfo.getAccessibilityViewId(sourceNodeId);
View source = mView.findViewByAccessibilityId(accessibilityViewId);
if (source != null) {
AccessibilityNodeProvider provider = source.getAccessibilityNodeProvider();
if (provider != null) {
setAccessibilityFocus(null, null);
}
}
}
break;
}
mAccessibilityManager.sendAccessibilityEvent(event);
return true;
}
use of android.view.accessibility.AccessibilityNodeProvider in project cornerstone by Onskreen.
the class ViewRootImpl method drawAccessibilityFocusedDrawableIfNeeded.
/**
* We want to draw a highlight around the current accessibility focused.
* Since adding a style for all possible view is not a viable option we
* have this specialized drawing method.
*
* Note: We are doing this here to be able to draw the highlight for
* virtual views in addition to real ones.
*
* @param canvas The canvas on which to draw.
*/
private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
AccessibilityManager manager = AccessibilityManager.getInstance(mView.mContext);
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
return;
}
if (mAccessibilityFocusedHost == null || mAccessibilityFocusedHost.mAttachInfo == null) {
return;
}
Drawable drawable = getAccessibilityFocusedDrawable();
if (drawable == null) {
return;
}
AccessibilityNodeProvider provider = mAccessibilityFocusedHost.getAccessibilityNodeProvider();
Rect bounds = mView.mAttachInfo.mTmpInvalRect;
if (provider == null) {
mAccessibilityFocusedHost.getDrawingRect(bounds);
if (mView instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) mView;
viewGroup.offsetDescendantRectToMyCoords(mAccessibilityFocusedHost, bounds);
}
} else {
if (mAccessibilityFocusedVirtualView == null) {
return;
}
mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
}
drawable.setBounds(bounds);
drawable.draw(canvas);
}
Aggregations