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

Commit c25989eb authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed the launch animation for groups

Also fixed various bugs when the notification
was clipped in the beginning.

Bug: 72997506
Test: add group, click on group child
Change-Id: I30c76f2a86838fbeee1c6e6adb88dc9f4f4be0c4
parent ed64a14c
Loading
Loading
Loading
Loading
+77 −17
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private AboveShelfChangedListener mAboveShelfChangedListener;
    private HeadsUpManager mHeadsUpManager;
    private View mHelperButton;
    private boolean mChildIsExpanding;

    private boolean mJustClicked;
    private boolean mIconAnimationRunning;
@@ -574,8 +575,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * @param isChildInGroup Is this notification now in a group
     * @param parent the new parent notification
     */
    public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {;
    public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {
        boolean childInGroup = StatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup;
        if (mExpandAnimationRunning && !isChildInGroup && mNotificationParent != null) {
            mNotificationParent.setChildIsExpanding(false);
            mNotificationParent.setExtraWidthForClipping(0.0f);
            mNotificationParent.setMinimumHeightForClipping(0);
        }
        mNotificationParent = childInGroup ? parent : null;
        mPrivateLayout.setIsChildInGroup(childInGroup);
        mNotificationInflater.setIsChildInGroup(childInGroup);
@@ -650,10 +656,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                visualStabilityManager, callback);
    }

    public void getChildrenStates(StackScrollState resultState) {
    public void getChildrenStates(StackScrollState resultState,
            AmbientState ambientState) {
        if (mIsSummaryWithChildren) {
            ExpandableViewState parentState = resultState.getViewStateForView(this);
            mChildrenContainer.getState(resultState, parentState);
            mChildrenContainer.getState(resultState, parentState, ambientState);
        }
    }

@@ -1600,19 +1607,42 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (params == null) {
            return;
        }
        setTranslationY(params.getTop());
        float zProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(
                params.getProgress(0, 50));
        float translationZ = MathUtils.lerp(params.getStartTranslationZ(),
                mNotificationLaunchHeight,
                zProgress);
        setTranslationZ(translationZ);
        float extraWidthForClipping = params.getWidth() - getWidth()
                + MathUtils.lerp(0, mOutlineRadius * 2, params.getProgress());
        setExtraWidthForClipping(extraWidthForClipping);
        int top = params.getTop();
        float interpolation = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(params.getProgress());
        int startClipTopAmount = params.getStartClipTopAmount();
        if (mNotificationParent != null) {
            top -= mNotificationParent.getTranslationY();
            mNotificationParent.setTranslationZ(translationZ);
            int parentStartClipTopAmount = params.getParentStartClipTopAmount();
            if (startClipTopAmount != 0) {
                int clipTopAmount = (int) MathUtils.lerp(parentStartClipTopAmount,
                        parentStartClipTopAmount - startClipTopAmount,
                        interpolation);
                mNotificationParent.setClipTopAmount(clipTopAmount);
            }
            mNotificationParent.setExtraWidthForClipping(extraWidthForClipping);
            mNotificationParent.setMinimumHeightForClipping(params.getHeight()
                    + mNotificationParent.getActualHeight());
        } else if (startClipTopAmount != 0) {
            int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, interpolation);
            setClipTopAmount(clipTopAmount);
        }
        setTranslationY(top);
        setActualHeight(params.getHeight());

        mBackgroundNormal.setExpandAnimationParams(params);
    }

    public void setExpandAnimationRunning(boolean expandAnimationRunning) {
        if (expandAnimationRunning) {
        View contentView;
        if (mIsSummaryWithChildren) {
            contentView =  mChildrenContainer;
@@ -1622,6 +1652,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (mGuts != null && mGuts.isExposed()) {
            contentView = mGuts;
        }
        if (expandAnimationRunning) {
            contentView.animate()
                    .alpha(0f)
                    .setDuration(ActivityLaunchAnimator.ANIMATION_DURATION_FADE_CONTENT)
@@ -1636,15 +1667,35 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            if (mGuts != null) {
                mGuts.setAlpha(1.0f);
            }
            if (contentView != null) {
                contentView.setAlpha(1.0f);
            }
            setExtraWidthForClipping(0.0f);
            if (mNotificationParent != null) {
                mNotificationParent.setExtraWidthForClipping(0.0f);
                mNotificationParent.setMinimumHeightForClipping(0);
            }
        }
        if (mNotificationParent != null) {
            mNotificationParent.setChildIsExpanding(mExpandAnimationRunning);
        }
        updateChildrenVisibility();
        updateClipping();
        mBackgroundNormal.setExpandAnimationRunning(expandAnimationRunning);
    }

    private void setChildIsExpanding(boolean isExpanding) {
        mChildIsExpanding = isExpanding;
    }

    @Override
    public boolean hasExpandingChild() {
        return mChildIsExpanding;
    }

    @Override
    protected boolean shouldClipToActualHeight() {
        return super.shouldClipToActualHeight() && !mExpandAnimationRunning;
        return super.shouldClipToActualHeight() && !mExpandAnimationRunning && !mChildIsExpanding;
    }

    @Override
@@ -2236,7 +2287,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                mGuts.setClipBottomAmount(clipBottomAmount);
            }
        }
        if (mChildrenContainer != null) {
        if (mChildrenContainer != null && !mChildIsExpanding) {
            // We have to update this even if it hasn't changed, since the children locations can
            // have changed
            mChildrenContainer.setClipBottomAmount(clipBottomAmount);
@@ -2444,7 +2495,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    public boolean isAboveShelf() {
        return !isOnKeyguard()
                && (mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf)
                || mExpandAnimationRunning);
                || mExpandAnimationRunning || mChildIsExpanding);
    }

    public void setShowAmbient(boolean showAmbient) {
@@ -2469,7 +2520,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                return true;
            }
        } else if (child == mChildrenContainer) {
            if (isClippingNeeded() || !hasNoRounding()) {
            if (!mChildIsExpanding && (isClippingNeeded() || !hasNoRounding())) {
                return true;
            }
        } else if (child instanceof NotificationGuts) {
@@ -2535,11 +2586,19 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                if (row.isExpandAnimationRunning()) {
                    return;
                }
                handleFixedTranslationZ(row);
                super.applyToView(view);
                row.applyChildrenState(mOverallState);
            }
        }

        private void handleFixedTranslationZ(ExpandableNotificationRow row) {
            if (row.hasExpandingChild()) {
                zTranslation = row.getTranslationZ();
                clipTopAmount = row.getClipTopAmount();
            }
        }

        @Override
        protected void onYTranslationAnimationFinished(View view) {
            super.onYTranslationAnimationFinished(view);
@@ -2558,6 +2617,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                if (row.isExpandAnimationRunning()) {
                    return;
                }
                handleFixedTranslationZ(row);
                super.animateTo(child, properties);
                row.startChildAnimation(mOverallState, properties);
            }
+15 −5
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
    private final Path mClipPath = new Path();
    private boolean mCustomOutline;
    private float mOutlineAlpha = -1f;
    private float mOutlineRadius;
    protected float mOutlineRadius;
    private boolean mAlwaysRoundBothCorners;
    private Path mTmpPath = new Path();
    private Path mTmpPath2 = new Path();
@@ -78,6 +78,8 @@ public abstract class ExpandableOutlineView extends ExpandableView {
    protected boolean mShouldTranslateContents;
    private boolean mClipRoundedToClipTopAmount;
    private float mDistanceToTopRoundness = -1;
    private float mExtraWidthForClipping;
    private int mMinimumHeightForClipping = 0;

    private final ViewOutlineProvider mProvider = new ViewOutlineProvider() {
        @Override
@@ -202,11 +204,11 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        canvas.save();
        Path intersectPath = null;
        if (mClipRoundedToClipTopAmount) {
            int left = 0;
            int left = (int) (- mExtraWidthForClipping / 2.0f);
            int top = (int) (mClipTopAmount - mDistanceToTopRoundness);
            int right = getWidth();
            int bottom = (int) Math.max(getActualHeight() - mClipBottomAmount,
                    top + mOutlineRadius);
            int right = getWidth() + (int) (mExtraWidthForClipping + left);
            int bottom = (int) Math.max(mMinimumHeightForClipping,
                    Math.max(getActualHeight() - mClipBottomAmount, top + mOutlineRadius));
            ExpandableOutlineView.getRoundedRectPath(left, top, right, bottom, mOutlineRadius,
                    0.0f,
                    mClipPath);
@@ -234,6 +236,14 @@ public abstract class ExpandableOutlineView extends ExpandableView {
        return result;
    }

    public void setExtraWidthForClipping(float extraWidthForClipping) {
        mExtraWidthForClipping = extraWidthForClipping;
    }

    public void setMinimumHeightForClipping(int minimumHeightForClipping) {
        mMinimumHeightForClipping = minimumHeightForClipping;
    }

    @Override
    public void setDistanceToTopRoundness(float distanceToTopRoundness) {
        super.setDistanceToTopRoundness(distanceToTopRoundness);
+4 −0
Original line number Diff line number Diff line
@@ -543,6 +543,10 @@ public abstract class ExpandableView extends FrameLayout {
        return false;
    }

    public boolean hasExpandingChild() {
        return false;
    }

    /**
     * A listener notifying when {@link #getActualHeight} changes.
     */
+37 −4
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarWindowView;

import java.util.function.Consumer;

/**
 * A class that allows activities to be launched in a seamless way where the notification
 * transforms nicely into the starting window.
@@ -134,8 +132,24 @@ public class ActivityLaunchAnimator {
                        ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
                        mParams.startPosition = mSourceNotification.getLocationOnScreen();
                        mParams.startTranslationZ = mSourceNotification.getTranslationZ();
                        mParams.startClipTopAmount = mSourceNotification.getClipTopAmount();
                        if (mSourceNotification.isChildInGroup()) {
                            int parentClip = mSourceNotification
                                    .getNotificationParent().getClipTopAmount();
                            mParams.parentStartClipTopAmount = parentClip;
                            // We need to calculate how much the child is clipped by the parent
                            // because children always have 0 clipTopAmount
                            if (parentClip != 0) {
                                float childClip = parentClip
                                        - mSourceNotification.getTranslationY();
                                if (childClip > 0.0f) {
                                    mParams.startClipTopAmount = (int) Math.ceil(childClip);
                                }
                            }
                        }
                        int targetWidth = app.sourceContainerBounds.width();
                        int notificationHeight = mSourceNotification.getActualHeight();
                        int notificationHeight = mSourceNotification.getActualHeight()
                                - mSourceNotification.getClipBottomAmount();
                        int notificationWidth = mSourceNotification.getWidth();
                        anim.setDuration(ANIMATION_DURATION);
                        anim.setInterpolator(Interpolators.LINEAR);
@@ -241,6 +255,8 @@ public class ActivityLaunchAnimator {
        int top;
        int right;
        int bottom;
        int startClipTopAmount;
        int parentStartClipTopAmount;

        public ExpandAnimationParameters() {
        }
@@ -258,15 +274,32 @@ public class ActivityLaunchAnimator {
        }

        public int getTopChange() {
            return Math.min(top - startPosition[1], 0);
            // We need this compensation to ensure that the QS moves in sync.
            int clipTopAmountCompensation = 0;
            if (startClipTopAmount != 0.0f) {
                clipTopAmountCompensation = (int) MathUtils.lerp(0, startClipTopAmount,
                        Interpolators.FAST_OUT_SLOW_IN.getInterpolation(linearProgress));
            }
            return Math.min(top - startPosition[1] - clipTopAmountCompensation, 0);
        }

        public float getProgress() {
            return linearProgress;
        }

        public float getProgress(long delay, long duration) {
            return MathUtils.constrain((linearProgress * ANIMATION_DURATION - delay)
                    / duration, 0.0f, 1.0f);
        }

        public int getStartClipTopAmount() {
            return startClipTopAmount;
        }

        public int getParentStartClipTopAmount() {
            return parentStartClipTopAmount;
        }

        public float getStartTranslationZ() {
            return startTranslationZ;
        }
+1 −2
Original line number Diff line number Diff line
@@ -220,8 +220,7 @@ public class AmbientState {
    }

    public int getInnerHeight() {
        return Math.max(Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding
                - mExpandAnimationTopChange, mLayoutMinHeight);
        return Math.max(Math.min(mLayoutHeight, mMaxLayoutHeight) - mTopPadding, mLayoutMinHeight);
    }

    public boolean isShadeExpanded() {
Loading