From bba7e8af3735ae4f9113f471c96d476118bd8a24 Mon Sep 17 00:00:00 2001 From: Sam Cackett Date: Fri, 14 Mar 2025 04:55:32 -0700 Subject: [PATCH] Inflate TaskThumbnailViewDeprecated as TaskContentView If the enableRefactorTaskThumbnail is false, then inflate TaskThumbnailViewDeprecated as TaskContentView so that the behaviour matches the previous pre-factor behaviour Fix: 402277471 Flag: com.android.launcher3.enable_refactor_task_thumbnail Test: Manual. See bug Change-Id: Ie62d4d83d0a16d965820d2a218a44478b660a806 --- .../quickstep/views/DesktopTaskView.kt | 41 ++++++++++++++----- .../quickstep/views/GroupedTaskView.kt | 6 ++- .../android/quickstep/views/TaskContainer.kt | 7 +++- .../com/android/quickstep/views/TaskView.kt | 18 +++++--- 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt index 27657b4c0f..5c60798f3e 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt @@ -73,14 +73,27 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu private val contentViewFullscreenParams = FullscreenDrawParams(context) + private val taskThumbnailViewDeprecatedPool = + if (!enableRefactorTaskThumbnail()) { + ViewPool( + context, + this, + R.layout.task_thumbnail_deprecated, + VIEW_POOL_MAX_SIZE, + VIEW_POOL_INITIAL_SIZE, + ) + } else null + private val taskContentViewPool = - ViewPool( - context, - this, - R.layout.task_content_view, - VIEW_POOL_MAX_SIZE, - VIEW_POOL_INITIAL_SIZE, - ) + if (enableRefactorTaskThumbnail()) { + ViewPool( + context, + this, + R.layout.task_content_view, + VIEW_POOL_MAX_SIZE, + VIEW_POOL_INITIAL_SIZE, + ) + } else null private val tempPointF = PointF() private val lastComputedTaskSize = Rect() @@ -249,7 +262,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu if ( enableDesktopRecentsTransitionsCornersBugfix() && enableRefactorTaskThumbnail() ) { - it.taskContentView?.outlineBounds = + (it.taskContentView as TaskContentView).outlineBounds = if (intersects(overviewTaskPosition, screenRect)) Rect(overviewTaskPosition).apply { intersectUnchecked(screenRect) @@ -300,13 +313,15 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu val backgroundViewIndex = contentView.indexOfChild(backgroundView) taskContainers = tasks.map { task -> - val taskContentView = taskContentViewPool.view + val taskContentView = + if (enableRefactorTaskThumbnail()) taskContentViewPool!!.view + else taskThumbnailViewDeprecatedPool!!.view contentView.addView(taskContentView, backgroundViewIndex + 1) val snapshotView = if (enableRefactorTaskThumbnail()) { taskContentView.findViewById(R.id.snapshot) } else { - taskContentView.findViewById(R.id.snapshot) + taskContentView } TaskContainer( @@ -466,7 +481,11 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu private fun removeAndRecycleThumbnailView(taskContainer: TaskContainer) { contentView.removeView(taskContainer.taskContentView) - taskContentViewPool.recycle(taskContainer.taskContentView) + if (enableRefactorTaskThumbnail()) { + taskContentViewPool!!.recycle(taskContainer.taskContentView as TaskContentView) + } else { + taskThumbnailViewDeprecatedPool!!.recycle(taskContainer.thumbnailViewDeprecated) + } } private fun updateTaskPositions() { diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt index 71a4dde395..b8dadce65a 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt @@ -24,6 +24,7 @@ import android.view.View import android.view.ViewStub import com.android.internal.jank.Cuj import com.android.launcher3.Flags.enableOverviewIconMenu +import com.android.launcher3.Flags.enableRefactorTaskThumbnail import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.util.RunnableList @@ -94,8 +95,11 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu override fun inflateViewStubs() { super.inflateViewStubs() + val taskContentViewLayoutId = + if (enableRefactorTaskThumbnail()) R.layout.task_content_view + else R.layout.task_thumbnail_deprecated findViewById(R.id.bottomright_task_content_view) - ?.apply { layoutResource = R.layout.task_content_view } + ?.apply { layoutResource = taskContentViewLayoutId } ?.inflate() findViewById(R.id.bottomRight_icon) ?.apply { diff --git a/quickstep/src/com/android/quickstep/views/TaskContainer.kt b/quickstep/src/com/android/quickstep/views/TaskContainer.kt index afe7e928ad..a98b17dbce 100644 --- a/quickstep/src/com/android/quickstep/views/TaskContainer.kt +++ b/quickstep/src/com/android/quickstep/views/TaskContainer.kt @@ -40,7 +40,8 @@ import com.android.systemui.shared.recents.model.ThumbnailData class TaskContainer( val taskView: TaskView, val task: Task, - val taskContentView: TaskContentView, + // TODO(b/361500574): Upon flag cleanup, use the TaskContentView type and remove the getter + val taskContentView: View, val snapshotView: View, val iconView: TaskViewIcon, /** @@ -62,8 +63,10 @@ class TaskContainer( init { if (enableRefactorTaskThumbnail()) { + require(taskContentView is TaskContentView) require(snapshotView is TaskThumbnailView) } else { + require(taskContentView is TaskThumbnailViewDeprecated) require(snapshotView is TaskThumbnailViewDeprecated) } } @@ -174,7 +177,7 @@ class TaskContainer( clickCloseListener: OnClickListener?, ) = traceSection("TaskContainer.setState") { - taskContentView.setState( + (taskContentView as TaskContentView).setState( TaskUiStateMapper.toTaskHeaderState(state, hasHeader, clickCloseListener), TaskUiStateMapper.toTaskThumbnailUiState(state, liveTile), state?.taskId, diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 8d95b131bf..24e6fc92b3 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -722,8 +722,12 @@ constructor( } protected open fun inflateViewStubs() { + val taskContentViewLayoutId = + if (enableRefactorTaskThumbnail()) R.layout.task_content_view + else R.layout.task_thumbnail_deprecated + findViewById(R.id.task_content_view) - ?.apply { layoutResource = R.layout.task_content_view } + ?.apply { layoutResource = taskContentViewLayoutId } ?.inflate() findViewById(R.id.icon) @@ -893,7 +897,7 @@ constructor( taskContainers.forEach { container -> container.bind() if (enableRefactorTaskThumbnail()) { - container.taskContentView.cornerRadius = + (container.taskContentView as TaskContentView).cornerRadius = thumbnailFullscreenParams.currentCornerRadius container.taskContentView.doOnSizeChange { width, height -> updateThumbnailValidity(container) @@ -932,12 +936,15 @@ constructor( ): TaskContainer = traceSection("TaskView.createTaskContainer") { val iconView = findViewById(iconViewId) as TaskViewIcon - val taskContentView = findViewById(taskContentViewId) + val taskContentView = findViewById(taskContentViewId) + val snapshotView = + if (enableRefactorTaskThumbnail()) taskContentView.findViewById(thumbnailViewId) + else taskContentView return TaskContainer( this, task, taskContentView, - taskContentView.findViewById(thumbnailViewId), + snapshotView, iconView, TransformingTouchDelegate(iconView.asView()), stagePosition, @@ -1752,7 +1759,8 @@ constructor( updateFullscreenParams(thumbnailFullscreenParams) taskContainers.forEach { if (enableRefactorTaskThumbnail()) { - it.taskContentView.cornerRadius = thumbnailFullscreenParams.currentCornerRadius + (it.taskContentView as TaskContentView).cornerRadius = + thumbnailFullscreenParams.currentCornerRadius } else { it.thumbnailViewDeprecated.setFullscreenParams(thumbnailFullscreenParams) }