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

Commit 4a1ac84e authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed several bugs regarding the state of the notifications

Fixed an issue where the last card was hidden even though there would
have been enough space to show it when it was expanded.
Also fixed an issue where the first card was not expandable when it was
the only one.
In addition the scroll range was corrected, to ensure that the last card
could always be scrolled to full visibility, which was not the case
previously when the last card was expanded.

Bug: 14376035
Change-Id: I372a55dc1fc6e381dd9aef3d631447912e3d1024
parent ae84e20b
Loading
Loading
Loading
Loading
+45 −2
Original line number Diff line number Diff line
@@ -237,6 +237,25 @@ public class NotificationStackScrollLayout extends ViewGroup
        mStackScrollAlgorithm.setTopPadding(mTopPadding);
    }

    /**
     * @return whether the height of the layout needs to be adapted, in order to ensure that the
     *         last child is not in the bottom stack.
     */
    private boolean needsHeightAdaption() {
        View lastChild = getLastChildNotGone();
        View firstChild = getFirstChildNotGone();
        boolean isLastChildExpanded = isViewExpanded(lastChild);
        return isLastChildExpanded && lastChild != firstChild;
    }

    private boolean isViewExpanded(View view) {
        if (view != null) {
            ExpandableView expandView = (ExpandableView) view;
            return expandView.getActualHeight() > mCollapsedSize;
        }
        return false;
    }

    /**
     * Updates the children views according to the stack scroll algorithm. Call this whenever
     * modifications to {@link #mOwnScrollY} are performed to reflect it in the view layout.
@@ -682,7 +701,13 @@ public class NotificationStackScrollLayout extends ViewGroup
            int firstChildMaxExpandHeight = getMaxExpandHeight(firstChild);

            scrollRange = Math.max(0, contentHeight - mMaxLayoutHeight + mBottomStackPeekSize);
            if (scrollRange > 0 && getChildCount() > 0) {
            if (scrollRange > 0) {
                View lastChild = getLastChildNotGone();
                if (isViewExpanded(lastChild)) {
                    // last child is expanded, so we have to ensure that it can exit the
                    // bottom stack
                    scrollRange += mCollapsedSize + mPaddingBetweenElements;
                }
                // We want to at least be able collapse the first item and not ending in a weird
                // end state.
                scrollRange = Math.max(scrollRange, firstChildMaxExpandHeight - mCollapsedSize);
@@ -705,6 +730,20 @@ public class NotificationStackScrollLayout extends ViewGroup
        return null;
    }

    /**
     * @return the last child which has visibility unequal to GONE
     */
    private View getLastChildNotGone() {
        int childCount = getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
            View child = getChildAt(i);
            if (child.getVisibility() != View.GONE) {
                return child;
            }
        }
        return null;
    }

    private int getMaxExpandHeight(View view) {
        if (view instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
@@ -1040,7 +1079,11 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public int getEmptyBottomMargin() {
        return Math.max(getHeight() - mContentHeight, 0);
        int emptyMargin = mMaxLayoutHeight - mContentHeight;
        if (needsHeightAdaption()) {
            emptyMargin = emptyMargin - mCollapsedSize - mBottomStackPeekSize;
        }
        return Math.max(emptyMargin, 0);
    }

    public void onExpansionStarted() {
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ public class StackScrollAlgorithm {
                clampYTranslation(childViewState, childHeight);
                // check if we are overlapping with the bottom stack
                if (childViewState.yTranslation + childHeight + mPaddingBetweenElements
                        >= bottomStackStart && !mIsExpansionChanging) {
                        >= bottomStackStart && !mIsExpansionChanging && i != 0) {
                    // TODO: handle overlapping sizes with end stack better
                    // we just collapse this element
                    childViewState.height = mCollapsedSize;