Search in sources :

Example 76 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.

the class LauncherTransitionable method isClingsEnabled.

/* Cling related */
private boolean isClingsEnabled() {
    if (DISABLE_CLINGS) {
        return false;
    }
    // For now, limit only to phones
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    if (grid.isTablet()) {
        return false;
    }
    // disable clings when running in a test harness
    if (ActivityManager.isRunningInTestHarness())
        return false;
    // Disable clings for accessibility when explore by touch is enabled
    final AccessibilityManager a11yManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
    if (a11yManager.isTouchExplorationEnabled()) {
        return false;
    }
    //        }
    return true;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 77 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project Launcher3 by chislon.

the class PagedView method sendScrollAccessibilityEvent.

private void sendScrollAccessibilityEvent() {
    AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        AccessibilityEvent ev = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
        ev.setItemCount(getChildCount());
        ev.setFromIndex(mCurrentPage);
        final int action;
        if (getNextPage() >= mCurrentPage) {
            action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
        } else {
            action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
        }
        ev.setAction(action);
        sendAccessibilityEventUnchecked(ev);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 78 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project platform_frameworks_base by android.

the class ExploreByTouchHelper method requestAccessibilityFocus.

/**
     * Attempts to give accessibility focus to a virtual view.
     * <p>
     * A virtual view will not actually take focus if
     * {@link AccessibilityManager#isEnabled()} returns false,
     * {@link AccessibilityManager#isTouchExplorationEnabled()} returns false,
     * or the view already has accessibility focus.
     *
     * @param virtualViewId The id of the virtual view on which to place
     *            accessibility focus.
     * @return Whether this virtual view actually took accessibility focus.
     */
private boolean requestAccessibilityFocus(int virtualViewId) {
    final AccessibilityManager accessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!mManager.isEnabled() || !accessibilityManager.isTouchExplorationEnabled()) {
        return false;
    }
    // TODO: Check virtual view visibility.
    if (!isAccessibilityFocused(virtualViewId)) {
        // Clear focus from the previously focused view, if applicable.
        if (mFocusedVirtualViewId != INVALID_ID) {
            sendEventForVirtualView(mFocusedVirtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
        }
        // Set focus on the new view.
        mFocusedVirtualViewId = virtualViewId;
        // TODO: Only invalidate virtual view bounds.
        mView.invalidate();
        sendEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
        return true;
    }
    return false;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Example 79 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project SublimePicker by vikramkakkar.

the class AccessibilityUtils method makeAnnouncement.

public static void makeAnnouncement(View view, CharSequence announcement) {
    if (view == null)
        return;
    if (SUtils.isApi_16_OrHigher()) {
        view.announceForAccessibility(announcement);
    } else {
        // For API 15 and earlier, we need to construct an accessibility event
        Context ctx = view.getContext();
        AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (!am.isEnabled())
            return;
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
        AccessibilityRecordCompat arc = AccessibilityEventCompat.asRecord(event);
        arc.setSource(view);
        event.setClassName(view.getClass().getName());
        event.setPackageName(view.getContext().getPackageName());
        event.setEnabled(view.isEnabled());
        event.getText().add(announcement);
        am.sendAccessibilityEvent(event);
    }
}
Also used : Context(android.content.Context) AccessibilityRecordCompat(android.support.v4.view.accessibility.AccessibilityRecordCompat) AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 80 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project AndroidChromium by JackyAndroid.

the class DeviceClassManager method isAccessibilityModeEnabled.

public static boolean isAccessibilityModeEnabled(Context context) {
    TraceEvent.begin("DeviceClassManager::isAccessibilityModeEnabled");
    AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    boolean enabled = manager != null && manager.isEnabled() && manager.isTouchExplorationEnabled();
    TraceEvent.end("DeviceClassManager::isAccessibilityModeEnabled");
    return enabled;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)170 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)54 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)49 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 ArrayList (java.util.ArrayList)26 ServiceInfo (android.content.pm.ServiceInfo)20 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 ComponentName (android.content.ComponentName)16 Drawable (android.graphics.drawable.Drawable)10 Bundle (android.os.Bundle)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 SuppressLint (android.annotation.SuppressLint)7 Context (android.content.Context)7 SwitchPreference (android.support.v14.preference.SwitchPreference)7 ListPreference (android.support.v7.preference.ListPreference)7 Preference (android.support.v7.preference.Preference)7 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6