Search in sources :

Example 61 with AccessibilityNodeProvider

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;
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider) Point(android.graphics.Point)

Example 62 with AccessibilityNodeProvider

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;
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 63 with AccessibilityNodeProvider

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);
}
Also used : Rect(android.graphics.Rect) AccessibilityManager(android.view.accessibility.AccessibilityManager) Drawable(android.graphics.drawable.Drawable) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider)

Aggregations

AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)63 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)45 Point (android.graphics.Point)36 RemoteException (android.os.RemoteException)18 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)18 SomeArgs (com.android.internal.os.SomeArgs)18 View (android.view.View)11 ViewRootImpl (android.view.ViewRootImpl)11 RemoteView (android.widget.RemoteViews.RemoteView)11 Paint (android.graphics.Paint)10 Region (android.graphics.Region)10 Rect (android.graphics.Rect)7 AccessibilityManager (android.view.accessibility.AccessibilityManager)7 Bundle (android.os.Bundle)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 AttachInfo (android.view.View.AttachInfo)5 LinkedList (java.util.LinkedList)5 Drawable (android.graphics.drawable.Drawable)2