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

Commit b0b66c4d authored by Selim Cinek's avatar Selim Cinek Committed by Automerger Merge Worker
Browse files

Merge "Animation reveal animation for HUN and Shelf" into sc-dev am: 00630da0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14626097

Change-Id: Iff8ad8bcf7b6f64b0b4dbe8819d16e9133ac9a4c
parents 1a520bdf 00630da0
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -20,14 +20,11 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.view.DisplayCutout;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityNodeInfo;

import com.android.internal.annotations.VisibleForTesting;
+39 −61
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.notification.row;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
@@ -84,7 +83,16 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     * or {@link #setOverrideTintColor(int, float)}.
     */
    protected static final int NO_COLOR = 0;

    /**
     * The content of the view should start showing at animation progress value of
     * #ALPHA_APPEAR_START_FRACTION.
     */
    private static final float ALPHA_APPEAR_START_FRACTION = .4f;
    /**
     * The content should show fully with progress at #ALPHA_APPEAR_END_FRACTION
     * The start of the animation is at #ALPHA_APPEAR_START_FRACTION
     */
    private static final float ALPHA_APPEAR_END_FRACTION = 1;
    private static final Interpolator ACTIVATE_INVERSE_INTERPOLATOR
            = new PathInterpolator(0.6f, 0, 0.5f, 1);
    private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR
@@ -106,10 +114,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private final Interpolator mSlowOutFastInInterpolator;
    private final Interpolator mSlowOutLinearInInterpolator;
    private Interpolator mCurrentAppearInterpolator;
    private Interpolator mCurrentAlphaInterpolator;

    NotificationBackgroundView mBackgroundNormal;
    private ObjectAnimator mBackgroundAnimator;
    private RectF mAppearAnimationRect = new RectF();
    private float mAnimationTranslationY;
    private boolean mDrawingAppearAnimation;
@@ -475,8 +481,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay,
            long duration, final Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        cancelAppearAnimation();
        mAnimationTranslationY = translationDirection * getActualHeight();
        cancelAppearAnimation();
        if (mAppearAnimationFraction == -1.0f) {
            // not initialized yet, we start anew
            if (isAppearing) {
@@ -492,15 +498,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        float targetValue;
        if (isAppearing) {
            mCurrentAppearInterpolator = mSlowOutFastInInterpolator;
            mCurrentAlphaInterpolator = Interpolators.LINEAR_OUT_SLOW_IN;
            targetValue = 1.0f;
            if (!mIsHeadsUpAnimation && isChildInGroup()) {
                // slower fade in of children to avoid visibly overlapping with other children
                mCurrentAlphaInterpolator = Interpolators.SLOW_OUT_LINEAR_IN;
            }
        } else {
            mCurrentAppearInterpolator = Interpolators.FAST_OUT_SLOW_IN;
            mCurrentAlphaInterpolator = mSlowOutLinearInInterpolator;
            targetValue = 0.0f;
        }
        mAppearAnimator = ValueAnimator.ofFloat(mAppearAnimationFraction,
@@ -588,61 +588,23 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        float translationFraction = mCurrentAppearInterpolator.getInterpolation(inverseFraction);
        float translateYTotalAmount = translationFraction * mAnimationTranslationY;
        mAppearAnimationTranslation = translateYTotalAmount;
        final int actualHeight = getActualHeight();
        float bottom = actualHeight * mAppearAnimationFraction;

        // handle width animation
        float widthFraction = (inverseFraction - (1.0f - HORIZONTAL_ANIMATION_START))
                / (HORIZONTAL_ANIMATION_START - HORIZONTAL_ANIMATION_END);
        widthFraction = Math.min(1.0f, Math.max(0.0f, widthFraction));
        widthFraction = mCurrentAppearInterpolator.getInterpolation(widthFraction);
        float startWidthFraction = HORIZONTAL_COLLAPSED_REST_PARTIAL;
        if (mIsHeadsUpAnimation && !mIsAppearing) {
            startWidthFraction = 0;
        }
        if (mIsAppearing && !mIsHeadsUpAnimation && isChildInGroup()) {
            // Children in a group (when not heads up) should simply fade in.
            startWidthFraction = 1;
        }
        float width = MathUtils.lerp(startWidthFraction, 1.0f, 1.0f - widthFraction)
                        * getWidth();
        float left;
        float right;
        if (mIsHeadsUpAnimation) {
            left = MathUtils.lerp(mHeadsUpLocation, 0, 1.0f - widthFraction);
            right = left + width;
        } else {
            left = getWidth() * 0.5f - width / 2.0f;
            right = getWidth() - left;
        setOutlineRect(0, mAppearAnimationTranslation,
                getWidth(), bottom + mAppearAnimationTranslation);
    }

        // handle top animation
        float heightFraction = (inverseFraction - (1.0f - VERTICAL_ANIMATION_START)) /
                VERTICAL_ANIMATION_START;
        heightFraction = Math.max(0.0f, heightFraction);
        heightFraction = mCurrentAppearInterpolator.getInterpolation(heightFraction);

        float top;
        float bottom;
        final int actualHeight = getActualHeight();
        if (mAnimationTranslationY > 0.0f) {
            bottom = actualHeight - heightFraction * mAnimationTranslationY * 0.1f
                    - translateYTotalAmount;
            top = bottom * heightFraction;
        } else {
            top = heightFraction * (actualHeight + mAnimationTranslationY) * 0.1f -
                    translateYTotalAmount;
            bottom = actualHeight * (1 - heightFraction) + top * heightFraction;
        }
        mAppearAnimationRect.set(left, top, right, bottom);
        setOutlineRect(left, top + mAppearAnimationTranslation, right,
                bottom + mAppearAnimationTranslation);
    private float getAppearAnimationFraction() {
        return mAppearAnimationFraction >= 0 ? mAppearAnimationFraction : 1;
    }

    private void updateAppearAnimationAlpha() {
        float contentAlphaProgress = mAppearAnimationFraction;
        contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
        contentAlphaProgress = Math.min(1.0f, contentAlphaProgress);
        contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress);
        setContentAlpha(contentAlphaProgress);
        float contentAlphaProgress = MathUtils.constrain(mAppearAnimationFraction,
                ALPHA_APPEAR_START_FRACTION, ALPHA_APPEAR_END_FRACTION);
        float range = ALPHA_APPEAR_END_FRACTION - ALPHA_APPEAR_START_FRACTION;
        float alpha = (contentAlphaProgress - ALPHA_APPEAR_START_FRACTION) / range;
        setContentAlpha(Interpolators.ALPHA_IN.getInterpolation(alpha));
    }

    private void setContentAlpha(float contentAlpha) {
@@ -665,6 +627,22 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
                getCurrentBackgroundRadiusBottom());
    }

    @Override
    public float getCurrentBackgroundRadiusTop() {
        float fraction = getAppearAnimationFraction();
        return isHeadsUpAnimatingAway() || isHeadsUp()
                ? mOutlineRadius * fraction
                : super.getCurrentBackgroundRadiusTop();
    }

    @Override
    public float getCurrentBackgroundRadiusBottom() {
        float fraction = getAppearAnimationFraction();
        return isHeadsUpAnimatingAway() || isHeadsUp()
                ? mOutlineRadius * fraction
                : super.getCurrentBackgroundRadiusBottom();
    }

    private void applyBackgroundRoundness(float topRadius, float bottomRadius) {
        mBackgroundNormal.setRadius(topRadius, bottomRadius);
    }
+0 −17
Original line number Diff line number Diff line
@@ -1997,23 +1997,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return false;
    }

    @Override
    public float getCurrentTopRoundness() {
        if (mExpandAnimationRunning) {
            return mTopRoundnessDuringExpandAnimation;
        }

        return super.getCurrentTopRoundness();
    }

    @Override
    public float getCurrentBottomRoundness() {
        if (mExpandAnimationRunning) {
            return mBottomRoundnessDuringExpandAnimation;
        }

        return super.getCurrentBottomRoundness();
    }

    public void applyExpandAnimationParams(ExpandAnimationParameters params) {
        if (params == null) {
+0 −10
Original line number Diff line number Diff line
@@ -117,16 +117,6 @@ public class AnimationFilter {
                    NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_GO_TO_FULL_SHADE) {
                hasGoToFullShadeEvent = true;
            }
            if (ev.animationType == NotificationStackScrollLayout.AnimationEvent
                    .ANIMATION_TYPE_HEADS_UP_DISAPPEAR) {
                customDelay = StackStateAnimator.ANIMATION_DELAY_HEADS_UP;
            } else if (ev.animationType == NotificationStackScrollLayout.AnimationEvent
                    .ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
                // We need both timeouts when clicking, one to delay it and one for the animation
                // to look nice
                customDelay = StackStateAnimator.ANIMATION_DELAY_HEADS_UP_CLICKED
                        + StackStateAnimator.ANIMATION_DELAY_HEADS_UP;
            }
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ public class StackScrollAlgorithm {
                continue;
            }
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (!row.isHeadsUp()) {
            if (!(row.isHeadsUp() || row.isHeadsUpAnimatingAway())) {
                continue;
            }
            ExpandableViewState childState = row.getViewState();
@@ -585,6 +585,7 @@ public class StackScrollAlgorithm {
                }
            }
            if (row.isHeadsUpAnimatingAway()) {
                childState.yTranslation = Math.max(childState.yTranslation, mHeadsUpInset);
                childState.hidden = false;
            }
        }
Loading