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:com.android.screenspeak.SavedNode.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
        clearCache();/*www  . j a va  2s.  c  om*/
        break;
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
        AccessibilityNodeInfo source = event.getSource();
        if (source != null) {
            AccessibilityNodeInfoCompat copyNode = new AccessibilityNodeInfoCompat(
                    AccessibilityNodeInfo.obtain(source));
            Selection selection = new Selection(event.getFromIndex(), event.getToIndex());
            mSelectionCache.put(copyNode, selection);
        }
        break;
    }
}

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

/**
 * Adds an {@link AccessibilityEvent} to the queue for processing. If this
 * addition causes the queue to exceed the maximum allowable events for an
 * event's type, earlier events of this type will be pruned from the queue.
 *
 * @param event The event to add to the queue
 */// w  w  w.  ja  va2  s.  com
public void enqueue(AccessibilityEvent event) {
    final AccessibilityEvent clone = AccessibilityEvent.obtain(event);
    final int eventType = clone.getEventType();

    if (AccessibilityEventUtils.eventMatchesAnyType(clone, MASK_LIMITED_EVENT_TYPES)) {
        final int eventCountOfType = mQualifyingEvents.get(eventType, 0);
        mQualifyingEvents.put(eventType, (eventCountOfType + 1));
    }

    mEventQueue.add(clone);
    enforceEventLimits();
}

From source file:com.android.datetimepicker.date.YearPickerView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);/*from w w  w.j  a va2  s  .  c  om*/
        AccessibilityEventCompat.asRecord(event).setToIndex(0);
    }
}

From source file:com.google.android.marvin.mytalkback.EventQueue.java

/**
 * Adds an {@link AccessibilityEvent} to the queue for processing. If this
 * addition causes the queue to exceed the maximum allowable events for an
 * event's type, earlier events of this type will be pruned from the queue.
 *
 * @param event The event to add to the queue
 *///from   w w w. j a v a2s .c  o  m
public void enqueue(AccessibilityEvent event) {
    final AccessibilityEvent clone = AccessibilityEventCompatUtils.obtain(event);
    final int eventType = clone.getEventType();

    if (AccessibilityEventUtils.eventMatchesAnyType(clone, MASK_LIMITED_EVENT_TYPES)) {
        final int eventCountOfType = mQualifyingEvents.get(eventType, 0);
        mQualifyingEvents.put(eventType, (eventCountOfType + 1));
    }

    mEventQueue.add(clone);
    enforceEventLimits();
}

From source file:com.android.screenspeak.SideTapManager.java

/**
 * Called so we can avoid detecting screen touches as side taps.
 *///from w w w.  j av a 2  s .co m
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START) {
        mLastTouchTime = System.nanoTime();
    }
}

From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java

private void checkIMEPicker(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            && "android".equals(event.getPackageName())
            && "android.app.AlertDialog".equals(event.getClassName())) {
        AccessibilityNodeInfo node = event.getSource();
        if (node == null) {
            return;
        }//  w w  w  . j  a v  a 2s .  c o m
        String IMETitle = mContext.getString(R.string.braille_ime_name);
        List<AccessibilityNodeInfo> found = node.findAccessibilityNodeInfosByText(IMETitle);
        if (found.size() == 0) {
            return;
        }
        AccessibilityNodeInfo firstFound = found.get(0);
        AccessibilityNodeInfo toFocus = firstFound.getParent();
        if (toFocus != null) {
            toFocus.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
        }
    }
}

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

/**
 * Resets cached scrollable state when touch exploration after window state
 * changes.//from   w  ww.j av a  2  s . c o  m
 */
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Reset cached scrollable state.
        mLastNodeWasScrollable = false;
        break;
    }
}

From source file:com.codetroopers.betterpickers.calendardatepicker.YearPickerView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);/*from  w w  w.  j  ava  2 s  .c  o m*/
        event.setToIndex(0);
    }
}

From source file:com.android.screenspeak.contextmenu.ListMenuManager.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED && mDeferredAction != null) {
        Handler handler = new Handler();
        handler.post(new Runnable() {
            @Override/*from   www  .j ava2 s.c om*/
            public void run() {
                if (mDeferredAction != null) {
                    mDeferredAction.run();
                    mDeferredAction = null;
                }
            }
        });
        mService.postRemoveEventListener(this);
    }
}

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

private boolean shouldIgnoreEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
    case AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
        return true;
    case AccessibilityEventCompat.TYPE_WINDOW_CONTENT_CHANGED:
    case AccessibilityEventCompat.TYPE_VIEW_SCROLLED:
        return shouldIgnoreUpdateListEvent(event);
    default:/*w w  w.  j av  a  2  s.c o  m*/
        return false;
    }
}