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

Commit 7efe495c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Notif redesign] Fix group header motion on tap" into main

parents 70353cb3 7efbff35
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -183,6 +183,12 @@ public class NotificationHeaderView extends RelativeLayout {

    /**
     * Center top line  and expand button vertically.
     * Note that this is primarily only used as a remotable method to ensure the correct initial
     * state of the RemoteView. For further updating the position after the RemoteView has been
     * created, we directly apply a translation obtained from
     * {@link NotificationHeaderView#getTopLineTranslation()} and
     * {@link NotificationHeaderView#getExpandButtonTranslation()} to the corresponding children, in
     * order to have a smoother transition.
     */
    @RemotableViewMethod
    public void centerTopLine(boolean center) {
+19 −6
Original line number Diff line number Diff line
@@ -834,7 +834,7 @@ public class NotificationChildrenContainer extends ViewGroup
        int firstOverflowIndex = lastVisibleIndex + 1;
        float expandFactor = 0;
        boolean expandingToExpandedGroup = mUserLocked && !showingAsLowPriority();
        if (mUserLocked) {
        if (notificationsRedesignTemplates() || mUserLocked) {
            expandFactor = getGroupExpandFraction();
            firstOverflowIndex = getMaxAllowedVisibleChildren(true /* likeCollapsed */);
        }
@@ -1198,11 +1198,24 @@ public class NotificationChildrenContainer extends ViewGroup
            }
            mGroupOverFlowState.animateTo(mOverflowNumber, properties);
        }
        if (mGroupHeader != null && mHeaderViewState != null) {
        if (mGroupHeader != null) {
            if (mHeaderViewState != null) {
                // TODO(389839492): For Groups in Bundles mGroupHeader might be initialized
                //  but mHeaderViewState is null.
                mHeaderViewState.applyToView(mGroupHeader);
            }

            // Only apply the special viewState for the header's children if we're not currently
            // showing the minimized header.
            if (notificationsRedesignTemplates() && !showingAsLowPriority()) {
                if (mTopLineViewState != null) {
                    mTopLineViewState.applyToView(mGroupHeader.getTopLineView());
                }
                if (mExpandButtonViewState != null) {
                    mExpandButtonViewState.applyToView(mGroupHeader.getExpandButton());
                }
            }
        }
        updateChildrenClipping();
    }

@@ -1433,7 +1446,7 @@ public class NotificationChildrenContainer extends ViewGroup
    }

    public void setActualHeight(int actualHeight) {
        if (!mUserLocked) {
        if (!notificationsRedesignTemplates() && !mUserLocked) {
            return;
        }
        mActualHeight = actualHeight;
+0 −33
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.notification.stack;

import static android.app.Flags.notificationsRedesignTemplates;
import static android.os.Trace.TRACE_TAG_APP;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_UP;
@@ -69,7 +68,6 @@ import android.view.DisplayCutout;
import android.view.InputDevice;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.NotificationHeaderView;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
@@ -6864,41 +6862,10 @@ public class NotificationStackScrollLayout

        changedRow.setChildrenExpanded(expanded);
        onChildHeightChanged(changedRow, false /* needsAnimation */);
        updateGroupHeaderAlignment(changedRow, expanded);

        runAfterAnimationFinished(changedRow::onFinishedExpansionChange);
    }

    private void updateGroupHeaderAlignment(ExpandableNotificationRow row, boolean expanded) {
        if (!notificationsRedesignTemplates()) {
            return;
        }

        NotificationChildrenContainer childrenContainer = row.getChildrenContainer();
        if (childrenContainer == null) {
            Log.wtf(TAG, "Tried to update group header alignment for something that's "
                    + "not a group; key = " + row.getKey());
            return;
        }
        NotificationHeaderView header = childrenContainer.getGroupHeader();
        if (header != null) {
            resetYTranslation(header.getTopLineView());
            resetYTranslation(header.getExpandButton());
            header.centerTopLine(expanded);
        }
    }

    /**
     * Reset the y translation of the {@code view} via the {@link ViewState}, to ensure that the
     * animation state is updated correctly.
     */
    private static void resetYTranslation(View view) {
        ViewState viewState = new ViewState();
        viewState.initFrom(view);
        viewState.setYTranslation(0);
        viewState.applyToView(view);
    }

    private final ExpandHelper.Callback mExpandHelperCallback = new ExpandHelper.Callback() {
        @Override
        public ExpandableView getChildAtPosition(float touchX, float touchY) {