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 Original line Diff line number Diff line
@@ -180,6 +180,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private AboveShelfChangedListener mAboveShelfChangedListener;
    private AboveShelfChangedListener mAboveShelfChangedListener;
    private HeadsUpManager mHeadsUpManager;
    private HeadsUpManager mHeadsUpManager;
    private View mHelperButton;
    private View mHelperButton;
    private boolean mChildIsExpanding;


    private boolean mJustClicked;
    private boolean mJustClicked;
    private boolean mIconAnimationRunning;
    private boolean mIconAnimationRunning;
@@ -574,8 +575,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * @param isChildInGroup Is this notification now in a group
     * @param isChildInGroup Is this notification now in a group
     * @param parent the new parent notification
     * @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;
        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;
        mNotificationParent = childInGroup ? parent : null;
        mPrivateLayout.setIsChildInGroup(childInGroup);
        mPrivateLayout.setIsChildInGroup(childInGroup);
        mNotificationInflater.setIsChildInGroup(childInGroup);
        mNotificationInflater.setIsChildInGroup(childInGroup);
@@ -650,10 +656,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                visualStabilityManager, callback);
                visualStabilityManager, callback);
    }
    }


    public void getChildrenStates(StackScrollState resultState) {
    public void getChildrenStates(StackScrollState resultState,
            AmbientState ambientState) {
        if (mIsSummaryWithChildren) {
        if (mIsSummaryWithChildren) {
            ExpandableViewState parentState = resultState.getViewStateForView(this);
            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) {
        if (params == null) {
            return;
            return;
        }
        }
        setTranslationY(params.getTop());
        float zProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(
        float zProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(
                params.getProgress(0, 50));
                params.getProgress(0, 50));
        float translationZ = MathUtils.lerp(params.getStartTranslationZ(),
        float translationZ = MathUtils.lerp(params.getStartTranslationZ(),
                mNotificationLaunchHeight,
                mNotificationLaunchHeight,
                zProgress);
                zProgress);
        setTranslationZ(translationZ);
        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());
        setActualHeight(params.getHeight());

        mBackgroundNormal.setExpandAnimationParams(params);
        mBackgroundNormal.setExpandAnimationParams(params);
    }
    }


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


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

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

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


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


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


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

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


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


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

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

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


    public boolean hasExpandingChild() {
        return false;
    }

    /**
    /**
     * A listener notifying when {@link #getActualHeight} changes.
     * A listener notifying when {@link #getActualHeight} changes.
     */
     */
+37 −4
Original line number Original line 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.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
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
 * A class that allows activities to be launched in a seamless way where the notification
 * transforms nicely into the starting window.
 * transforms nicely into the starting window.
@@ -134,8 +132,24 @@ public class ActivityLaunchAnimator {
                        ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
                        ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
                        mParams.startPosition = mSourceNotification.getLocationOnScreen();
                        mParams.startPosition = mSourceNotification.getLocationOnScreen();
                        mParams.startTranslationZ = mSourceNotification.getTranslationZ();
                        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 targetWidth = app.sourceContainerBounds.width();
                        int notificationHeight = mSourceNotification.getActualHeight();
                        int notificationHeight = mSourceNotification.getActualHeight()
                                - mSourceNotification.getClipBottomAmount();
                        int notificationWidth = mSourceNotification.getWidth();
                        int notificationWidth = mSourceNotification.getWidth();
                        anim.setDuration(ANIMATION_DURATION);
                        anim.setDuration(ANIMATION_DURATION);
                        anim.setInterpolator(Interpolators.LINEAR);
                        anim.setInterpolator(Interpolators.LINEAR);
@@ -241,6 +255,8 @@ public class ActivityLaunchAnimator {
        int top;
        int top;
        int right;
        int right;
        int bottom;
        int bottom;
        int startClipTopAmount;
        int parentStartClipTopAmount;


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


        public int getTopChange() {
        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) {
        public float getProgress(long delay, long duration) {
            return MathUtils.constrain((linearProgress * ANIMATION_DURATION - delay)
            return MathUtils.constrain((linearProgress * ANIMATION_DURATION - delay)
                    / duration, 0.0f, 1.0f);
                    / duration, 0.0f, 1.0f);
        }
        }


        public int getStartClipTopAmount() {
            return startClipTopAmount;
        }

        public int getParentStartClipTopAmount() {
            return parentStartClipTopAmount;
        }

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


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


    public boolean isShadeExpanded() {
    public boolean isShadeExpanded() {
Loading