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.google.android.marvin.mytalkback.ProcessorScrollPosition.java

private void updateRecentlyExplored(AccessibilityEvent event) {
    // TODO(alanv): We track this in several places. Need to refactor.

    // We only need to track recently explored views on ICS.
    if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
            || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)) {
        return;/*from ww w. ja  va2 s .  c  o m*/
    }

    // Exploration is the result of HOVER_ENTER events.
    if (event.getEventType() != AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER) {
        return;
    }

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    final AccessibilityNodeInfoCompat node = record.getSource();

    if (mRecentlyExplored != null) {
        if (mRecentlyExplored.equals(node)) {
            return;
        }

        mRecentlyExplored.recycle();
        mRecentlyExplored = null;
    }

    if (node != null) {
        mRecentlyExplored = AccessibilityNodeInfoCompat.obtain(node);
    }
}

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

public void onAccessibilityEvent(AccessibilityEvent event) {
    if (mTestingListener != null) {
        mTestingListener.onAccessibilityEvent(event);
    }//  w  w  w.j  ava  2  s  .  c  o m

    if ((mDumpEventMask & event.getEventType()) != 0) {
        Log.v(DUMP_EVNET_LOG_TAG, event.toString());
    }

    if (shouldDropRefocusEvent(event)) {
        return;
    }

    if (shouldDropEvent(event)) {
        return;
    }

    maintainExplorationState(event);

    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
            || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
        mService.setRootDirty(true);
    }

    // We need to save the last focused event so that we can filter out related selected events.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
        if (mLastFocusedEvent != null) {
            mLastFocusedEvent.recycle();
        }

        mLastFocusedEvent = AccessibilityEvent.obtain(event);
    }

    if (AccessibilityEventUtils.eventMatchesAnyType(event, MASK_DELAYED_EVENT_TYPES)) {
        mHandler.postProcessEvent(event);
    } else {
        processEvent(event);
    }

    if (mTestingListener != null) {
        mTestingListener.afterAccessibilityEvent(event);
    }
}

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

@Override
public boolean onAccessibilityEvent(AccessibilityEvent event) {
    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
        brailleNodeFromEvent(event);//from   www . ja v  a  2  s  .com
        break;
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        brailleFocusedNode();
        break;
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        if (!brailleFocusedNode()) {
            // Since focus is typically not set in a newly opened
            // window, so braille the window as-if the first focusable
            // node had focus.  We don't update the focus because that
            // will make other services (e.g. talkback) reflect this
            // change, which is not desired.
            brailleFirstFocusableNode();
        }
        break;
    }
    return true;
}

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

@Override
public void onObserveAccessibilityEvent(AccessibilityEvent event) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null) {
        return;/*  ww w.  j av  a2 s .c o m*/
    }
    boolean isNewWindow = false;
    if (mCurrentNode == null || mCurrentNode.getWindowId() != source.getWindowId()) {
        isNewWindow = true;
    }
    int t = event.getEventType();
    boolean isInterestingEventType = false;
    if (t == AccessibilityEvent.TYPE_VIEW_SELECTED || t == AccessibilityEvent.TYPE_VIEW_FOCUSED
            || t == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            || t != AccessibilityEvent.TYPE_VIEW_HOVER_ENTER) {
        isInterestingEventType = true;
    }
    if (isNewWindow || isInterestingEventType) {
        setPendingNode(source);
    }
}

From source file:com.android.talkback.tutorial.TutorialMainFragment.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (mOffButton == null || mParentLayout == null) {
        return;//w  w  w  .j  a v a  2  s. c  o m
    }

    // There are three types of areas that we're detecting: the button area, areas of the
    // activity that are a11y-focusable, and areas of the activity that are blank.
    // 1) The HoverTrackingButton keeps track of the button area.
    // 2) The HoverTrackingLinearLayout keeps track of blank activity areas.
    // 3) We use TYPE_VIEW_HOVER_ENTER to track a11y-focusable activity areas.
    // The user must begin and end the touch interaction within the Turn TalkBack Off button
    // without moving their finger into other areas of the activity in order to turn TB off.

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
        mOtherViewHovered = false;
        mOffButton.clearTracking();
        mParentLayout.clearTracking();
        break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
        if (mOffButton.didHoverEnter() && !mParentLayout.didHoverEnter() && !mOtherViewHovered) {
            if (TalkBackService.getInstance() != null) {
                TalkBackService.getInstance().disableTalkBack();
            }
        }
        break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
        CharSequence className = event.getClassName();
        // Hovering over the button gives an event with TUTORIAL_CLASS_NAME class.
        // But empty areas of the activity should be tracked by HoverTrackingLinearLayout.
        if (className == null || !className.equals(TUTORIAL_CLASS_NAME)) {
            mOtherViewHovered = true;
        }
        break;
    }
}

From source file:com.a.mirko.android.datetimepicker.time.RadialPickerLayout.java

/**
 * Announce the currently-selected time when launched.
 *///from w ww. java2  s  .c o m
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current time will be spoken.
        event.getText().clear();
        Time time = new Time();
        time.hour = getHours();
        time.minute = getMinutes();
        long millis = time.normalize(true);
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (mIs24HourMode) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
        event.getText().add(timeString);
        return true;
    }
    return super.dispatchPopulateAccessibilityEvent(event);
}

From source file:com.example.accessibility.OverlayManager.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    // TODO Auto-generated method stub
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
        if (mFCV != null) {
            destroyFeedbackClickView(mContext);
        }/*from  w  ww.  j a v  a2s  . co  m*/
        showScrollButtons();

    }
}

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

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
        final AccessibilityNodeInfo node = event.getSource();
        if (node == null) {
            if (LogUtils.LOG_LEVEL <= Log.WARN) {
                Log.w(LOGTAG, "TYPE_VIEW_ACCESSIBILITY_FOCUSED event without a source.");
            }/* w w w  .  j  a  va2  s .co  m*/
            return;
        }

        // When a new view gets focus, clear the state of the granularity
        // manager if this event came from a different node than the locked
        // node but from the same window.
        final AccessibilityNodeInfoCompat nodeCompat = new AccessibilityNodeInfoCompat(node);
        mGranularityManager.onNodeFocused(nodeCompat);
        if (mSwitchNodeWithGranularityDirection == TraversalStrategy.SEARCH_FOCUS_FORWARD) {
            mGranularityManager.navigate(AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
        } else if (mSwitchNodeWithGranularityDirection == TraversalStrategy.SEARCH_FOCUS_BACKWARD) {
            mGranularityManager.startFromLastNode();
            mGranularityManager.navigate(AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
        }
        mSwitchNodeWithGranularityDirection = 0;
        nodeCompat.recycle();
        mReachedEdge = false;
        mGranularityNavigationReachedEdge = false;
    }
}

From source file:org.mozilla.focus.widget.InlineAutocompleteEditText.java

@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    // We need to bypass the isShown() check in the default implementation
    // for TYPE_VIEW_TEXT_SELECTION_CHANGED events so that accessibility
    // services could detect a url change.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED && getParent() != null
            && !isShown()) {//from  w  ww .  ja va2s  . co  m
        onInitializeAccessibilityEvent(event);
        dispatchPopulateAccessibilityEvent(event);
        getParent().requestSendAccessibilityEvent(this, event);
    } else {
        super.sendAccessibilityEventUnchecked(event);
    }
}

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

/**
 * Given an {@link AccessibilityEvent}, obtains and speaks a long
 * hover utterance.//  w  w w .j a  v  a  2s.  co  m
 *
 * @param event The source event.
 */
private void speakLongHover(AccessibilityEvent event) {
    // Never speak hint text if the tutorial is active
    if (AccessibilityTutorialActivity.isTutorialActive()) {
        LogUtils.log(this, Log.VERBOSE, "Dropping long hover hint speech because tutorial is active.");
        return;
    }

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    AccessibilityNodeInfoCompat source = record.getSource();

    if (source == null) {
        return;
    }

    // If this was a HOVER_ENTER event, we need to compute the focused node.
    // TODO: We're already doing this in the touch exploration formatter --
    // maybe this belongs there instead?
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER) {
        source = AccessibilityNodeInfoUtils.findFocusFromHover(mContext, source);
        if (source == null) {
            return;
        }
    }

    final CharSequence text = mRuleProcessor.getHintForNode(source);
    source.recycle();

    // Use QUEUE mode so that we don't interrupt more important messages.
    mSpeechController.speak(text, SpeechController.QUEUE_MODE_QUEUE, FeedbackItem.FLAG_NO_HISTORY, null);
}