Example usage for android.view.accessibility AccessibilityManager isEnabled

List of usage examples for android.view.accessibility AccessibilityManager isEnabled

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityManager isEnabled.

Prototype

public boolean isEnabled() 

Source Link

Document

Returns if the accessibility in the system is enabled.

Usage

From source file:Main.java

public static void sendAccessibilityEvent(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        am.sendAccessibilityEvent(AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED));
    }/*from   w  ww  .  j a v  a 2s.  c  o m*/
}

From source file:Main.java

public static boolean isEnabled(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    return am.isEnabled();
}

From source file:Main.java

/**
 * Announce text through the AccessibilityManager for a view.
 *
 * @param text/*from w  ww  .j av  a2s  .  c o m*/
 * @param view
 * @param manager
 */
public static void announceText(String text, View view, AccessibilityManager manager) {
    // Only announce text if the accessibility service is enabled
    if (!manager.isEnabled()) {
        return;
    }
    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
    event.getText().add(text);
    event.setEnabled(true);
    // Tie the event to the view
    event.setClassName(view.getClass().getName());
    event.setPackageName(view.getContext().getPackageName());
    AccessibilityEventCompat.asRecord(event).setSource(view);

    // Send the announcement
    manager.sendAccessibilityEvent(event);

}

From source file:Main.java

/**
 * If accessibility manager is enabled, we should force text views to be focusable.
 */// ww  w .  j  ava2 s  .c o  m
public static boolean forceFocusableViews(Context context) {
    AccessibilityManager accessMan = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    return accessMan.isEnabled();
}

From source file:Main.java

/**
 * Return true if the accessibility service or touch exploration are enabled.
 *//*from  ww  w . jav a 2s .com*/
public static boolean isTouchAccessiblityEnabled(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    boolean isAccessibilityEnabled = am.isEnabled();
    boolean isTouchExplorationEnabled = am.isTouchExplorationEnabled();
    return isAccessibilityEnabled || isTouchExplorationEnabled;
}

From source file:com.android.gallery3d.util.AccessibilityUtils.java

public static void makeAnnouncement(View view, CharSequence announcement) {
    if (view == null)
        return;//from   w  w  w  .  j av a  2 s .  c  om
    if (ApiHelper.HAS_ANNOUNCE_FOR_ACCESSIBILITY) {
        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 = new AccessibilityRecordCompat(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);
    }
}

From source file:com.android.fastergallery.util.AccessibilityUtils.java

public static void makeAnnouncement(View view, CharSequence announcement) {
    if (view == null)
        return;//w  w w  .j ava2  s  .c  o m
    if (ApiHelper.HAS_ANNOUNCE_FOR_ACCESSIBILITY) {
        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 = new AccessibilityRecordCompat(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);
    }
}

From source file:com.appeaser.sublimepickerlibrary.utilities.AccessibilityUtils.java

public static void makeAnnouncement(View view, CharSequence announcement) {
    if (view == null)
        return;/*w ww .  ja  v  a  2  s . co m*/
    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);
    }
}

From source file:Main.java

/**
 * @returns True if accessibility touch exploration is currently enabled
 * in the framework./*from   w w  w.  j  av a  2s  .c  o m*/
 */
public static boolean isAccessibilityEnabled(Context context) {
    final AccessibilityManager manager = (AccessibilityManager) context.getSystemService(ACCESSIBILITY_SERVICE);
    return ACCESSIBILITY_ENABLED
            || (manager.isEnabled() && AccessibilityManagerCompat.isTouchExplorationEnabled(manager));
}

From source file:Main.java

/**
 * Try to send an {@link AccessibilityEvent}
 * for a {@link View}.//from  w w w . j av a2s .  c  o m
 *
 * @param view The View that will dispatch the AccessibilityEvent
 * @return true if the AccessibilityEvent was dispatched
 */
@SuppressWarnings("UnusedReturnValue")
public static boolean sendAccessibilityEvent(View view) {
    final AccessibilityManager accessibilityManager = (AccessibilityManager) view.getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (!accessibilityManager.isEnabled())
        return false;

    final AccessibilityEvent accessibilityEvent = AccessibilityEvent
            .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
    accessibilityEvent.setClassName(view.getClass().getName());
    accessibilityEvent.setPackageName(view.getContext().getPackageName());

    view.dispatchPopulateAccessibilityEvent(accessibilityEvent);
    accessibilityManager.sendAccessibilityEvent(accessibilityEvent);

    return true;
}