Search in sources :

Example 1 with AccessibilityRecordCompat

use of android.support.v4.view.accessibility.AccessibilityRecordCompat in project actor-platform by actorapp.

the class ChatLinearLayoutManager method onInitializeAccessibilityEvent.

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (getChildCount() > 0) {
        final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        record.setFromIndex(findFirstVisibleItemPosition());
        record.setToIndex(findLastVisibleItemPosition());
    }
}
Also used : AccessibilityRecordCompat(android.support.v4.view.accessibility.AccessibilityRecordCompat)

Example 2 with AccessibilityRecordCompat

use of android.support.v4.view.accessibility.AccessibilityRecordCompat in project HoloEverywhere by Prototik.

the class TouchExplorationHelper method getEventForItem.

private AccessibilityEvent getEventForItem(T item, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    final int virtualDescendantId = getIdForItem(item);
    // Ensure the client has good defaults.
    event.setEnabled(true);
    // Allow the client to populate the event.
    populateEventForItem(item, event);
    if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
        throw new RuntimeException("You must add text or a content description in populateEventForItem()");
    }
    // Don't allow the client to override these properties.
    event.setClassName(item.getClass().getName());
    event.setPackageName(mParentView.getContext().getPackageName());
    record.setSource(mParentView, virtualDescendantId);
    return event;
}
Also used : AccessibilityRecordCompat(android.support.v4.view.accessibility.AccessibilityRecordCompat) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 3 with AccessibilityRecordCompat

use of android.support.v4.view.accessibility.AccessibilityRecordCompat in project android-betterpickers by code-troopers.

the class TouchExplorationHelper method getEventForItem.

private AccessibilityEvent getEventForItem(T item, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    final int virtualDescendantId = getIdForItem(item);
    // Ensure the client has good defaults.
    event.setEnabled(true);
    // Allow the client to populate the event.
    populateEventForItem(item, event);
    if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
        throw new RuntimeException("You must add text or a content description in populateEventForItem()");
    }
    // Don't allow the client to override these properties.
    event.setClassName(item.getClass().getName());
    event.setPackageName(mParentView.getContext().getPackageName());
    record.setSource(mParentView, virtualDescendantId);
    return event;
}
Also used : AccessibilityRecordCompat(android.support.v4.view.accessibility.AccessibilityRecordCompat) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 4 with AccessibilityRecordCompat

use of android.support.v4.view.accessibility.AccessibilityRecordCompat 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 5 with AccessibilityRecordCompat

use of android.support.v4.view.accessibility.AccessibilityRecordCompat in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class KeyboardAccessibilityNodeProvider method createAccessibilityEvent.

/**
     * Creates and populates an {@link AccessibilityEvent} for the specified key
     * and event type.
     *
     * @param key A key on the host keyboard view.
     * @param eventType The event type to create.
     * @return A populated {@link AccessibilityEvent} for the key.
     * @see AccessibilityEvent
     */
public AccessibilityEvent createAccessibilityEvent(final Key key, final int eventType) {
    final int virtualViewId = getVirtualViewIdOf(key);
    final String keyDescription = getKeyDescription(key);
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setPackageName(mKeyboardView.getContext().getPackageName());
    event.setClassName(key.getClass().getName());
    event.setContentDescription(keyDescription);
    event.setEnabled(true);
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mKeyboardView, virtualViewId);
    return event;
}
Also used : AccessibilityRecordCompat(android.support.v4.view.accessibility.AccessibilityRecordCompat) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Aggregations

AccessibilityRecordCompat (android.support.v4.view.accessibility.AccessibilityRecordCompat)6 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)4 Context (android.content.Context)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1