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

Commit c7873d1d authored by Lyn Han's avatar Lyn Han
Browse files

Remove anchor scrolling

Fixes: 175336550
Test: manual, no regressions
Change-Id: Ie262e9023cb1a51d449ea3a74867dbd4798d1a41
parent 2928df12
Loading
Loading
Loading
Loading
+0 −23
Original line number Original line Diff line number Diff line
@@ -42,8 +42,6 @@ public class AmbientState {


    private final SectionProvider mSectionProvider;
    private final SectionProvider mSectionProvider;
    private int mScrollY;
    private int mScrollY;
    private int mAnchorViewIndex;
    private int mAnchorViewY;
    private boolean mDimmed;
    private boolean mDimmed;
    private ActivatableNotificationView mActivatedChild;
    private ActivatableNotificationView mActivatedChild;
    private float mOverScrollTopAmount;
    private float mOverScrollTopAmount;
@@ -139,27 +137,6 @@ public class AmbientState {
        this.mScrollY = scrollY;
        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;
    }

    /**
    /**
     * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are
     * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are
     *               translucent and everything is scaled back a bit.
     *               translucent and everything is scaled back a bit.
+168 −632

File changed.

Preview size limit exceeded, changes collapsed.

+8 −49
Original line number Original line Diff line number Diff line
@@ -45,8 +45,6 @@ import java.util.List;
 */
 */
public class StackScrollAlgorithm {
public class StackScrollAlgorithm {


    static final boolean ANCHOR_SCROLLING = false;

    private static final String LOG_TAG = "StackScrollAlgorithm";
    private static final String LOG_TAG = "StackScrollAlgorithm";
    private final ViewGroup mHostView;
    private final ViewGroup mHostView;


@@ -229,10 +227,6 @@ public class StackScrollAlgorithm {
        scrollY = Math.max(0, scrollY);
        scrollY = Math.max(0, scrollY);
        state.scrollY = (int) (scrollY + bottomOverScroll);
        state.scrollY = (int) (scrollY + bottomOverScroll);


        if (ANCHOR_SCROLLING) {
            state.anchorViewY = (int) (ambientState.getAnchorViewY() - bottomOverScroll);
        }

        //now init the visible children and update paddings
        //now init the visible children and update paddings
        int childCount = hostView.getChildCount();
        int childCount = hostView.getChildCount();
        state.visibleChildren.clear();
        state.visibleChildren.clear();
@@ -240,11 +234,6 @@ public class StackScrollAlgorithm {
        int notGoneIndex = 0;
        int notGoneIndex = 0;
        ExpandableView lastView = null;
        ExpandableView lastView = null;
        for (int i = 0; i < childCount; i++) {
        for (int i = 0; i < childCount; i++) {
            if (ANCHOR_SCROLLING) {
                if (i == ambientState.getAnchorViewIndex()) {
                    state.anchorViewIndex = state.visibleChildren.size();
                }
            }
            ExpandableView v = (ExpandableView) hostView.getChildAt(i);
            ExpandableView v = (ExpandableView) hostView.getChildAt(i);
            if (v.getVisibility() != View.GONE) {
            if (v.getVisibility() != View.GONE) {
                if (v == ambientState.getShelf()) {
                if (v == ambientState.getShelf()) {
@@ -293,19 +282,6 @@ public class StackScrollAlgorithm {
     */
     */
    private void updatePositionsForState(StackScrollAlgorithmState algorithmState,
    private void updatePositionsForState(StackScrollAlgorithmState algorithmState,
            AmbientState ambientState) {
            AmbientState ambientState) {
        if (ANCHOR_SCROLLING) {
            float currentYPosition = algorithmState.anchorViewY;
            int childCount = algorithmState.visibleChildren.size();
            for (int i = algorithmState.anchorViewIndex; i < childCount; i++) {
                currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition,
                        false /* reverse */);
            }
            currentYPosition = algorithmState.anchorViewY;
            for (int i = algorithmState.anchorViewIndex - 1; i >= 0; i--) {
                currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition,
                        true /* reverse */);
            }
        } else {
        // The y coordinate of the current child.
        // The y coordinate of the current child.
        float currentYPosition = -algorithmState.scrollY;
        float currentYPosition = -algorithmState.scrollY;
        int childCount = algorithmState.visibleChildren.size();
        int childCount = algorithmState.visibleChildren.size();
@@ -314,7 +290,6 @@ public class StackScrollAlgorithm {
                    false /* reverse */);
                    false /* reverse */);
        }
        }
    }
    }
    }


    /**
    /**
     * Populates the {@link ExpandableViewState} for a single child.
     * Populates the {@link ExpandableViewState} for a single child.
@@ -343,7 +318,7 @@ public class StackScrollAlgorithm {
        ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null;
        ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null;
        final boolean applyGapHeight =
        final boolean applyGapHeight =
                childNeedsGapHeight(
                childNeedsGapHeight(
                        ambientState.getSectionProvider(), algorithmState.anchorViewIndex, i,
                        ambientState.getSectionProvider(), i,
                        child, previousChild);
                        child, previousChild);
        ExpandableViewState childViewState = child.getViewState();
        ExpandableViewState childViewState = child.getViewState();
        childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;
        childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;
@@ -409,7 +384,6 @@ public class StackScrollAlgorithm {
     * Get the gap height needed for before a view
     * Get the gap height needed for before a view
     *
     *
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
     * @param visibleIndex the visible index of this view in the list
     * @param visibleIndex the visible index of this view in the list
     * @param child the child asked about
     * @param child the child asked about
     * @param previousChild the child right before it or null if none
     * @param previousChild the child right before it or null if none
@@ -417,12 +391,11 @@ public class StackScrollAlgorithm {
     */
     */
    public float getGapHeightForChild(
    public float getGapHeightForChild(
            SectionProvider sectionProvider,
            SectionProvider sectionProvider,
            int anchorViewIndex,
            int visibleIndex,
            int visibleIndex,
            View child,
            View child,
            View previousChild) {
            View previousChild) {


        if (childNeedsGapHeight(sectionProvider, anchorViewIndex, visibleIndex, child,
        if (childNeedsGapHeight(sectionProvider, visibleIndex, child,
                previousChild)) {
                previousChild)) {
            return mGapHeight;
            return mGapHeight;
        } else {
        } else {
@@ -434,7 +407,6 @@ public class StackScrollAlgorithm {
     * Does a given child need a gap, i.e spacing before a view?
     * Does a given child need a gap, i.e spacing before a view?
     *
     *
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param sectionProvider the sectionProvider used to understand the sections
     * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
     * @param visibleIndex the visible index of this view in the list
     * @param visibleIndex the visible index of this view in the list
     * @param child the child asked about
     * @param child the child asked about
     * @param previousChild the child right before it or null if none
     * @param previousChild the child right before it or null if none
@@ -442,16 +414,12 @@ public class StackScrollAlgorithm {
     */
     */
    private boolean childNeedsGapHeight(
    private boolean childNeedsGapHeight(
            SectionProvider sectionProvider,
            SectionProvider sectionProvider,
            int anchorViewIndex,
            int visibleIndex,
            int visibleIndex,
            View child,
            View child,
            View previousChild) {
            View previousChild) {


        boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild)
        boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild)
                && visibleIndex > 0;
                && visibleIndex > 0;
        if (ANCHOR_SCROLLING) {
            needsGapHeight &= visibleIndex != anchorViewIndex;
        }
        return needsGapHeight;
        return needsGapHeight;
    }
    }


@@ -537,7 +505,6 @@ public class StackScrollAlgorithm {
                // To check if the row need to do translation according to scroll Y
                // To check if the row need to do translation according to scroll Y
                // heads up show full of row's content and any scroll y indicate that the
                // heads up show full of row's content and any scroll y indicate that the
                // translationY need to move up the HUN.
                // translationY need to move up the HUN.
                // TODO: fix this check for anchor scrolling.
                if (!mIsExpanded && isTopEntry && ambientState.getScrollY() > 0) {
                if (!mIsExpanded && isTopEntry && ambientState.getScrollY() > 0) {
                    childState.yTranslation -= ambientState.getScrollY();
                    childState.yTranslation -= ambientState.getScrollY();
                }
                }
@@ -701,14 +668,6 @@ public class StackScrollAlgorithm {
         */
         */
        public int scrollY;
        public int scrollY;


        /** The index of the anchor view (anchor scrolling). */
        public int anchorViewIndex;

        /**
         * The Y position, relative to the top of the screen, of the anchor view (anchor scrolling).
         */
        public int anchorViewY;

        /**
        /**
         * The children from the host view which are not gone.
         * The children from the host view which are not gone.
         */
         */