Merge "Refactor: Update the way tintAmount is propagated to TTV" into main

This commit is contained in:
Treehugger Robot
2025-02-05 11:16:02 -08:00
committed by Android (Google) Code Review
5 changed files with 5 additions and 24 deletions
@@ -68,8 +68,6 @@ class TaskViewModel(
)
}
val tintAmount: Flow<Float> = recentsViewData.tintAmount
val state: Flow<TaskTileUiState> =
combine(taskData, isLiveTile) { tasks, isLiveTile -> mapToTaskTile(tasks, isLiveTile) }
.distinctUntilChanged()
@@ -27,9 +27,6 @@ class RecentsViewData {
// 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. */
@@ -42,10 +42,6 @@ class RecentsViewModel(
recentsViewData.overlayEnabled.value = isOverlayEnabled
}
fun setTintAmount(tintAmount: Float) {
recentsViewData.tintAmount.value = tintAmount
}
fun updateThumbnailSplashProgress(taskThumbnailSplashAlpha: Float) {
recentsViewData.thumbnailSplashProgress.value = taskThumbnailSplashAlpha
}
@@ -241,8 +241,8 @@ import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlinx.coroutines.CoroutineScope;
import java.util.ArrayList;
@@ -6567,10 +6567,6 @@ public abstract class RecentsView<
private void setColorTint(float tintAmount) {
mColorTint = tintAmount;
if (enableRefactorTaskThumbnail()) {
mRecentsViewModel.setTintAmount(tintAmount);
}
for (TaskView taskView : getTaskViews()) {
taskView.setColorTint(mColorTint, mTintingColor);
}
@@ -33,6 +33,7 @@ import android.util.Log
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.Job
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. */
@@ -742,18 +741,11 @@ constructor(
// The TaskView lifecycle is starts the ViewModel during onBind, and cleans it in
// 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 @@ constructor(
/** 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)