diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt index 0a01d8b4ea..cf083916a9 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt @@ -17,9 +17,11 @@ package com.android.quickstep.util import com.android.launcher3.Flags.enableLargeDesktopWindowingTile +import com.android.quickstep.RecentsAnimationController import com.android.quickstep.views.DesktopTaskView import com.android.quickstep.views.TaskView import com.android.quickstep.views.TaskViewType +import com.android.systemui.shared.recents.model.ThumbnailData /** * Helper class for [com.android.quickstep.views.RecentsView]. This util class contains refactored @@ -68,4 +70,12 @@ class RecentsViewUtils { if (taskView?.isLargeTile == true) taskView else null } } + + fun screenshotTasks( + taskView: TaskView, + recentsAnimationController: RecentsAnimationController + ): Map = + taskView.taskContainers.associate { + it.task.key.id to recentsAnimationController.screenshotTask(it.task.key.id) + } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 255619ae9d..226ecf5063 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3058,14 +3058,15 @@ public abstract class RecentsView< } private void setRunningTaskViewShowScreenshot(boolean showScreenshot) { + setRunningTaskViewShowScreenshot(showScreenshot, /*updatedThumbnails=*/null); + } + + private void setRunningTaskViewShowScreenshot(boolean showScreenshot, + @Nullable Map updatedThumbnails) { mRunningTaskShowScreenshot = showScreenshot; TaskView runningTaskView = getRunningTaskView(); if (runningTaskView != null) { - runningTaskView.setShouldShowScreenshot(mRunningTaskShowScreenshot); - if (!enableRefactorTaskThumbnail()) { - runningTaskView.getTaskContainers().forEach( - taskContainer -> taskContainer.getThumbnailViewDeprecated().refresh()); - } + runningTaskView.setShouldShowScreenshot(mRunningTaskShowScreenshot, updatedThumbnails); } if (enableRefactorTaskThumbnail()) { mRecentsViewModel.setRunningTaskShowScreenshot(showScreenshot); @@ -6154,20 +6155,12 @@ public abstract class RecentsView< return; } + Map updatedThumbnails = mRecentsViewUtils.screenshotTasks(taskView, + mRecentsAnimationController); if (enableRefactorTaskThumbnail()) { - mHelper.switchToScreenshot(taskView, mRecentsAnimationController, onFinishRunnable); + mHelper.switchToScreenshot(taskView, updatedThumbnails, onFinishRunnable); } else { - setRunningTaskViewShowScreenshot(true); - for (TaskContainer container : taskView.getTaskContainers()) { - ThumbnailData thumbnailData = - mRecentsAnimationController.screenshotTask(container.getTask().key.id); - TaskThumbnailViewDeprecated thumbnailView = container.getThumbnailViewDeprecated(); - if (thumbnailData != null) { - thumbnailView.setThumbnail(container.getTask(), thumbnailData); - } else { - thumbnailView.refresh(); - } - } + setRunningTaskViewShowScreenshot(true, updatedThumbnails); ViewUtils.postFrameDrawn(taskView, onFinishRunnable); } } @@ -6186,8 +6179,7 @@ public abstract class RecentsView< if (enableRefactorTaskThumbnail()) { mHelper.switchToScreenshot(taskView, thumbnailDatas, onFinishRunnable); } else { - taskView.setShouldShowScreenshot(true); - taskView.refreshThumbnails(thumbnailDatas); + taskView.setShouldShowScreenshot(true, thumbnailDatas); ViewUtils.postFrameDrawn(taskView, onFinishRunnable); } } else { diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewModelHelper.kt b/quickstep/src/com/android/quickstep/views/RecentsViewModelHelper.kt index f5b217648a..4604b7022b 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewModelHelper.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewModelHelper.kt @@ -16,7 +16,6 @@ package com.android.quickstep.views -import com.android.quickstep.RecentsAnimationController import com.android.quickstep.ViewUtils import com.android.quickstep.recents.viewmodel.RecentsViewModel import com.android.systemui.shared.recents.model.ThumbnailData @@ -40,18 +39,6 @@ class RecentsViewModelHelper(private val recentsViewModel: RecentsViewModel) { viewAttachedScope.cancel("RecentsView detaching from window") } - fun switchToScreenshot( - taskView: TaskView, - recentsAnimationController: RecentsAnimationController, - onFinishRunnable: Runnable, - ) { - val updatedThumbnails = - taskView.taskContainers.associate { - it.task.key.id to recentsAnimationController.screenshotTask(it.task.key.id) - } - switchToScreenshot(taskView, updatedThumbnails, onFinishRunnable) - } - fun switchToScreenshot( taskView: TaskView, updatedThumbnails: Map?, diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 1f46fa74be..d2cdfa2bef 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -79,7 +79,6 @@ import com.android.launcher3.util.rects.set import com.android.launcher3.views.ActivityContext import com.android.quickstep.RecentsModel import com.android.quickstep.RemoteAnimationTargets -import com.android.quickstep.TaskAnimationManager import com.android.quickstep.TaskOverlayFactory import com.android.quickstep.TaskViewUtils import com.android.quickstep.orientation.RecentsPagedOrientationHandler @@ -408,6 +407,7 @@ constructor( protected var shouldShowScreenshot = false get() = !isRunningTask || field + private set /** Enable or disable showing border on hover and focus change */ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) @@ -974,7 +974,13 @@ constructor( iconView.setText(text) } - open fun refreshThumbnails(thumbnailDatas: Map?) { + @JvmOverloads + open fun setShouldShowScreenshot( + shouldShowScreenshot: Boolean, + thumbnailDatas: Map? = null + ) { + if (this.shouldShowScreenshot == shouldShowScreenshot) return + this.shouldShowScreenshot = shouldShowScreenshot if (enableRefactorTaskThumbnail()) { return }