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

Commit 95507721 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Potentially fix notification launch animation

If we don't have something to animate, immediately finish
animation

Test: Open a couple of notifications
Bug: 77847366
Change-Id: I06c651b33a5ffb4ec236ba41f9db38b0125684dd
parent 0bbd1f57
Loading
Loading
Loading
Loading
+89 −70
Original line number Diff line number Diff line
@@ -123,11 +123,17 @@ public class ActivityLaunchAnimator {
                IRemoteAnimationFinishedCallback iRemoteAnimationFinishedCallback)
                    throws RemoteException {
            mSourceNotification.post(() -> {
                for (RemoteAnimationTarget app : remoteAnimationTargets) {
                    if (app.mode == RemoteAnimationTarget.MODE_OPENING) {
                RemoteAnimationTarget primary = getPrimaryRemoteAnimationTarget(
                        remoteAnimationTargets);
                if (primary == null) {
                    setAnimationPending(false);
                    invokeCallback(iRemoteAnimationFinishedCallback);
                    return;
                }

                setExpandAnimationRunning(true);
                        mInstantCollapsePanel = app.position.y == 0
                                && app.sourceContainerBounds.height()
                mInstantCollapsePanel = primary.position.y == 0
                        && primary.sourceContainerBounds.height()
                                >= mNotificationPanel.getHeight();
                if (!mInstantCollapsePanel) {
                    mNotificationPanel.collapseWithDuration(ANIMATION_DURATION);
@@ -150,7 +156,7 @@ public class ActivityLaunchAnimator {
                        }
                    }
                }
                        int targetWidth = app.sourceContainerBounds.width();
                int targetWidth = primary.sourceContainerBounds.width();
                int notificationHeight = mSourceNotification.getActualHeight()
                        - mSourceNotification.getClipBottomAmount();
                int notificationWidth = mSourceNotification.getWidth();
@@ -168,12 +174,12 @@ public class ActivityLaunchAnimator {
                        mParams.left = (int) ((targetWidth - newWidth) / 2.0f);
                        mParams.right = mParams.left + newWidth;
                        mParams.top = (int) MathUtils.lerp(mParams.startPosition[1],
                                        app.position.y, progress);
                                primary.position.y, progress);
                        mParams.bottom = (int) MathUtils.lerp(mParams.startPosition[1]
                                        + notificationHeight,
                                        app.position.y + app.sourceContainerBounds.bottom,
                                primary.position.y + primary.sourceContainerBounds.bottom,
                                progress);
                                applyParamsToWindow(app);
                        applyParamsToWindow(primary);
                        applyParamsToNotification(mParams);
                        applyParamsToNotificationList(mParams);
                    }
@@ -185,19 +191,32 @@ public class ActivityLaunchAnimator {
                        if (mInstantCollapsePanel) {
                            mStatusBar.collapsePanel(false /* animate */);
                        }
                        invokeCallback(iRemoteAnimationFinishedCallback);
                    }
                });
                anim.start();
                setAnimationPending(false);
            });
        }

        private void invokeCallback(IRemoteAnimationFinishedCallback callback) {
            try {
                                    iRemoteAnimationFinishedCallback.onAnimationFinished();
                callback.onAnimationFinished();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
                        });
                        anim.start();

        private RemoteAnimationTarget getPrimaryRemoteAnimationTarget(
                RemoteAnimationTarget[] remoteAnimationTargets) {
            RemoteAnimationTarget primary = null;
            for (RemoteAnimationTarget app : remoteAnimationTargets) {
                if (app.mode == RemoteAnimationTarget.MODE_OPENING) {
                    primary = app;
                    break;
                }
            }
                setAnimationPending(false);
            });
            return primary;
        }

        private void setExpandAnimationRunning(boolean running) {