Example usage for android.view.accessibility AccessibilityEvent getEventType

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

Introduction

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

Prototype

public @EventType int getEventType() 

Source Link

Document

Gets the event type.

Usage

From source file:Main.java

/**
 * Determines if an accessibility event is of a type defined by a mask of
 * qualifying event types.//from  w w w  .ja va 2s  . c  o m
 *
 * @param event The event to evaluate
 * @param typeMask A mask of event types that will cause this method to
 *            accept the event as matching
 * @return {@code true} if {@code event}'s type is one of types defined in
 *         {@code typeMask}, {@code false} otherwise
 */
public static boolean eventMatchesAnyType(AccessibilityEvent event, int typeMask) {
    return event != null && (event.getEventType() & typeMask) != 0;
}

From source file:com.android.utils.AccessibilityEventUtils.java

public static boolean isCharacterTraversalEvent(AccessibilityEvent event) {
    return (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
            && event.getMovementGranularity() == AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER);
}

From source file:Main.java

/**
 * Determines if an accessibility event is of a type defined by a mask of
 * qualifying event types./*from   w  w w . ja va  2 s . c om*/
 *
 * @param event The event to evaluate
 * @param typeMask A mask of event types that will cause this method to
 *            accept the event as matching
 * @return {@code true} if {@code event}'s type is one of types defined in
 *         {@code typeMask}, {@code false} otherwise
 */
public static boolean eventMatchesAnyType(AccessibilityEvent event, int typeMask) {
    if (event == null) {
        return false;
    }

    return (event.getEventType() & typeMask) != 0;
}

From source file:Main.java

/**
 * @return If the <code>first</code> event is equal to the <code>second</code>.
 *///  ww w  . j a v a2s . c o  m
public static boolean eventEquals(AccessibilityEvent first, AccessibilityEvent second) {
    // TODO: The framework should implement AccessibilityEvent#equals()
    if (first == null || second == null) {
        return false;
    }
    if (first.getEventType() != second.getEventType()) {
        return false;
    }
    if (first.getPackageName() == null) {
        if (second.getPackageName() != null) {
            return false;
        }
    } else if (!first.getPackageName().equals(second.getPackageName())) {
        return false;
    }
    if (first.getClassName() == null) {
        if (second.getClassName() != null) {
            return false;
        }
    } else if (!first.getClassName().equals(second.getClassName())) {
        return false;
    }
    if (!first.getText().equals(second.getText())) {
        // The result of getText() is never null.
        return false;
    }
    if (first.getContentDescription() == null) {
        if (second.getContentDescription() != null) {
            return false;
        }
    } else if (!first.getContentDescription().equals(second.getContentDescription())) {
        return false;
    }
    if (first.getBeforeText() == null) {
        if (second.getBeforeText() != null) {
            return false;
        }
    } else if (!first.getBeforeText().equals(second.getBeforeText())) {
        return false;
    }
    if (first.getParcelableData() != null) {
        // Parcelable data may not implement equals() correctly.
        return false;
    }
    if (first.getAddedCount() != second.getAddedCount()) {
        return false;
    }
    if (first.isChecked() != second.isChecked()) {
        return false;
    }
    if (first.isEnabled() != second.isEnabled()) {
        return false;
    }
    if (first.getFromIndex() != second.getFromIndex()) {
        return false;
    }
    if (first.isFullScreen() != second.isFullScreen()) {
        return false;
    }
    if (first.getCurrentItemIndex() != second.getCurrentItemIndex()) {
        return false;
    }
    if (first.getItemCount() != second.getItemCount()) {
        return false;
    }
    if (first.isPassword() != second.isPassword()) {
        return false;
    }
    if (first.getRemovedCount() != second.getRemovedCount()) {
        return false;
    }
    if (first.getEventTime() != second.getEventTime()) {
        return false;
    }
    return true;
}

From source file:com.rosthouse.vibrobag.NotificationListener.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    final int eventType = event.getEventType();
    String eventText = null;/*from   w  w  w  .  ja  v  a 2s  .  c  o  m*/
    if (eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
        Notification note = (Notification) event.getParcelableData();

    }
    eventText = eventText + event.getContentDescription();
    LocalBroadcastManager.getInstance(this);

}

From source file:com.android.screenspeak.eventprocessor.ProcessorGestureVibrator.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEventCompat.TYPE_GESTURE_DETECTION_START:
        mHandler.postDelayed(mFeedbackRunnable, FEEDBACK_DELAY);
        break;/*from   w  w w.ja  v a  2  s  . c  o  m*/
    case AccessibilityEventCompat.TYPE_GESTURE_DETECTION_END:
        mHandler.removeCallbacks(mFeedbackRunnable);
        mFeedbackController.interrupt();
        break;
    }
}

From source file:com.android.talkback.controller.TextCursorControllerApp.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED) {
        processTextSelectionChange(event);
    }//from www .  ja v a  2  s  .c  o m
}

From source file:com.android.screenspeak.controller.TextCursorControllerApp.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
        processTextSelectionChange(event);
        break;/*from   ww w.  j ava  2 s  .co m*/
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        clear();
        break;
    }
}

From source file:com.android.screenspeak.formatter.LiveViewFormatter.java

@Override
public boolean accept(AccessibilityEvent event, ScreenSpeakService context) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED)
        return false;

    AccessibilityNodeInfoCompat node = new AccessibilityNodeInfoCompat(event.getSource());
    if (node.getInfo() == null) {
        return false;
    }/*from   ww w . j a  v a 2s  . co m*/

    int liveRegion = node.getLiveRegion();
    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }
}

From source file:com.android.talkback.formatter.LiveViewFormatter.java

@Override
public boolean accept(AccessibilityEvent event, TalkBackService context) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED)
        return false;

    AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    AccessibilityNodeInfoCompat node = record.getSource();
    if (node == null) {
        return false;
    }/*from   www. jav a2s  . c om*/

    int liveRegion = node.getLiveRegion();
    node.recycle();

    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }
}