From bca368924c44a8b2183fc04f50a18105aa4aaea7 Mon Sep 17 00:00:00 2001 From: Sam Cackett Date: Tue, 18 Mar 2025 10:54:23 -0700 Subject: [PATCH] Revert^2 "Inflate TaskThumbnailViewDeprecated as TaskContentView" This reverts commit 1048b2711c6edc43d1b34df5b4479bf6e32351d6. Reason for revert: Reland CL with fix Original message: 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 Bug: 403826044 Flag: com.android.launcher3.enable_refactor_task_thumbnail Test: Manual. See bug Change-Id: Ib43331023d99316c7b0c9de2ab81e379db58bb50 --- quickstep/res/layout/task.xml | 1 - quickstep/res/layout/task_grouped.xml | 2 - quickstep/res/values/ids.xml | 2 + .../orientation/LandscapePagedViewHandler.kt | 2 +- .../orientation/PortraitPagedViewHandler.kt | 3 +- .../orientation/SeascapePagedViewHandler.kt | 4 +- .../quickstep/views/DesktopTaskView.kt | 41 ++++++++++++++----- .../quickstep/views/GroupedTaskView.kt | 13 +++++- .../android/quickstep/views/TaskContainer.kt | 7 +++- .../com/android/quickstep/views/TaskView.kt | 24 ++++++++--- 10 files changed, 72 insertions(+), 27 deletions(-) diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index 4abfbbe152..def5a1e0a9 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -30,7 +30,6 @@ diff --git a/quickstep/res/layout/task_grouped.xml b/quickstep/res/layout/task_grouped.xml index a7c48561c8..a9a6dc1fc7 100644 --- a/quickstep/res/layout/task_grouped.xml +++ b/quickstep/res/layout/task_grouped.xml @@ -35,13 +35,11 @@ diff --git a/quickstep/res/values/ids.xml b/quickstep/res/values/ids.xml index c71bb762db..14928fd941 100644 --- a/quickstep/res/values/ids.xml +++ b/quickstep/res/values/ids.xml @@ -21,4 +21,6 @@ + + \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt index b8f43a4c36..7dff504f24 100644 --- a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt @@ -275,7 +275,7 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { desiredTaskId: Int, banner: View, ): Pair { - val snapshotParams = thumbnailViews[0].layoutParams as LinearLayout.LayoutParams + val snapshotParams = thumbnailViews[0].layoutParams as ViewGroup.MarginLayoutParams val translationX = banner.height.toFloat() val translationY: Float if (splitBounds == null) { diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt index 15eb69e47a..c6b2f3c0a7 100644 --- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt @@ -255,7 +255,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat } } else { if (desiredTaskId == splitBounds.leftTopTaskId) { - val snapshotParams = thumbnailViews[0].layoutParams as LinearLayout.LayoutParams + val snapshotParams = + thumbnailViews[0].layoutParams as ViewGroup.MarginLayoutParams val bottomRightTaskPlusDividerPercent = (splitBounds.rightBottomTaskPercent + splitBounds.dividerPercent) translationY = diff --git a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt index 80b50cbd83..f0b67efad0 100644 --- a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt @@ -25,8 +25,8 @@ import android.view.Gravity import android.view.Surface import android.view.View import android.view.View.MeasureSpec +import android.view.ViewGroup import android.widget.FrameLayout -import android.widget.LinearLayout import androidx.core.util.component1 import androidx.core.util.component2 import androidx.core.view.updateLayoutParams @@ -152,7 +152,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() { desiredTaskId: Int, banner: View, ): Pair { - val snapshotParams = thumbnailViews[0].layoutParams as LinearLayout.LayoutParams + val snapshotParams = thumbnailViews[0].layoutParams as ViewGroup.MarginLayoutParams val translationX: Float = (taskViewWidth - banner.height).toFloat() val translationY: Float if (splitBounds == null) { diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt index 8876633bd3..9d07b30ec0 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt @@ -78,14 +78,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() @@ -262,7 +275,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) @@ -313,13 +326,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( @@ -479,7 +494,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 10a2e902cb..3b8607b41c 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,16 @@ 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 { + inflatedId = + if (enableRefactorTaskThumbnail()) R.id.bottomright_task_content_view + else R.id.bottomright_snapshot + layoutResource = taskContentViewLayoutId + } ?.inflate() findViewById(R.id.bottomRight_icon) ?.apply { @@ -134,7 +143,7 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu createTaskContainer( secondaryTask, R.id.bottomright_task_content_view, - R.id.snapshot, + if (enableRefactorTaskThumbnail()) R.id.snapshot else R.id.bottomright_snapshot, R.id.bottomRight_icon, R.id.show_windows_right, R.id.bottomRight_digital_wellbeing_toast, 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 3835e48a9e..a30bb37ce4 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -764,8 +764,16 @@ 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 { + inflatedId = + if (enableRefactorTaskThumbnail()) R.id.task_content_view else R.id.snapshot + layoutResource = taskContentViewLayoutId + } ?.inflate() findViewById(R.id.icon) @@ -935,7 +943,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) @@ -974,12 +982,17 @@ constructor( ): TaskContainer = traceSection("TaskView.createTaskContainer") { val iconView = findViewById(iconViewId) as TaskViewIcon - val taskContentView = findViewById(taskContentViewId) + val taskContentView = + if (enableRefactorTaskThumbnail()) findViewById(taskContentViewId) + else findViewById(thumbnailViewId) + val snapshotView = + if (enableRefactorTaskThumbnail()) taskContentView.findViewById(thumbnailViewId) + else taskContentView return TaskContainer( this, task, taskContentView, - taskContentView.findViewById(thumbnailViewId), + snapshotView, iconView, TransformingTouchDelegate(iconView.asView()), stagePosition, @@ -1800,7 +1813,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) }