Example usage for android.view.accessibility AccessibilityEvent TYPE_VIEW_SCROLLED

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

Introduction

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

Prototype

int TYPE_VIEW_SCROLLED

To view the source code for android.view.accessibility AccessibilityEvent TYPE_VIEW_SCROLLED.

Click Source Link

Document

Represents the event of scrolling a view.

Usage

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

public static int[] getAllEventTypes() {
    return new int[] { AccessibilityEvent.TYPE_ANNOUNCEMENT, AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
            AccessibilityEvent.TYPE_GESTURE_DETECTION_END, AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
            AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
            AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
            AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
            AccessibilityEvent.TYPE_TOUCH_INTERACTION_END, AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, AccessibilityEvent.TYPE_VIEW_CLICKED,
            AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED, AccessibilityEvent.TYPE_VIEW_FOCUSED,
            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
            AccessibilityEvent.TYPE_VIEW_LONG_CLICKED, AccessibilityEvent.TYPE_VIEW_SCROLLED,
            AccessibilityEvent.TYPE_VIEW_SELECTED, AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
            AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
            AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
            AccessibilityEvent.TYPE_WINDOWS_CHANGED, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
            AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED };
}

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

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (shouldIgnoreEvent(event)) {
        return;//from  w w w  . j  a  va2 s  . c o  m
    }

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Window state changes clear the cache.
        mCachedFromValues.clear();
        mCachedItemCounts.clear();
        mHandler.cancelScrollFeedback();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        mHandler.postScrollFeedback(event);
        break;
    }
}

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

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    updateRecentlyExplored(event);//from www  .ja  v a 2s . c  o m

    if (shouldIgnoreEvent(event)) {
        return;
    }

    mHandler.cancelSeekFeedback();
    mHandler.cancelScrollFeedback();

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Window state changes clear the cache.
        mCachedFromValues.clear();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
        mHandler.postScrollFeedback(event);
        break;
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
        // SeekBars incorrectly send TYPE_VIEW_SELECTED events (verified
        // up to 4.1.2).
        if (AccessibilityEventUtils.eventMatchesClass(mContext, event,
                android.widget.SeekBar.class.getName())) {
            mHandler.postSeekFeedback(event);
        }
        break;
    }
}

From source file:com.android.screenspeak.tutorial.TutorialModule.java

/**
 * Constructs a new tutorial module for the given tutorial activity context
 * with the specified layout and title./*w  ww. jav  a2 s.  c  o  m*/
 *
 * @param parentTutorial The tutorial activity containing this module.
 * @param layoutResId The resource identifier for this module's layout.
 * @param titleResId The resource identifier for this module's title string.
 */
TutorialModule(AccessibilityTutorialActivity parentTutorial, int layoutResId, int titleResId) {
    super(parentTutorial);

    mParentTutorial = parentTutorial;
    mTitleResId = titleResId;

    final LayoutInflater inflater = mParentTutorial.getLayoutInflater();
    final View container = inflater.inflate(R.layout.tutorial_container, this, true);

    mInstructions = (TextView) container.findViewById(R.id.instructions);
    mSkip = (Button) container.findViewById(R.id.skip_button);
    mSkip.setOnClickListener(this);
    mBack = (Button) container.findViewById(R.id.back_button);
    mBack.setOnClickListener(this);
    mNext = (Button) container.findViewById(R.id.next_button);
    mNext.setOnClickListener(this);
    mFinish = (Button) container.findViewById(R.id.finish_button);
    mFinish.setOnClickListener(this);

    final TextView title = (TextView) container.findViewById(R.id.title);

    if (title != null) {
        title.setText(titleResId);
    }

    if (layoutResId != -1) {
        final ViewGroup contentHolder = (ViewGroup) container.findViewById(R.id.content);

        // Inflate the tutorial module content while dropping certain accessibility events
        // A delegate used to drop accessibility events related to AbsListView's
        // inflation of module content.
        contentHolder.setAccessibilityDelegate(new AccessibilityDelegate() {
            @Override
            public boolean onRequestSendAccessibilityEvent(@NonNull ViewGroup host, View child,
                    AccessibilityEvent event) {
                return event.getEventType() != AccessibilityEvent.TYPE_VIEW_SCROLLED
                        && super.onRequestSendAccessibilityEvent(host, child, event);

            }
        });
        inflater.inflate(layoutResId, contentHolder, true);
        contentHolder.setAccessibilityDelegate(null);
    }
}

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 .  jav  a2 s .  c o  m*/
        AccessibilityEventCompat.asRecord(event).setToIndex(0);
    }
}

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  . ja va2 s .c om
        event.setToIndex(0);
    }
}

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

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (!mAccessibilityManager.isTouchExplorationEnabled()) {
        // Don't manage focus when touch exploration is disabled.
        return;/*from   w w w.ja  v  a2  s  .c om*/
    }

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
        // Prevent conflicts between lift-to-type and single tap. This
        // is only necessary when a CLICKED event occurs during a touch
        // interaction sequence (e.g. before an INTERACTION_END event),
        // but it isn't harmful to call more often.
        cancelSingleTap();
        break;
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
        setFocusFromViewFocused(event, record);
        break;
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
        setFocusFromViewSelected(event, record);
        break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
        setFocusFromViewHoverEnter(record);
        break;
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        handleWindowStateChange(event);
        break;
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        handleWindowContentChanged(record);
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
        handleViewScrolled(event, record);
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionStart(event);
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionEnd(event);
        break;
    }
}

From source file:com.google.android.marvin.talkback.ProcessorFocusAndSingleTap.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (!mAccessibilityManager.isTouchExplorationEnabled()) {
        // Don't manage focus when touch exploration is disabled.
        return;//from  ww w. j a  v a 2  s . c  o  m
    }

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
        // Prevent conflicts between lift-to-type and single tap. This
        // is only necessary when a CLICKED event occurs during a touch
        // interaction sequence (e.g. before an INTERACTION_END event),
        // but it isn't harmful to call more often.
        cancelSingleTap();
        break;
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
        setFocusFromViewFocused(event, record);
        break;
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
        setFocusFromViewSelected(event, record);
        break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
        final AccessibilityNodeInfoCompat touchedNode = record.getSource();
        try {
            if ((touchedNode != null) && !setFocusFromViewHoverEnter(touchedNode) && FEATURE_FLAG_EMPTY_SPACE) {
                mHandler.sendEmptyTouchAreaFeedbackDelayed(touchedNode);
            }
        } finally {
            AccessibilityNodeInfoUtils.recycleNodes(touchedNode);
        }

        break;
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
        mHandler.cancelEmptyTouchAreaFeedback();
        break;
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        handleWindowStateChange(event);
        break;
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        handleWindowContentChanged(record);
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
        handleViewScrolled(event, record);
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionStart(event);
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionEnd(event);
        break;
    }
}

From source file:com.tr4android.support.extension.picker.date.YearPickerView.java

/** @hide */
@Override//  w  w w  .  j  av  a2 s.c o  m
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);

    // There are a bunch of years, so don't bother.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        AccessibilityEventCompat.asRecord(event).setFromIndex(0);
        AccessibilityEventCompat.asRecord(event).setToIndex(0);
    }
}

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

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (!mAccessibilityManager.isTouchExplorationEnabled()) {
        // Don't manage focus when touch exploration is disabled.
        return;//from  www.j av  a  2s.c o m
    }

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
        // Prevent conflicts between lift-to-type and single tap. This
        // is only necessary when a CLICKED event occurs during a touch
        // interaction sequence (e.g. before an INTERACTION_END event),
        // but it isn't harmful to call more often.
        cancelSingleTap();
        break;
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
        if (!mFirstWindowFocusManager.shouldProcessFocusEvent(event)) {
            return;
        }
        boolean isViewFocusedEvent = (AccessibilityEvent.TYPE_VIEW_FOCUSED == event.getEventType());
        if (!setFocusOnView(record, isViewFocusedEvent)) {
            // It is possible that the only speakable child of source node is invisible
            // at the moment, but could be made visible when view scrolls, or window state
            // changes. Cache it now. And try to focus on the cached record on:
            // VIEW_SCROLLED, WINDOW_CONTENT_CHANGED, WINDOW_STATE_CHANGED.
            // The above 3 are the events that could affect view visibility.
            if (mCachedPotentiallyFocusableRecordQueue.size() == MAX_CACHED_FOCUSED_RECORD_QUEUE) {
                mCachedPotentiallyFocusableRecordQueue.remove().first.recycle();
            }

            mCachedPotentiallyFocusableRecordQueue
                    .add(new Pair<>(AccessibilityRecordCompat.obtain(record), event.getEventType()));
        } else {
            emptyCachedPotentialFocusQueue();
        }
        break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
        final AccessibilityNodeInfoCompat touchedNode = record.getSource();
        try {
            if ((touchedNode != null) && !setFocusFromViewHoverEnter(touchedNode)) {
                mHandler.sendEmptyTouchAreaFeedbackDelayed(touchedNode);
            }
        } finally {
            AccessibilityNodeInfoUtils.recycleNodes(touchedNode);
        }

        break;
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
        mHandler.cancelEmptyTouchAreaFeedback();
        AccessibilityNodeInfo source = event.getSource();
        if (source != null) {
            AccessibilityNodeInfoCompat compatSource = new AccessibilityNodeInfoCompat(source);
            mLastFocusedItem = AccessibilityNodeInfoCompat.obtain(compatSource);
        }
        break;
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        mFirstWindowFocusManager.registerWindowChange(event);
        handleWindowStateChange(event);
        break;
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        handleWindowContentChanged();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
        handleViewScrolled(event, record);
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionStart();
        break;
    case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END:
        // This event type only exists on API 17+ (JB MR1).
        handleTouchInteractionEnd();
        break;
    }
}