Example usage for android.support.v4.view.accessibility AccessibilityWindowInfoCompat TYPE_INPUT_METHOD

List of usage examples for android.support.v4.view.accessibility AccessibilityWindowInfoCompat TYPE_INPUT_METHOD

Introduction

In this page you can find the example usage for android.support.v4.view.accessibility AccessibilityWindowInfoCompat TYPE_INPUT_METHOD.

Prototype

int TYPE_INPUT_METHOD

To view the source code for android.support.v4.view.accessibility AccessibilityWindowInfoCompat TYPE_INPUT_METHOD.

Click Source Link

Document

Window type: This is an input method window.

Usage

From source file:com.android.talkback.eventprocessor.ProcessorScreen.java

/**
 * Uses a heuristic to guess whether an event should be announced.
 * Any event that comes from an IME, or an invisible window is considered
 * an announcement./*from w  ww .j  ava2 s .  c o m*/
 */
private boolean shouldAnnounceEvent(AccessibilityEvent event, int windowId) {
    // Assume window ID of 0 is the keyboard.
    if (windowId == WINDOW_ID_NONE) {
        return true;
    }

    // If there's an actual window ID, we need to check the window type (if window available).
    boolean shouldAnnounceWindow = false;
    AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    AccessibilityNodeInfoCompat source = record.getSource();
    if (source != null) {
        AccessibilityWindowInfoCompat window = source.getWindow();
        if (window != null) {
            shouldAnnounceWindow = window.getType() == AccessibilityWindowInfoCompat.TYPE_INPUT_METHOD;
            window.recycle();
        } else {
            // If window is not visible, we cannot know whether the window type is input method
            // or not. Let's announce it for the case. If window is visible but window info is
            // not available, it can be non-focusable visible window. Don't announce it for the
            // case. It can be a toast.
            shouldAnnounceWindow = !source.isVisibleToUser();
        }
        source.recycle();
    }
    return shouldAnnounceWindow;
}