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

Commit 002e3cf7 authored by Qasid Ahmad Sadiq's avatar Qasid Ahmad Sadiq Committed by Qasid Sadiq
Browse files

Populate scrollX and scrollY on AccessibilityEvents.

This wasn't happening for RecyclerView, and that resulted in lost focus after scroll animations.
This is cause Talkback relies on changes in getScrollX/Y to determine if it should do anything about a TYPE_VIEW_SCROLLED AccessibilityEvent.
This squashes a big subset of "losted focus" bugs.
This is most painfully felt when you fling a RecyclerView and in ViewPager page transition, both resulting in slightly longer animations.
Also, change the default value of m[Max]Scroll[x/y] to reflect the above.

Change-Id: Ibe66260fbfc61c98ca88e1b2d9552ed116e44c15
Fix: 125385883
Test: CTSAccessibility*, Tried a few RecyclerViews on device, and ViewPager2 sample app.
parent 5ff1b20f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8273,6 +8273,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        event.setPackageName(getContext().getPackageName());
        event.setEnabled(isEnabled());
        event.setContentDescription(mContentDescription);
        event.setScrollX(getScrollX());
        event.setScrollY(getScrollY());
        switch (event.getEventType()) {
            case AccessibilityEvent.TYPE_VIEW_FOCUSED: {
+8 −8
Original line number Diff line number Diff line
@@ -90,13 +90,13 @@ public class AccessibilityRecord {
    int mItemCount = UNDEFINED;
    int mFromIndex = UNDEFINED;
    int mToIndex = UNDEFINED;
    int mScrollX = UNDEFINED;
    int mScrollY = UNDEFINED;
    int mScrollX = 0;
    int mScrollY = 0;

    int mScrollDeltaX = UNDEFINED;
    int mScrollDeltaY = UNDEFINED;
    int mMaxScrollX = UNDEFINED;
    int mMaxScrollY = UNDEFINED;
    int mMaxScrollX = 0;
    int mMaxScrollY = 0;

    int mAddedCount= UNDEFINED;
    int mRemovedCount = UNDEFINED;
@@ -878,10 +878,10 @@ public class AccessibilityRecord {
        mItemCount = UNDEFINED;
        mFromIndex = UNDEFINED;
        mToIndex = UNDEFINED;
        mScrollX = UNDEFINED;
        mScrollY = UNDEFINED;
        mMaxScrollX = UNDEFINED;
        mMaxScrollY = UNDEFINED;
        mScrollX = 0;
        mScrollY = 0;
        mMaxScrollX = 0;
        mMaxScrollY = 0;
        mAddedCount = UNDEFINED;
        mRemovedCount = UNDEFINED;
        mClassName = null;
+0 −2
Original line number Diff line number Diff line
@@ -951,8 +951,6 @@ public class HorizontalScrollView extends FrameLayout {
    public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
        super.onInitializeAccessibilityEventInternal(event);
        event.setScrollable(getScrollRange() > 0);
        event.setScrollX(mScrollX);
        event.setScrollY(mScrollY);
        event.setMaxScrollX(getScrollRange());
        event.setMaxScrollY(mScrollY);
    }
+0 −2
Original line number Diff line number Diff line
@@ -1010,8 +1010,6 @@ public class ScrollView extends FrameLayout {
        super.onInitializeAccessibilityEventInternal(event);
        final boolean scrollable = getScrollRange() > 0;
        event.setScrollable(scrollable);
        event.setScrollX(mScrollX);
        event.setScrollY(mScrollY);
        event.setMaxScrollX(mScrollX);
        event.setMaxScrollY(getScrollRange());
    }
+0 −1
Original line number Diff line number Diff line
@@ -4945,7 +4945,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
        super.onInitializeAccessibilityEventInternal(event);
        event.setScrollable(mScrollable);
        event.setScrollX(mScrollX);
        event.setMaxScrollX(mScrollX);
        if (ANCHOR_SCROLLING) {
            // TODO