Refactor: Update task container and thumbnail dimming progress

This commit updates the mechanism for dimming task containers and thumbnails in the recents view. These changes simplify the dimming logic and improve the performance of the recents view. It reduces the usage of Flows to propagate progress and animation states through the views and view models.

The following changes were made:

- The `TaskThumbnailViewModel` no longer provides a dimming level.
- The `TaskViewModel` now provides a `tintAmount` flow that represents the dimming level for a task.
- The `TaskContainer` and `TaskThumbnailView` now use the `tintAmount` flow to update their dimming level.
- The `TaskContainer` now also updates the dimming level based on the menu open progress.
- The `TaskThumbnailView` now uses a `MultiPropertyFactory` to manage the dimming level, allowing it to be controlled by both the tint amount and the menu open progress.

Bug: 390581380
Doc: go/launcher-overview-unified-taskviewmodel
Flag: com.android.launcher3.enable_refactor_task_thumbnail
Test: OverviewImageTest
Test: TaskViewModelTest
Test: TaskThumbnailViewModelImplTest
Test: TaskThumbnailViewScreenshotTest
Change-Id: I04d5dee534d56857b977d7f3ed6d4eda9f93be45
This commit is contained in:
Jordan Silva
2025-01-28 10:33:36 +00:00
parent fe4152e608
commit beb6122fbe
12 changed files with 74 additions and 63 deletions
@@ -23,11 +23,8 @@ import com.android.launcher3.util.TestDispatcherProvider
import com.android.quickstep.recents.usecase.GetThumbnailPositionUseCase
import com.android.quickstep.recents.usecase.ThumbnailPositionState.MatrixScaling
import com.android.quickstep.recents.usecase.ThumbnailPositionState.MissingThumbnail
import com.android.quickstep.recents.viewmodel.RecentsViewData
import com.android.quickstep.task.viewmodel.TaskContainerData
import com.android.quickstep.task.viewmodel.TaskThumbnailViewModelImpl
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
@@ -45,16 +42,12 @@ class TaskThumbnailViewModelImplTest {
private val dispatcher = StandardTestDispatcher()
private val testScope = TestScope(dispatcher)
private val recentsViewData = RecentsViewData()
private val taskContainerData = TaskContainerData()
private val dispatcherProvider = TestDispatcherProvider(dispatcher)
private val mGetThumbnailPositionUseCase = mock<GetThumbnailPositionUseCase>()
private val splashAlphaUseCase: SplashAlphaUseCase = mock()
private val systemUnderTest by lazy {
TaskThumbnailViewModelImpl(
recentsViewData,
taskContainerData,
dispatcherProvider,
mGetThumbnailPositionUseCase,
splashAlphaUseCase,
@@ -93,30 +86,6 @@ class TaskThumbnailViewModelImplTest {
.isEqualTo(MATRIX)
}
@Test
fun getForegroundScrimDimProgress_returnsForegroundMaxScrim() =
testScope.runTest {
recentsViewData.tintAmount.value = 0.32f
taskContainerData.taskMenuOpenProgress.value = 0f
assertThat(systemUnderTest.dimProgress.first()).isEqualTo(0.32f)
}
@Test
fun getTaskMenuScrimDimProgress_returnsTaskMenuScrim() =
testScope.runTest {
recentsViewData.tintAmount.value = 0f
taskContainerData.taskMenuOpenProgress.value = 1f
assertThat(systemUnderTest.dimProgress.first()).isEqualTo(0.4f)
}
@Test
fun getForegroundScrimDimProgress_returnsNoScrim() =
testScope.runTest {
recentsViewData.tintAmount.value = 0f
taskContainerData.taskMenuOpenProgress.value = 0f
assertThat(systemUnderTest.dimProgress.first()).isEqualTo(0f)
}
private companion object {
const val CANVAS_WIDTH = 300
const val CANVAS_HEIGHT = 600