Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1129650e authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Collect the icon tint from the StateFlow

The previous code only picked the initial tint value and wouldn't get updated

Test: manually on demo mode
Fixes: 402605944
Flag: com.android.settingslib.flags.new_status_bar_icons
Flag: com.android.systemui.status_bar_root_modernization
Change-Id: I6e5eaa39d3ebf527e026f1d15bd0b906ffb581fe
parent b6accbf1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ package com.android.systemui.statusbar.pipeline.mobile.ui.binder

import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags
import com.android.systemui.kairos.ExperimentalKairosApi
@@ -48,7 +50,7 @@ object StackedMobileIconBinder {
        return SingleBindableStatusBarComposeIconView.withDefaultBinding(
            view = view,
            shouldBeVisible = { mobileIconsViewModel.isStackable.value },
        ) { _, tint ->
        ) { _, tintFlow ->
            view.repeatWhenAttached {
                repeatOnLifecycle(Lifecycle.State.STARTED) {
                    view.composeView.apply {
@@ -66,8 +68,9 @@ object StackedMobileIconBinder {
                                        viewModelFactory.create()
                                    }
                                }
                            val tint by tintFlow.collectAsStateWithLifecycle()
                            if (viewModel.isIconVisible) {
                                CompositionLocalProvider(LocalContentColor provides Color(tint())) {
                                CompositionLocalProvider(LocalContentColor provides Color(tint)) {
                                    StackedMobileIcon(viewModel)
                                }
                            }
+3 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarV
import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewVisibilityHelper
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

/** Compose view that is bound to bindable_status_bar_compose_icon.xml */
class SingleBindableStatusBarComposeIconView(context: Context, attrs: AttributeSet?) :
@@ -78,7 +79,7 @@ class SingleBindableStatusBarComposeIconView(context: Context, attrs: AttributeS
        fun withDefaultBinding(
            view: SingleBindableStatusBarComposeIconView,
            shouldBeVisible: () -> Boolean,
            block: suspend LifecycleOwner.(View, () -> Int) -> Unit,
            block: suspend LifecycleOwner.(View, StateFlow<Int>) -> Unit,
        ): ModernStatusBarViewBinding {
            @StatusBarIconView.VisibleState
            val visibilityState: MutableStateFlow<Int> = MutableStateFlow(STATE_HIDDEN)
@@ -90,7 +91,7 @@ class SingleBindableStatusBarComposeIconView(context: Context, attrs: AttributeS

            view.repeatWhenAttached {
                // Child binding
                block(view) { iconTint.value }
                block(view, iconTint)

                lifecycleScope.launch {
                    repeatOnLifecycle(Lifecycle.State.STARTED) {
+11 −11

File changed.

Contains only whitespace changes.