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

Commit 54ef7be3 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the contentHeight was calculated wrongly

We adjusted the algorithm to include gaps before certain views
but never updated the contentHeight of the layout.
Those minor differences could lead to issues where a user couldn't
see the clear all in certain cases or where the expansion would
jump.

Fixes: 153321587
Test: add notification with 2 min priority notifications, expand, observe no flickering at the end
Change-Id: Iebf6493136b8c7784e41ab27891ffd225aa0fd54
parent 9ff1bda3
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2452,7 +2452,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        int numShownItems = 0;
        boolean finish = false;
        int maxDisplayedNotifications = mMaxDisplayedNotifications;

        ExpandableView previousView = null;
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView expandableView = (ExpandableView) getChildAt(i);
            boolean footerViewOnLockScreen = expandableView == mFooterView && onKeyguard();
@@ -2493,9 +2493,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                if (height != 0) {
                    height += padding;
                }
                height += mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager,
                        mAmbientState.getAnchorViewIndex(), numShownItems, expandableView,
                        previousView);
                previousPaddingAmount = increasedPaddingAmount;
                height += expandableView.getIntrinsicHeight();
                numShownItems++;
                previousView = expandableView;
                if (finish) {
                    break;
                }
+39 −3
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ public class StackScrollAlgorithm {
        ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null;
        final boolean applyGapHeight =
                childNeedsGapHeight(
                        ambientState.getSectionProvider(), algorithmState, i, child, previousChild);
                        ambientState.getSectionProvider(), algorithmState.anchorViewIndex, i,
                        child, previousChild);
        ExpandableViewState childViewState = child.getViewState();
        childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;

@@ -463,9 +464,44 @@ public class StackScrollAlgorithm {
        return currentYPosition;
    }

    /**
     * Get the gap height needed for before a view
     *
     * @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 child the child asked about
     * @param previousChild the child right before it or null if none
     * @return the size of the gap needed or 0 if none is needed
     */
    public float getGapHeightForChild(
            SectionProvider sectionProvider,
            int anchorViewIndex,
            int visibleIndex,
            View child,
            View previousChild) {

        if (childNeedsGapHeight(sectionProvider, anchorViewIndex, visibleIndex, child,
                previousChild)) {
            return mGapHeight;
        } else {
            return 0;
        }
    }

    /**
     * Does a given child need a gap, i.e spacing before a view?
     *
     * @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 child the child asked about
     * @param previousChild the child right before it or null if none
     * @return if the child needs a gap height
     */
    private boolean childNeedsGapHeight(
            SectionProvider sectionProvider,
            StackScrollAlgorithmState algorithmState,
            int anchorViewIndex,
            int visibleIndex,
            View child,
            View previousChild) {
@@ -473,7 +509,7 @@ public class StackScrollAlgorithm {
        boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild)
                && visibleIndex > 0;
        if (ANCHOR_SCROLLING) {
            needsGapHeight &= visibleIndex != algorithmState.anchorViewIndex;
            needsGapHeight &= visibleIndex != anchorViewIndex;
        }
        return needsGapHeight;
    }