Example usage for android.view.accessibility AccessibilityEvent getAction

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

Introduction

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

Prototype

public int getAction() 

Source Link

Document

Gets the performed action that triggered this event.

Usage

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

/**
 * Handle an event that indicates a text is being traversed at character
 * granularity.//  www  .j  a  v  a 2s .  c om
 */
private void processTraversalEvent(AccessibilityEvent event) {
    final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event);
    if (TextUtils.isEmpty(text)) {
        return;
    }

    String letter;
    if ((event.getAction() == AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY
            || event.getAction() == AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY)
            && event.getFromIndex() >= 0 && event.getFromIndex() < text.length()) {
        letter = String.valueOf(text.charAt(event.getFromIndex()));
    } else {
        return;
    }

    String phoneticLetter = getPhoneticLetter(Locale.getDefault().toString(), letter);
    if (phoneticLetter != null) {
        postPhoneticLetterRunnable(phoneticLetter);
    }
}

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

/**
 * ???/* ww  w . j av  a  2 s  .c om*/
 */
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    tag_callback_time = System.currentTimeMillis();
    int eventType = event.getEventType();

    Log.i("Info",
            " eventType: " + eventType + "   getEventTime:  " + event.getEventTime() + "     getAction"
                    + event.getAction() + "getContentChangeTypes:" + event.getContentChangeTypes()
                    + " getText :" + event.getText().toString() + "getPackageName :" + event.getPackageName()
                    + "getRecordCount : " + event.getRecordCount() + "  getClassName:" + event.getClassName()
                    + "  :" + event.getClass() + "   getParcelableData:" + event.getParcelableData());

    switch (eventType) {
    /*??*/
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        windowContentChanged();
        break;
    //???
    case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
        notificationChanged(event);
        break;
    //Activity???
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        windowChanged(event);
        break;
    }
}