Search in sources :

Example 41 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.

the class View method requestAccessibilityFocus.

/**
     * Call this to try to give accessibility focus to this view.
     *
     * A view will not actually take focus if {@link AccessibilityManager#isEnabled()}
     * returns false or the view is no visible or the view already has accessibility
     * focus.
     *
     * See also {@link #focusSearch(int)}, which is what you call to say that you
     * have focus, and you want your parent to look for the next one.
     *
     * @return Whether this view actually took accessibility focus.
     *
     * @hide
     */
public boolean requestAccessibilityFocus() {
    AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
    if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
        return false;
    }
    if ((mViewFlags & VISIBILITY_MASK) != VISIBLE) {
        return false;
    }
    if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) == 0) {
        mPrivateFlags2 |= PFLAG2_ACCESSIBILITY_FOCUSED;
        ViewRootImpl viewRootImpl = getViewRootImpl();
        if (viewRootImpl != null) {
            viewRootImpl.setAccessibilityFocus(this, null);
        }
        invalidate();
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
        return true;
    }
    return false;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 42 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.

the class SimpleWeekView method onHoverEvent.

@Override
public boolean onHoverEvent(MotionEvent event) {
    Context context = getContext();
    // only send accessibility events if accessibility and exploration are
    // on.
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
        return super.onHoverEvent(event);
    }
    if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
        Time hover = getDayFromLocation(event.getX());
        if (hover != null && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
            Long millis = hover.toMillis(true);
            String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
            AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
            accessEvent.getText().add(date);
            sendAccessibilityEventUnchecked(accessEvent);
            mLastHoverTime = hover;
        }
    }
    return true;
}
Also used : Context(android.content.Context) AccessibilityManager(android.view.accessibility.AccessibilityManager) Time(android.text.format.Time) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 43 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.

the class WebViewClassic method isAccessibilityInjectionEnabled.

private boolean isAccessibilityInjectionEnabled() {
    final AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
    if (!manager.isEnabled()) {
        return false;
    }
    // Accessibility scripts should be injected only when a speaking service
    // is enabled. This may need to change later to accommodate Braille.
    final List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
    if (services.isEmpty()) {
        return false;
    }
    return true;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 44 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by ParanoidAndroid.

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.getBoundsOnScreen(bounds);
    } else {
        if (mAccessibilityFocusedVirtualView == null) {
            return;
        }
        mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
    }
    bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
    bounds.intersect(0, 0, mAttachInfo.mViewRootImpl.mWidth, mAttachInfo.mViewRootImpl.mHeight);
    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)

Example 45 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project NewXmPluginSDK by MiEcosystem.

the class NumberPicker method dispatchHoverEvent.

@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
    if (!mHasSelectorWheel) {
        return super.dispatchHoverEvent(event);
    }
    AccessibilityManager acm = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (acm.isEnabled()) {
        final int eventY = (int) event.getY();
        final int hoveredVirtualViewId;
        if (eventY < mTopSelectionDividerTop) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
        } else if (eventY > mBottomSelectionDividerBottom) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
        } else {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
        }
        final int action = event.getActionMasked();
        AccessibilityNodeProviderImpl provider = (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider();
        switch(action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                {
                    provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                    mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                    provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
                }
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                {
                    if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId && mLastHoveredChildVirtualViewId != View.NO_ID) {
                        provider.sendAccessibilityEventForVirtualView(mLastHoveredChildVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                        provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                        mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                        provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
                    }
                }
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                {
                    provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                    mLastHoveredChildVirtualViewId = View.NO_ID;
                }
                break;
        }
    }
    return false;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) Paint(android.graphics.Paint)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)119 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)47 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)19 ArrayList (java.util.ArrayList)12 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6 UserInfo (android.content.pm.UserInfo)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 ParcelableString (com.android.internal.util.ParcelableString)6 SuppressLint (android.annotation.SuppressLint)5 ServiceInfo (android.content.pm.ServiceInfo)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 Context (android.content.Context)4 AttachInfo (android.view.View.AttachInfo)4 IAccessibilityManagerClient (android.view.accessibility.IAccessibilityManagerClient)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 Paint (android.graphics.Paint)3