Example usage for android.view.accessibility AccessibilityEvent setContentDescription

List of usage examples for android.view.accessibility AccessibilityEvent setContentDescription

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent setContentDescription.

Prototype

public void setContentDescription(CharSequence contentDescription) 

Source Link

Document

Sets the description of the source.

Usage

From source file:com.onyx.latinime.accessibility.AccessibleKeyboardViewProxy.java

/**
 * Sends a window state change event with the specified text.
 *
 * @param text The text to send with the event.
 *//*from w ww.ja v a 2s  .  c o  m*/
private void sendWindowStateChanged(final String text) {
    final AccessibilityEvent stateChange = AccessibilityEvent
            .obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    mView.onInitializeAccessibilityEvent(stateChange);
    stateChange.getText().add(text);
    stateChange.setContentDescription(null);

    final ViewParent parent = mView.getParent();
    if (parent != null) {
        parent.requestSendAccessibilityEvent(mView, stateChange);
    }
}

From source file:com.actionbarsherlock.internal.widget.ActionBarContextView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Action mode started
        //TODO event.setSource(this);
        event.setClassName(getClass().getName());
        event.setPackageName(getContext().getPackageName());
        event.setContentDescription(mTitle);
    } else {/*w  w w. j  a va2 s  .  c  om*/
        //TODO super.onInitializeAccessibilityEvent(event);
    }
}

From source file:android.support.v7.internal.widget.ActionBarContextView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    if (Build.VERSION.SDK_INT >= 14) {
        if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
            // Action mode started
            event.setSource(this);
            event.setClassName(getClass().getName());
            event.setPackageName(getContext().getPackageName());
            event.setContentDescription(mTitle);
        } else {/*from   w w w . ja  v  a2s  .  com*/
            super.onInitializeAccessibilityEvent(event);
        }
    }
}

From source file:org.mozilla.gecko.GeckoAppShell.java

public static void emitGeckoAccessibilityEvent(int eventType, String role, String text, String description,
        boolean enabled, boolean checked, boolean password) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) GeckoApp.mAppContext
            .getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (!accessibilityManager.isEnabled())
        return;// w  w  w  .java 2s  .c  om

    LayerController layerController = GeckoApp.mAppContext.getLayerController();
    LayerView layerView = layerController.getView();

    AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setClassName(layerView.getClass().getName() + "$" + role);
    event.setPackageName(GeckoApp.mAppContext.getPackageName());
    event.setEnabled(enabled);
    event.setChecked(checked);
    event.setPassword(password);
    event.setContentDescription(description);
    event.getText().add(text);

    accessibilityManager.sendAccessibilityEvent(event);
}