Search in sources :

Example 21 with AccessibilityEvent

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

the class View method announceForAccessibility.

/**
     * Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT}
     * {@link AccessibilityEvent} to make an announcement which is related to some
     * sort of a context change for which none of the events representing UI transitions
     * is a good fit. For example, announcing a new page in a book. If accessibility
     * is not enabled this method does nothing.
     *
     * @param text The announcement text.
     */
public void announceForAccessibility(CharSequence text) {
    if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
        onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        event.setContentDescription(null);
        mParent.requestSendAccessibilityEvent(this, event);
    }
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 22 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project robolectric by robolectric.

the class ShadowAccessibilityEventTest method shouldRecordParcelables.

@Test
public void shouldRecordParcelables() {
    final Notification notification = new Notification();
    event.setParcelableData(notification);
    AccessibilityEvent anotherEvent = AccessibilityEvent.obtain(event);
    assertThat(anotherEvent.getParcelableData() instanceof Notification).isEqualTo(true);
    assertThat(anotherEvent.getParcelableData()).isEqualTo(notification);
    anotherEvent.recycle();
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Notification(android.app.Notification) Test(org.junit.Test)

Example 23 with AccessibilityEvent

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

the class Folder method sendCustomAccessibilityEvent.

private void sendCustomAccessibilityEvent(int type, String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(type);
        onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 24 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project AndroidTraining by mixi-inc.

the class IcsAdapterView method onRequestSendAccessibilityEvent.

@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
    if (super.onRequestSendAccessibilityEvent(child, event)) {
        // Add a record for ourselves as well.
        AccessibilityEvent record = AccessibilityEvent.obtain();
        onInitializeAccessibilityEvent(record);
        // Populate with the text of the requesting child.
        child.dispatchPopulateAccessibilityEvent(record);
        event.appendRecord(record);
        return true;
    }
    return false;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 25 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project Fairphone by Kwamecorp.

the class DragLayer method sendTapOutsideFolderAccessibilityEvent.

private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
        onInitializeAccessibilityEvent(event);
        event.getText().add(getContext().getString(stringId));
        accessibilityManager.sendAccessibilityEvent(event);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Aggregations

AccessibilityEvent (android.view.accessibility.AccessibilityEvent)234 AccessibilityManager (android.view.accessibility.AccessibilityManager)47 LargeTest (android.test.suitebuilder.annotation.LargeTest)40 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)20 ViewParent (android.view.ViewParent)13 TimeoutException (java.util.concurrent.TimeoutException)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)10 Notification (android.app.Notification)7 ITransientNotification (android.app.ITransientNotification)6 RemoteException (android.os.RemoteException)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 SuppressLint (android.annotation.SuppressLint)5 AccessibilityEventFilter (android.app.UiAutomation.AccessibilityEventFilter)5 OnAccessibilityEventListener (android.app.UiAutomation.OnAccessibilityEventListener)5 ViewGroup (android.view.ViewGroup)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5