Merge "Inflate TaskThumbnailViewDeprecated as TaskContentView" into main

This commit is contained in:
Treehugger Robot authored and Android (Google) Code Review committed 2025-03-18 05:35:14 -07:00
commit 1f500d3cd3
4 files changed
+53 -19

No files matched your search

@@ -78,14 +78,27 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu
private val contentViewFullscreenParams = FullscreenDrawParams(context)
private val taskThumbnailViewDeprecatedPool =
if (!enableRefactorTaskThumbnail()) {
ViewPool<TaskThumbnailViewDeprecated>(
context,
this,
R.layout.task_thumbnail_deprecated,
VIEW_POOL_MAX_SIZE,
VIEW_POOL_INITIAL_SIZE,
)
} else null
private val taskContentViewPool =
ViewPool<TaskContentView>(
context,
this,
R.layout.task_content_view,
VIEW_POOL_MAX_SIZE,
VIEW_POOL_INITIAL_SIZE,
)
if (enableRefactorTaskThumbnail()) {
ViewPool<TaskContentView>(
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<TaskThumbnailView>(R.id.snapshot)
} else {
taskContentView.findViewById<TaskThumbnailViewDeprecated>(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() {
@@ -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<ViewStub>(R.id.bottomright_task_content_view)
?.apply { layoutResource = R.layout.task_content_view }
?.apply { layoutResource = taskContentViewLayoutId }
?.inflate()
findViewById<ViewStub>(R.id.bottomRight_icon)
?.apply {
@@ -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,
@@ -764,8 +764,12 @@ constructor(
}
protected open fun inflateViewStubs() {
val taskContentViewLayoutId =
if (enableRefactorTaskThumbnail()) R.layout.task_content_view
else R.layout.task_thumbnail_deprecated
findViewById<ViewStub>(R.id.task_content_view)
?.apply { layoutResource = R.layout.task_content_view }
?.apply { layoutResource = taskContentViewLayoutId }
?.inflate()
findViewById<ViewStub>(R.id.icon)
@@ -935,7 +939,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 +978,15 @@ constructor(
): TaskContainer =
traceSection("TaskView.createTaskContainer") {
val iconView = findViewById<View>(iconViewId) as TaskViewIcon
val taskContentView = findViewById<TaskContentView>(taskContentViewId)
val taskContentView = findViewById<View>(taskContentViewId)
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 +1807,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)
}