Merge "Extend notif lifetime if not anim activity launch" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8116540ce9
@@ -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?) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user