Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7abaecc3 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Removing firing of spurious scroll accesibility events."

parents 2c44b922 4e03f591
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -628,6 +628,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    private int mGlowPaddingLeft;
    private int mGlowPaddingRight;

    private int mLastAccessibilityScrollEventFromIndex;
    private int mLastAccessibilityScrollEventToIndex;

    /**
     * Interface definition for a callback to be invoked when the list or grid
     * has been scrolled.
@@ -1264,6 +1267,24 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        info.setScrollable(true);
    }

    @Override
    public void sendAccessibilityEvent(int eventType) {
        // Since this class calls onScrollChanged even if the mFirstPosition and the
        // child count have not changed we will avoid sending duplicate accessibility
        // events.
        if (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
            final int lastPosition = mFirstPosition + getChildCount();
            if (mLastAccessibilityScrollEventFromIndex == mFirstPosition
                    && mLastAccessibilityScrollEventToIndex == lastPosition) {
                return;   
            } else {
                mLastAccessibilityScrollEventFromIndex = mFirstPosition;
                mLastAccessibilityScrollEventToIndex = lastPosition;       
            }
        }
        super.sendAccessibilityEvent(eventType);
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
+11 −0
Original line number Diff line number Diff line
@@ -8449,6 +8449,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        info.setPassword(isPassword);
    }

    @Override
    public void sendAccessibilityEvent(int eventType) {
        // Do not send scroll events since first they are not interesting for
        // accessibility and second such events a generated too frequently.
        // For details see the implementation of bringTextIntoView().
        if (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
            return;
        }
        super.sendAccessibilityEvent(eventType);
    }

    void sendAccessibilityEventTypeViewTextChanged(CharSequence beforeText,
            int fromIndex, int removedCount, int addedCount) {
        AccessibilityEvent event =