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

Commit 8116540c authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Extend notif lifetime if not anim activity launch" into tm-dev

parents 945c56f2 a725209c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class NotificationLaunchAnimatorControllerProvider @Inject constructor(
    @JvmOverloads
    fun getAnimatorController(
        notification: ExpandableNotificationRow,
        onFinishAnimationCallback: Runnable = Runnable {}
        onFinishAnimationCallback: Runnable? = null
    ): NotificationLaunchAnimatorController {
        return NotificationLaunchAnimatorController(
            notificationShadeWindowViewController,
@@ -49,7 +49,7 @@ class NotificationLaunchAnimatorController(
    private val headsUpManager: HeadsUpManagerPhone,
    private val notification: ExpandableNotificationRow,
    private val jankMonitor: InteractionJankMonitor,
    private val onFinishAnimationCallback: Runnable
    private val onFinishAnimationCallback: Runnable?
) : ActivityLaunchAnimator.Controller {

    companion object {
@@ -123,7 +123,7 @@ class NotificationLaunchAnimatorController(

        if (!willAnimate) {
            removeHun(animate = true)
            onFinishAnimationCallback.run()
            onFinishAnimationCallback?.run()
        }
    }

@@ -142,7 +142,7 @@ class NotificationLaunchAnimatorController(
        notificationShadeWindowViewController.setExpandAnimationRunning(false)
        notificationEntry.isExpandAnimationRunning = false
        removeHun(animate = true)
        onFinishAnimationCallback.run()
        onFinishAnimationCallback?.run()
    }

    override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) {
@@ -162,7 +162,7 @@ class NotificationLaunchAnimatorController(
        notificationListContainer.setExpandingNotification(null)
        applyParams(null)
        removeHun(animate = false)
        onFinishAnimationCallback.run()
        onFinishAnimationCallback?.run()
    }

    private fun applyParams(params: ExpandAnimationParameters?) {
+15 −4
Original line number Diff line number Diff line
@@ -397,15 +397,25 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
            mMainThreadHandler.post(() -> {
                final Runnable removeNotification = () -> {
                    mOnUserInteractionCallback.onDismiss(entry, REASON_CLICK, summaryToRemove);
                    if (!animate) {
                        // If we're animating, this would be invoked after the activity launch
                        // animation completes. Since we're not animating, the launch already
                        // happened synchronously, so we notify the launch is complete here after
                        // onDismiss.
                        mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry);
                    }
                };
                if (mPresenter.isCollapsing()) {
                    // To avoid lags we're only performing the remove
                    // after the shade is collapsed
                    // To avoid lags we're only performing the remove after the shade is collapsed
                    mShadeController.addPostCollapseAction(removeNotification);
                } else {
                    removeNotification.run();
                }
            });
        } else if (!canBubble && !animate) {
            // Not animating, this is the end of the launch flow (see above comment for more info).
            mMainThreadHandler.post(
                    () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry));
        }

        mIsCollapsingToShowActivityOverLockscreen = false;
@@ -481,8 +491,9 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte
            boolean isActivityIntent) {
        mLogger.logStartNotificationIntent(entry.getKey(), intent);
        try {
            Runnable onFinishAnimationCallback =
                    () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry);
            Runnable onFinishAnimationCallback = animate
                    ? () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry)
                    : null;
            ActivityLaunchAnimator.Controller animationController =
                    new StatusBarLaunchAnimatorController(
                            mNotificationAnimationProvider
+11 −0
Original line number Diff line number Diff line
@@ -447,4 +447,15 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase {
        controllerCaptor.getValue().onIntentStarted(false);
        verify(listener).onFinishLaunchNotifActivity(mNotificationRow.getEntry());
    }

    @Test
    public void testNotifActivityStarterEventSourceFinishEvent_postPanelCollapse_noAnimate() {
        NotifActivityLaunchEvents.Listener listener =
                mock(NotifActivityLaunchEvents.Listener.class);
        mLaunchEventsEmitter.registerListener(listener);
        when(mCentralSurfaces.shouldAnimateLaunch(anyBoolean())).thenReturn(false);
        mNotificationActivityStarter
                .onNotificationClicked(mNotificationRow.getEntry().getSbn(), mNotificationRow);
        verify(listener).onFinishLaunchNotifActivity(mNotificationRow.getEntry());
    }
}