From 604906bb3c5c3f585677034c766d07fcb5945315 Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Wed, 26 Feb 2025 16:51:37 +0000 Subject: [PATCH] Skip animation when clicking on menu action from App Chip Menu. Also, skips chip collapse animation when isSplitSelection is active to improve the performance. This animation is not visible for the user, so we reduced the duration to 0 and reset the chip to the correct state. Bug: 398318613 Flag: com.android.launcher3.enable_overview_icon_menu Test: OverviewImageTest Change-Id: I79d543167eb172e6d3a8306122035396e9ee2e7c --- .../android/quickstep/views/IconAppChipView.kt | 3 ++- .../com/android/quickstep/views/TaskMenuView.kt | 17 +++++++++-------- .../src/com/android/quickstep/views/TaskView.kt | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/IconAppChipView.kt b/quickstep/src/com/android/quickstep/views/IconAppChipView.kt index 85d14cc5ab..8d535524f5 100644 --- a/quickstep/src/com/android/quickstep/views/IconAppChipView.kt +++ b/quickstep/src/com/android/quickstep/views/IconAppChipView.kt @@ -296,7 +296,7 @@ constructor( fun getMenuTranslationY(): MultiPropertyFactory.MultiProperty = viewTranslationY[INDEX_MENU_TRANSLATION] - internal fun revealAnim(isRevealing: Boolean) { + internal fun revealAnim(isRevealing: Boolean, animated: Boolean = true) { cancelInProgressAnimations() val collapsedBackgroundBounds = getCollapsedBackgroundLtrBounds() val expandedBackgroundBounds = getExpandedBackgroundLtrBounds() @@ -392,6 +392,7 @@ constructor( animator!!.setDuration(MENU_BACKGROUND_HIDE_DURATION.toLong()) } + if (!animated) animator!!.duration = 0 animator!!.interpolator = Interpolators.EMPHASIZED animator!!.start() } diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt index 95336cfe19..4777f4f140 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt @@ -75,7 +75,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : if (ev.action == MotionEvent.ACTION_DOWN) { if (!recentsViewContainer.dragLayer.isEventOverView(this, ev)) { // TODO: log this once we have a new container type for it? - close(true) + animateOpenOrClosed(true) return true } } @@ -83,7 +83,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : } override fun handleClose(animate: Boolean) { - animateClose() + animateOpenOrClosed(true, animated = false) } override fun isOfType(type: Int): Boolean = (type and TYPE_TASK_MENU) != 0 @@ -260,11 +260,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : private val iconView: View get() = taskContainer.iconView.asView() - private fun animateClose() { - animateOpenOrClosed(true) - } - - private fun animateOpenOrClosed(closing: Boolean) { + private fun animateOpenOrClosed(closing: Boolean, animated: Boolean = true) { openCloseAnimator?.let { if (it.isRunning) it.cancel() } openCloseAnimator = AnimatorSet() // If we're opening, we just start from the beginning as a new `TaskMenuView` is created @@ -312,7 +308,12 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : } } ) - val animationDuration = if (closing) REVEAL_CLOSE_DURATION else REVEAL_OPEN_DURATION + val animationDuration = + when { + animated && closing -> REVEAL_CLOSE_DURATION + animated && !closing -> REVEAL_OPEN_DURATION + else -> 0L + } openCloseAnimator!!.setDuration(animationDuration) openCloseAnimator!!.start() } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 27db6d6188..c5b8e8cca1 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -1476,7 +1476,8 @@ constructor( return if (enableOverviewIconMenu() && menuContainer.iconView is IconAppChipView) { menuContainer.iconView.revealAnim(/* isRevealing= */ true) TaskMenuView.showForTask(menuContainer) { - menuContainer.iconView.revealAnim(/* isRevealing= */ false) + val isAnimated = !recentsView.isSplitSelectionActive + menuContainer.iconView.revealAnim(/* isRevealing= */ false, isAnimated) if (enableHoverOfChildElementsInTaskview()) { recentsView.setTaskBorderEnabled(true) }