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

Commit 4a579676 authored by Adrian Roos's avatar Adrian Roos
Browse files

NotificationStackScroller: Fix scrollTo for notification groups

Change-Id: Iab101d7583e9849809058c96f0c480ea9b5cc0f5
Fixes: 28936844
parent 38b5946f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1486,6 +1486,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        updateBackground();
    }

    public int getPositionOfChild(ExpandableNotificationRow childRow) {
        if (mIsSummaryWithChildren) {
            return mChildrenContainer.getPositionInLinearLayout(childRow);
        }
        return 0;
    }

    public void setExpansionLogger(ExpansionLogger logger, String key) {
        mLogger = logger;
        mLoggingKey = key;
+8 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto;
import com.android.systemui.R;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.stack.ScrollContainer;
@@ -284,11 +285,17 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene

    private void findScrollContainer() {
        if (mScrollContainer == null) {
            mScrollContainerChild = null;
            ViewParent p = this;
            while (p != null) {
                if (mScrollContainerChild == null && p instanceof ExpandableView) {
                    mScrollContainerChild = (View) p;
                }
                if (p.getParent() instanceof ScrollContainer) {
                    mScrollContainer = (ScrollContainer) p.getParent();
                    if (mScrollContainerChild == null) {
                        mScrollContainerChild = (View) p;
                    }
                    break;
                }
                p = p.getParent();
+23 −0
Original line number Diff line number Diff line
@@ -677,6 +677,10 @@ public class NotificationChildrenContainer extends ViewGroup {
        mHeaderUtil = new NotificationHeaderUtil(mNotificationParent);
    }

    public ExpandableNotificationRow getNotificationParent() {
        return mNotificationParent;
    }

    public NotificationHeaderView getHeaderView() {
        return mNotificationHeader;
    }
@@ -854,4 +858,23 @@ public class NotificationChildrenContainer extends ViewGroup {
            child.setRemoved();
        }
    }

    public int getPositionInLinearLayout(View childInGroup) {
        int position = mNotificationHeaderMargin + mNotificatonTopPadding;

        for (int i = 0; i < mChildren.size(); i++) {
            ExpandableNotificationRow child = mChildren.get(i);
            boolean notGone = child.getVisibility() != View.GONE;
            if (notGone) {
                position += mDividerHeight;
            }
            if (child == childInGroup) {
                return position;
            }
            if (notGone) {
                position += child.getIntrinsicHeight();
            }
        }
        return 0;
    }
}
+28 −5
Original line number Diff line number Diff line
@@ -610,9 +610,13 @@ public class NotificationStackScrollLayout extends ViewGroup
            ExpandableView expandableView = (ExpandableView) mForcedScroll;
            int positionInLinearLayout = getPositionInLinearLayout(expandableView);
            int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
            int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();

            targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange()));
            if (mOwnScrollY < targetScroll || positionInLinearLayout < mOwnScrollY) {

            // Only apply the scroll if we're scrolling the view upwards, or the view is so far up
            // that it is not visible anymore.
            if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
                mOwnScrollY = targetScroll;
            }
        }
@@ -1032,9 +1036,13 @@ public class NotificationStackScrollLayout extends ViewGroup
    @Override
    public boolean scrollTo(View v) {
        ExpandableView expandableView = (ExpandableView) v;
        int targetScroll = targetScrollForView(expandableView, getPositionInLinearLayout(v));
        int positionInLinearLayout = getPositionInLinearLayout(v);
        int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
        int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();

        if (mOwnScrollY < targetScroll) {
        // Only apply the scroll if we're scrolling the view upwards, or the view is so far up
        // that it is not visible anymore.
        if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
            mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY);
            mDontReportNextOverScroll = true;
            postInvalidateOnAnimation();
@@ -1062,6 +1070,10 @@ public class NotificationStackScrollLayout extends ViewGroup
            // animating away. To work around that we'll wait until things have settled.
            removeCallbacks(mReclamp);
            postDelayed(mReclamp, 50);
        } else if (mForcedScroll != null) {
            // The scroll was requested before we got the actual inset - in case we need
            // to scroll up some more do so now.
            scrollTo(mForcedScroll);
        }
        return insets;
    }
@@ -2361,7 +2373,15 @@ public class NotificationStackScrollLayout extends ViewGroup
        return view.getHeight();
    }

    private int getPositionInLinearLayout(View requestedChild) {
    private int getPositionInLinearLayout(View requestedView) {
        ExpandableNotificationRow childInGroup = null;
        ExpandableNotificationRow requestedRow = null;
        if (isChildInGroup(requestedView)) {
            // We're asking for a child in a group. Calculate the position of the parent first,
            // then within the parent.
            childInGroup = (ExpandableNotificationRow) requestedView;
            requestedView = requestedRow = childInGroup.getNotificationParent();
        }
        int position = 0;
        float previousIncreasedAmount = 0.0f;
        for (int i = 0; i < getChildCount(); i++) {
@@ -2377,7 +2397,10 @@ public class NotificationStackScrollLayout extends ViewGroup
                }
                previousIncreasedAmount = increasedPaddingAmount;
            }
            if (child == requestedChild) {
            if (child == requestedView) {
                if (requestedRow != null) {
                    position += requestedRow.getPositionOfChild(childInGroup);
                }
                return position;
            }
            if (notGone) {