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

Commit ba12753e authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge changes from topic "convert-hun-anim-flag" into main

* changes:
  Tweak HUN intro/outro animations
  Convert IMPROVED_HUN_ANIMATIONS flag to aconfig
parents 320804e0 1baaee6f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -44,6 +44,13 @@ flag {
    bug: "293824309"
}

flag {
    name: "notifications_improved_hun_animation"
    namespace: "systemui"
    description: "Adds a translateY animation, and other improvements to match the motion specs of the HUN Intro + Outro animations."
    bug: "243302608"
}

flag {
    name: "notification_lifetime_extension_refactor"
    namespace: "systemui"
+4 −0
Original line number Diff line number Diff line
@@ -274,6 +274,10 @@
    <!-- Side padding on the side of notifications -->
    <dimen name="notification_side_paddings">16dp</dimen>

    <!-- Starting translateY offset of the HUN appear and disappear animations. Indicates
    the amount by the view is positioned above the screen before the animation starts. -->
    <dimen name="heads_up_appear_y_above_screen">32dp</dimen>

    <!-- padding between the heads up and the statusbar -->
    <dimen name="heads_up_status_bar_padding">8dp</dimen>

+1 −4
Original line number Diff line number Diff line
@@ -17,11 +17,11 @@ package com.android.systemui.flags

import android.provider.DeviceConfig
import com.android.internal.annotations.Keep
import com.android.systemui.res.R
import com.android.systemui.flags.FlagsFactory.releasedFlag
import com.android.systemui.flags.FlagsFactory.resourceBooleanFlag
import com.android.systemui.flags.FlagsFactory.sysPropBooleanFlag
import com.android.systemui.flags.FlagsFactory.unreleasedFlag
import com.android.systemui.res.R

/**
 * List of [Flag] objects for use in SystemUI.
@@ -604,9 +604,6 @@ object Flags {
    @JvmField
    val LOCKSCREEN_WALLPAPER_DREAM_ENABLED = unreleasedFlag("enable_lockscreen_wallpaper_dream")

    // TODO(b/283084712): Tracking Bug
    @JvmField val IMPROVED_HUN_ANIMATIONS = unreleasedFlag("improved_hun_animations")

    // TODO(b/283447257): Tracking bug
    @JvmField
    val BIGPICTURE_NOTIFICATION_LAZY_LOADING =
+3 −8
Original line number Diff line number Diff line
@@ -3,10 +3,8 @@ package com.android.systemui.statusbar.notification
import android.util.FloatProperty
import android.view.View
import androidx.annotation.FloatRange
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.flags.RefactorFlag
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import kotlin.math.abs
@@ -42,13 +40,13 @@ interface Roundable {
    /** Current top corner in pixel, based on [topRoundness] and [maxRadius] */
    val topCornerRadius: Float
        get() =
            if (roundableState.newHeadsUpAnim.isEnabled) roundableState.topCornerRadius
            if (NotificationsImprovedHunAnimation.isEnabled) roundableState.topCornerRadius
            else topRoundness * maxRadius

    /** Current bottom corner in pixel, based on [bottomRoundness] and [maxRadius] */
    val bottomCornerRadius: Float
        get() =
            if (roundableState.newHeadsUpAnim.isEnabled) roundableState.bottomCornerRadius
            if (NotificationsImprovedHunAnimation.isEnabled) roundableState.bottomCornerRadius
            else bottomRoundness * maxRadius

    /** Get and update the current radii */
@@ -318,13 +316,10 @@ constructor(
    internal val targetView: View,
    private val roundable: Roundable,
    maxRadius: Float,
    featureFlags: FeatureFlags? = null
) {
    internal var maxRadius = maxRadius
        private set

    internal val newHeadsUpAnim = RefactorFlag.forView(Flags.IMPROVED_HUN_ANIMATIONS, featureFlags)

    /** Animatable for top roundness */
    private val topAnimatable = topAnimatable(roundable)

+15 −11
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.view.Choreographer;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;

import com.android.app.animation.Interpolators;
import com.android.internal.jank.InteractionJankMonitor;
@@ -44,6 +43,7 @@ import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.util.DumpUtilsKt;
@@ -67,7 +67,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     * 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;

    private static final float ALPHA_APPEAR_START_FRACTION = .7f;
    /**
     * The content should show fully with progress at #ALPHA_APPEAR_END_FRACTION
     * The start of the animation is at #ALPHA_APPEAR_START_FRACTION
@@ -86,9 +87,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     */
    private boolean mActivated;

    private final Interpolator mSlowOutFastInInterpolator;
    private Interpolator mCurrentAppearInterpolator;

    NotificationBackgroundView mBackgroundNormal;
    private float mAnimationTranslationY;
    private boolean mDrawingAppearAnimation;
@@ -116,7 +115,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    public ActivatableNotificationView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mSlowOutFastInInterpolator = new PathInterpolator(0.8f, 0.0f, 0.6f, 1.0f);
        setClipChildren(false);
        setClipToPadding(false);
        updateColors();
@@ -400,12 +398,16 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            mCurrentAppearInterpolator = Interpolators.FAST_OUT_SLOW_IN;
            targetValue = 1.0f;
        } else {
            mCurrentAppearInterpolator = mSlowOutFastInInterpolator;
            mCurrentAppearInterpolator = Interpolators.FAST_OUT_SLOW_IN_REVERSE;
            targetValue = 0.0f;
        }
        mAppearAnimator = ValueAnimator.ofFloat(mAppearAnimationFraction,
                targetValue);
        if (NotificationsImprovedHunAnimation.isEnabled()) {
            mAppearAnimator.setInterpolator(mCurrentAppearInterpolator);
        } else {
            mAppearAnimator.setInterpolator(Interpolators.LINEAR);
        }
        mAppearAnimator.setDuration(
                (long) (duration * Math.abs(mAppearAnimationFraction - targetValue)));
        mAppearAnimator.addUpdateListener(animation -> {
@@ -502,8 +504,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    private void updateAppearRect() {
        float interpolatedFraction = mCurrentAppearInterpolator.getInterpolation(
                mAppearAnimationFraction);
        float interpolatedFraction =
                NotificationsImprovedHunAnimation.isEnabled() ? mAppearAnimationFraction
                        : mCurrentAppearInterpolator.getInterpolation(mAppearAnimationFraction);
        mAppearAnimationTranslation = (1.0f - interpolatedFraction) * mAnimationTranslationY;
        final int actualHeight = getActualHeight();
        float bottom = actualHeight * interpolatedFraction;
@@ -524,6 +527,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    private float getInterpolatedAppearAnimationFraction() {

        if (mAppearAnimationFraction >= 0) {
            return mCurrentAppearInterpolator.getInterpolation(mAppearAnimationFraction);
        }
@@ -569,7 +573,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    @Override
    public float getTopCornerRadius() {
        if (mImprovedHunAnimation.isEnabled()) {
        if (NotificationsImprovedHunAnimation.isEnabled()) {
            return super.getTopCornerRadius();
        }

@@ -579,7 +583,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    @Override
    public float getBottomCornerRadius() {
        if (mImprovedHunAnimation.isEnabled()) {
        if (NotificationsImprovedHunAnimation.isEnabled()) {
            return super.getBottomCornerRadius();
        }

Loading