Refactor: Update the way tintAmount is propagated to TTV
- Propagate the tintAmount using the Views instead of using a Flow.
This was done to minimize the usage of Flows to propagate animations
and progress through Views. It should improve the overall performance
of UI updates
Some stats about the number of collections:
- Entering Overview: ~4 collections
- Displaying Scrim: ~32 collections
- Hiding Scrim: ~35 collections
- With 4 apps on screen: ~140 collections
Bug: 390581380
Doc: go/launcher-overview-unified-taskviewmodel
Flag: com.android.launcher3.enable_refactor_task_thumbnail
Test: OverviewImageTest
Test: TaskViewModelTest
Change-Id: Ice68edef12c7e3b2a26107b0fc6e62578de241b4
diff --git a/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt b/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt
index 4936e30..961446f 100644
--- a/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt
+++ b/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt
@@ -68,8 +68,6 @@
)
}
- val tintAmount: Flow<Float> = recentsViewData.tintAmount
-
val state: Flow<TaskTileUiState> =
combine(taskData, isLiveTile) { tasks, isLiveTile -> mapToTaskTile(tasks, isLiveTile) }
.distinctUntilChanged()
diff --git a/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewData.kt b/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewData.kt
index 4cd7ef1..a1f8454 100644
--- a/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewData.kt
+++ b/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewData.kt
@@ -27,9 +27,6 @@
// The settled set of visible taskIds that is updated after RecentsView scroll settles.
val settledFullyVisibleTaskIds = MutableStateFlow(emptySet<Int>())
- // Color tint on foreground scrim
- val tintAmount = MutableStateFlow(0f)
-
val thumbnailSplashProgress = MutableStateFlow(0f)
// A list of taskIds that are associated with a RecentsAnimationController. */
diff --git a/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewModel.kt b/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewModel.kt
index 25487b4..73332fc 100644
--- a/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewModel.kt
+++ b/quickstep/src/com/android/quickstep/recents/viewmodel/RecentsViewModel.kt
@@ -42,10 +42,6 @@
recentsViewData.overlayEnabled.value = isOverlayEnabled
}
- fun setTintAmount(tintAmount: Float) {
- recentsViewData.tintAmount.value = tintAmount
- }
-
fun updateThumbnailSplashProgress(taskThumbnailSplashAlpha: Float) {
recentsViewData.thumbnailSplashProgress.value = taskThumbnailSplashAlpha
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 5ebb603..3d34d2e 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -241,8 +241,8 @@
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
-
import kotlin.jvm.functions.Function0;
+
import kotlinx.coroutines.CoroutineScope;
import java.util.ArrayList;
@@ -6567,10 +6567,6 @@
private void setColorTint(float tintAmount) {
mColorTint = tintAmount;
- if (enableRefactorTaskThumbnail()) {
- mRecentsViewModel.setTintAmount(tintAmount);
- }
-
for (TaskView taskView : getTaskViews()) {
taskView.setColorTint(mColorTint, mTintingColor);
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index 062955b..1720110 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -33,6 +33,7 @@
import android.view.Display
import android.view.MotionEvent
import android.view.View
+import android.view.View.OnClickListener
import android.view.ViewGroup
import android.view.ViewStub
import android.view.accessibility.AccessibilityNodeInfo
@@ -98,8 +99,6 @@
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.collectLatest
-import kotlinx.coroutines.flow.launchIn
-import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
/** A task in the Recents view. */
@@ -743,17 +742,10 @@
// onRecycle. So it should be initialized at this point. TaskView Lifecycle:
// `bind` -> `onBind` -> onAttachedToWindow() -> onDetachFromWindow -> onRecycle
coroutineJobs +=
- viewModel!!.tintAmount.onEach(::updateTintAmount).launchIn(coroutineScope)
-
- coroutineJobs +=
coroutineScope.launch { viewModel!!.state.collectLatest(::updateTaskViewState) }
}
}
- private fun updateTintAmount(amount: Float) {
- taskContainers.forEach { it.updateTintAmount(amount) }
- }
-
private fun updateTaskViewState(state: TaskTileUiState) {
sysUiStatusNavFlags = state.sysUiStatusNavFlags
@@ -1531,7 +1523,9 @@
/** Set a color tint on the snapshot and supporting views. */
open fun setColorTint(amount: Float, tintColor: Int) {
taskContainers.forEach {
- if (!enableRefactorTaskThumbnail()) {
+ if (enableRefactorTaskThumbnail()) {
+ it.updateTintAmount(amount)
+ } else {
it.thumbnailViewDeprecated.dimAlpha = amount
}
it.iconView.setIconColorTint(tintColor, amount)