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

Commit 068ddf7b authored by Zhen Zhang's avatar Zhen Zhang
Browse files

Scroll the hiding page to top on tab changed in sharesheet

After the tab changed, ResolverDrawerLayout will lose reference of the
hidden page which can cause the page not able to scoll back to top.
Automatically scroll on tab changed to avoid that situation.

Bug: 160886554
Test: manually test; atest ChooserActivityTest; atest
ResolverActivityTest

Change-Id: I1a8ba72f6b1dcb9bca19262b97983788001d715b
parent 83d9908e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3134,6 +3134,7 @@ public class ChooserActivity extends ResolverActivity implements
        // ends up disabled. That's because at some point the old tab's vertical scrolling is
        // disabled and the new tab's is enabled. For context, see b/159997845
        setVerticalScrollEnabled(true);
        mResolverDrawerLayout.scrollNestedScrollableChildBackToTop();
    }

    @Override
+12 −5
Original line number Diff line number Diff line
@@ -464,11 +464,7 @@ public class ResolverDrawerLayout extends ViewGroup {
                            smoothScrollTo(mCollapsibleHeight + mUncollapsibleHeight, yvel);
                            mDismissOnScrollerFinished = true;
                        } else {
                            if (isNestedListChildScrolled()) {
                                mNestedListChild.smoothScrollToPosition(0);
                            } else if (isNestedRecyclerChildScrolled()) {
                                mNestedRecyclerChild.smoothScrollToPosition(0);
                            }
                            scrollNestedScrollableChildBackToTop();
                            smoothScrollTo(yvel < 0 ? 0 : mCollapsibleHeight, yvel);
                        }
                    }
@@ -493,6 +489,17 @@ public class ResolverDrawerLayout extends ViewGroup {
        return handled;
    }

    /**
     * Scroll nested scrollable child back to top if it has been scrolled.
     */
    public void scrollNestedScrollableChildBackToTop() {
        if (isNestedListChildScrolled()) {
            mNestedListChild.smoothScrollToPosition(0);
        } else if (isNestedRecyclerChildScrolled()) {
            mNestedRecyclerChild.smoothScrollToPosition(0);
        }
    }

    private void onSecondaryPointerUp(MotionEvent ev) {
        final int pointerIndex = ev.getActionIndex();
        final int pointerId = ev.getPointerId(pointerIndex);