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

Commit 2627d72e authored by Selim Cinek's avatar Selim Cinek
Browse files

Launching Notification animations inline

Using the new control mechanism introduced in order
to coordinate notification launches and smoothly
transform the notification into the launching window.

Bug: 69168591
Test: add notification, launch it
Change-Id: Ib2d671c65f276ec596a2f07edf64d65bf27a2882
parent 65b79f7e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -350,6 +350,7 @@ applications that come with the platform
        <permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
        <permission name="android.permission.CHANGE_OVERLAY_PACKAGES"/>
        <permission name="android.permission.CONNECTIVITY_INTERNAL"/>
        <permission name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS"/>
        <permission name="android.permission.CONTROL_VPN"/>
        <permission name="android.permission.DUMP"/>
        <permission name="android.permission.GET_APP_OPS_STATS"/>
+11 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.graphics.Xfermode;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -814,6 +815,16 @@ public class GradientDrawable extends Drawable {
        }
    }

    /**
     * @param mode to draw this drawable with
     * @hide
     */
    @Override
    public void setXfermode(@Nullable Xfermode mode) {
        super.setXfermode(mode);
        mFillPaint.setXfermode(mode);
    }

    private void buildPathIfDirty() {
        final GradientState st = mGradientState;
        if (mPathIsDirty) {
+3 −0
Original line number Diff line number Diff line
@@ -200,6 +200,9 @@
    <!-- to access instant apps -->
    <uses-permission android:name="android.permission.ACCESS_INSTANT_APPS" />

    <!-- to control remote app transitions -->
    <uses-permission android:name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS" />

    <!-- to change themes - light or dark -->
    <uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES" />

+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private Interpolator mCurrentAppearInterpolator;
    private Interpolator mCurrentAlphaInterpolator;

    private NotificationBackgroundView mBackgroundNormal;
    protected NotificationBackgroundView mBackgroundNormal;
    private NotificationBackgroundView mBackgroundDimmed;
    private ObjectAnimator mBackgroundAnimator;
    private RectF mAppearAnimationRect = new RectF();
+83 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar;

import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.NotificationInflater.InflationCallback;

import android.animation.Animator;
@@ -37,6 +38,7 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.MathUtils;
import android.util.Property;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -67,6 +69,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem;
import com.android.systemui.statusbar.NotificationGuts.GutsContent;
import com.android.systemui.statusbar.notification.AboveShelfChangedListener;
import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.HybridNotificationView;
import com.android.systemui.statusbar.notification.NotificationInflater;
import com.android.systemui.statusbar.notification.NotificationUtils;
@@ -75,6 +78,7 @@ import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.stack.AmbientState;
import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
@@ -113,6 +117,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private int mNotificationMaxHeight;
    private int mNotificationAmbientHeight;
    private int mIncreasedPaddingBetweenElements;
    private int mNotificationLaunchHeight;
    private boolean mMustStayOnScreen;

    /** Does this row contain layouts that can adapt to row expansion */
@@ -172,6 +177,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private boolean mIsSystemChildExpanded;
    private boolean mIsPinned;
    private FalsingManager mFalsingManager;
    private boolean mExpandAnimationRunning;
    private AboveShelfChangedListener mAboveShelfChangedListener;
    private HeadsUpManager mHeadsUpManager;
    private View mHelperButton;
@@ -270,6 +276,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private float mTranslationWhenRemoved;
    private boolean mWasChildInGroupWhenRemoved;
    private int mNotificationColorAmbient;
    private NotificationViewState mNotificationViewState;

    @Override
    public boolean isGroupExpansionChanging() {
@@ -363,6 +370,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mNotificationInflater.inflateNotificationViews();
    }

    @Override
    public void setPressed(boolean pressed) {
        if (isOnKeyguard() || mEntry.notification.getNotification().contentIntent == null) {
            // We're dropping the ripple if we have a collapse / launch animation
            super.setPressed(pressed);
        }
    }

    public void onNotificationUpdated() {
        for (NotificationContentView l : mLayouts) {
            l.onNotificationUpdated(mEntry);
@@ -1159,6 +1174,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    private void updateContentTransformation() {
        if (mExpandAnimationRunning) {
            return;
        }
        float contentAlpha;
        float translationY = -mContentTransformationAmount * mIconTransformContentShift;
        if (mIsLastChild) {
@@ -1569,6 +1587,56 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        updateShelfIconColor();
    }

    public void applyExpandAnimationParams(ExpandAnimationParameters params) {
        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);
        setActualHeight(params.getHeight());
        mBackgroundNormal.setExpandAnimationParams(params);
    }

    public void setExpandAnimationRunning(boolean expandAnimationRunning) {
        if (expandAnimationRunning) {
            View contentView;
            if (mIsSummaryWithChildren) {
                contentView =  mChildrenContainer;
            } else {
                contentView = getShowingLayout();
            }
            contentView.animate()
                    .alpha(0f)
                    .setDuration(ActivityLaunchAnimator.ANIMATION_DURATION_FADE_CONTENT)
                    .setInterpolator(Interpolators.ALPHA_OUT);
            setAboveShelf(true);
            mExpandAnimationRunning = true;
            mNotificationViewState.cancelAnimations(this);
            mNotificationLaunchHeight = AmbientState.getNotificationLaunchHeight(getContext());
        } else {
            mExpandAnimationRunning = false;
            setAboveShelf(isAboveShelf());
        }
        mExpandAnimationRunning = expandAnimationRunning;
        updateClipping();
        mBackgroundNormal.setExpandAnimationRunning(expandAnimationRunning);
    }

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

    @Override
    public boolean isExpandAnimationRunning() {
        return mExpandAnimationRunning;
    }

    /**
     * Tap sounds should not be played when we're unlocking.
     * Doing so would cause audio collision and the system would feel unpolished.
@@ -2142,6 +2210,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    public void setClipBottomAmount(int clipBottomAmount) {
        if (mExpandAnimationRunning) {
            return;
        }
        if (clipBottomAmount != mClipBottomAmount) {
            super.setClipBottomAmount(clipBottomAmount);
            for (NotificationContentView l : mLayouts) {
@@ -2352,13 +2423,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    public ExpandableViewState createNewViewState(StackScrollState stackScrollState) {
        return new NotificationViewState(stackScrollState);
        mNotificationViewState = new NotificationViewState(stackScrollState);
        return mNotificationViewState;
    }

    @Override
    public boolean isAboveShelf() {
        return !isOnKeyguard()
                && (mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf));
                && (mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf)
                || mExpandAnimationRunning);
    }

    public void setShowAmbient(boolean showAmbient) {
@@ -2444,9 +2517,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

        @Override
        public void applyToView(View view) {
            super.applyToView(view);
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
                if (row.isExpandAnimationRunning()) {
                    return;
                }
                super.applyToView(view);
                row.applyChildrenState(mOverallState);
            }
        }
@@ -2464,9 +2540,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

        @Override
        public void animateTo(View child, AnimationProperties properties) {
            super.animateTo(child, properties);
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                if (row.isExpandAnimationRunning()) {
                    return;
                }
                super.animateTo(child, properties);
                row.startChildAnimation(mOverallState, properties);
            }
        }
Loading