From 3519785d79fbd499b1cee80ac4d0fcb66d583f32 Mon Sep 17 00:00:00 2001 From: Shamali P Date: Thu, 17 Apr 2025 15:25:11 +0000 Subject: [PATCH] Change task content view to be a constraint layout. This is for child cl to be able to place dwb inline in it. Bug: 405359383 Flag: com.android.launcher3.enable_refactor_task_content_view Test: Screenshot tests Change-Id: Id3252fff5776c199ae2a0c7e89d96c423241478c --- quickstep/res/layout/task_content_view.xml | 17 +++++++++++++---- .../quickstep/task/thumbnail/TaskContentView.kt | 15 +++++++++++++-- .../thumbnail/TaskContentViewScreenshotTest.kt | 15 ++++++++++++--- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/quickstep/res/layout/task_content_view.xml b/quickstep/res/layout/task_content_view.xml index 478ee55c06..62277919f6 100644 --- a/quickstep/res/layout/task_content_view.xml +++ b/quickstep/res/layout/task_content_view.xml @@ -14,21 +14,30 @@ ~ limitations under the License. --> + android:layout_height="wrap_content" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + /> - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + /> \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/task/thumbnail/TaskContentView.kt b/quickstep/src/com/android/quickstep/task/thumbnail/TaskContentView.kt index a010f81c1f..184d863c45 100644 --- a/quickstep/src/com/android/quickstep/task/thumbnail/TaskContentView.kt +++ b/quickstep/src/com/android/quickstep/task/thumbnail/TaskContentView.kt @@ -24,7 +24,8 @@ import android.util.AttributeSet import android.view.View import android.view.ViewOutlineProvider import android.view.ViewStub -import android.widget.LinearLayout +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.constraintlayout.widget.ConstraintSet import androidx.core.view.isInvisible import com.android.launcher3.R import com.android.launcher3.util.ViewPool @@ -35,7 +36,7 @@ import com.android.quickstep.views.TaskHeaderView * DWB, AiAi (TaskOverlay). */ class TaskContentView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : - LinearLayout(context, attrs), ViewPool.Reusable { + ConstraintLayout(context, attrs), ViewPool.Reusable { private var taskHeaderView: TaskHeaderView? = null private var taskThumbnailView: TaskThumbnailView? = null @@ -123,6 +124,16 @@ class TaskContentView @JvmOverloads constructor(context: Context, attrs: Attribu findViewById(R.id.task_header_view) .apply { layoutResource = R.layout.task_header_view } .inflate() as TaskHeaderView + + // TODO: Move to layout xml when moving away from view stubs. + val constraintSet = ConstraintSet().apply { clone(this@TaskContentView) } + constraintSet.connect( + R.id.snapshot, + ConstraintSet.TOP, + R.id.task_header_view, + ConstraintSet.BOTTOM, + ) + constraintSet.applyTo(this@TaskContentView) } } diff --git a/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskContentViewScreenshotTest.kt b/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskContentViewScreenshotTest.kt index 5e546f7f1a..e3b27f0359 100644 --- a/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskContentViewScreenshotTest.kt +++ b/quickstep/tests/multivalentScreenshotTests/src/com/android/quickstep/task/thumbnail/TaskContentViewScreenshotTest.kt @@ -61,7 +61,10 @@ class TaskContentViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { @Test fun taskContentView_recyclesToUninitialized() { - screenshotRule.screenshotTest("taskContentView_uninitialized") { activity -> + screenshotRule.screenshotTest( + "taskContentView_uninitialized", + ViewScreenshotTestRule.Mode.MatchSize, + ) { activity -> activity.actionBar?.hide() val taskContentView = createTaskContentView(activity) taskContentView.setState( @@ -76,7 +79,10 @@ class TaskContentViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { @Test fun taskContentView_shows_thumbnail_and_header() { - screenshotRule.screenshotTest("taskContentView_shows_thumbnail_and_header") { activity -> + screenshotRule.screenshotTest( + "taskContentView_shows_thumbnail_and_header", + ViewScreenshotTestRule.Mode.MatchSize, + ) { activity -> activity.actionBar?.hide() createTaskContentView(activity).apply { setState( @@ -95,7 +101,10 @@ class TaskContentViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { @Test fun taskContentView_scaled_roundRoundedCorners() { - screenshotRule.screenshotTest("taskContentView_scaledRoundedCorners") { activity -> + screenshotRule.screenshotTest( + "taskContentView_scaledRoundedCorners", + ViewScreenshotTestRule.Mode.MatchSize, + ) { activity -> activity.actionBar?.hide() createTaskContentView(activity).apply { scaleX = 0.75f