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

Commit 0fa58d6c authored by Gus Prevas's avatar Gus Prevas
Browse files

Implements basic anchor-based scrolling.

This change introduces an alternate method of laying out notification
rows in StackScrollAlgorithm based on identifying an "anchor" view and
its position relative to the top of the container, then laying out the
rest of the rows outwards from there.  It also adds alternate logic to
everywhere NotificationStackScrollLayout reads or modifies the scroll
position to work with the anchor-based approach instead.  A binary flag
is introduced to toggle between the approaches.

In this change we implement the basic scrolling functionality only.
TODOs are added where functionality is missing, including:
- flinging/animated scrolling
- forced scroll/scrolling to a specific view
- clamping to window insets
- a11y scroll actions/scrolling state
- edge cases related to expanding/collapsing views above the anchor or
at the bottom of the shade

Test: atest SystemUITests, manual
Change-Id: Idd0711a7947733bd81c10feccda871b736c0578a
parent c6223792
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -538,6 +538,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
                    - getIntrinsicHeight());
        }
        float viewEnd = viewStart + fullHeight;
        // TODO: fix this check for anchor scrolling.
        if (expandingAnimated && mAmbientState.getScrollY() == 0
                && !mAmbientState.isOnKeyguard() && !iconState.isLastExpandIcon) {
            // We are expanding animated. Because we switch to a linear interpolation in this case,
+23 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ public class AmbientState {

    private ArrayList<ExpandableView> mDraggedViews = new ArrayList<>();
    private int mScrollY;
    private int mAnchorViewIndex;
    private int mAnchorViewY;
    private boolean mDimmed;
    private ActivatableNotificationView mActivatedChild;
    private float mOverScrollTopAmount;
@@ -131,6 +133,27 @@ public class AmbientState {
        this.mScrollY = scrollY;
    }

    /**
     * Index of the child view whose Y position on screen is returned by {@link #getAnchorViewY()}.
     * Other views are laid out outwards from this view in both directions.
     */
    public int getAnchorViewIndex() {
        return mAnchorViewIndex;
    }

    public void setAnchorViewIndex(int anchorViewIndex) {
        mAnchorViewIndex = anchorViewIndex;
    }

    /** Current Y position of the view at {@link #getAnchorViewIndex()}. */
    public int getAnchorViewY() {
        return mAnchorViewY;
    }

    public void setAnchorViewY(int anchorViewY) {
        mAnchorViewY = anchorViewY;
    }

    /** Call when dragging begins. */
    public void onBeginDrag(ExpandableView view) {
        mDraggedViews.add(view);