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

Commit 1e2886ce authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Spatial audio button should be toggled off when it's turned off" into main

parents 52897418 3cd05af0
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -69,9 +69,19 @@ class ButtonComponent(
                            role = Role.Button
                            contentDescription = label
                        },
                    color = MaterialTheme.colorScheme.tertiaryContainer,
                    color =
                        if (viewModel.isActive) {
                            MaterialTheme.colorScheme.tertiaryContainer
                        } else {
                            MaterialTheme.colorScheme.surface
                        },
                    shape = RoundedCornerShape(28.dp),
                    contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
                    contentColor =
                        if (viewModel.isActive) {
                            MaterialTheme.colorScheme.onTertiaryContainer
                        } else {
                            MaterialTheme.colorScheme.onSurface
                        },
                    onClick = onClick,
                ) {
                    Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+4 −4
Original line number Diff line number Diff line
@@ -40,14 +40,14 @@ import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.android.systemui.common.ui.compose.Icon
import com.android.systemui.volume.panel.component.button.ui.viewmodel.ToggleButtonViewModel
import com.android.systemui.volume.panel.component.button.ui.viewmodel.ButtonViewModel
import com.android.systemui.volume.panel.ui.composable.ComposeVolumePanelUiComponent
import com.android.systemui.volume.panel.ui.composable.VolumePanelComposeScope
import kotlinx.coroutines.flow.StateFlow

/** [ComposeVolumePanelUiComponent] implementing a toggleable button from a bottom row. */
class ToggleButtonComponent(
    private val viewModelFlow: StateFlow<ToggleButtonViewModel?>,
    private val viewModelFlow: StateFlow<ButtonViewModel?>,
    private val onCheckedChange: (isChecked: Boolean) -> Unit
) : ComposeVolumePanelUiComponent {

@@ -64,7 +64,7 @@ class ToggleButtonComponent(
        ) {
            BottomComponentButtonSurface {
                val colors =
                    if (viewModel.isChecked) {
                    if (viewModel.isActive) {
                        ButtonDefaults.buttonColors(
                            containerColor = MaterialTheme.colorScheme.tertiaryContainer,
                            contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
@@ -81,7 +81,7 @@ class ToggleButtonComponent(
                            role = Role.Switch
                            contentDescription = label
                        },
                    onClick = { onCheckedChange(!viewModel.isChecked) },
                    onClick = { onCheckedChange(!viewModel.isActive) },
                    shape = RoundedCornerShape(28.dp),
                    colors = colors
                ) {
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ constructor(
            VolumePanelUiEvent.VOLUME_PANEL_SPATIAL_AUDIO_POP_UP_SHOWN,
            0,
            null,
            viewModel.spatialAudioButtons.value.indexOfFirst { it.button.isChecked }
            viewModel.spatialAudioButtons.value.indexOfFirst { it.button.isActive }
        )
        volumePanelPopup.show(expandable, { Title() }, { Content(it) })
    }
@@ -85,7 +85,7 @@ constructor(
            for (buttonViewModel in enabledModelStates) {
                val label = buttonViewModel.button.label.toString()
                item(
                    isSelected = buttonViewModel.button.isChecked,
                    isSelected = buttonViewModel.button.isActive,
                    onItemSelected = { viewModel.setEnabled(buttonViewModel.model) },
                    contentDescription = label,
                    icon = { Icon(icon = buttonViewModel.button.icon) },
+2 −2
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ class CaptioningViewModelTest : SysuiTestCase() {
                val buttonViewModel by collectLastValue(underTest.buttonViewModel)
                runCurrent()

                assertThat(buttonViewModel!!.isChecked).isFalse()
                assertThat(buttonViewModel!!.isActive).isFalse()
            }
        }
    }
@@ -78,7 +78,7 @@ class CaptioningViewModelTest : SysuiTestCase() {
                val buttonViewModel by collectLastValue(underTest.buttonViewModel)
                runCurrent()

                assertThat(buttonViewModel!!.isChecked).isTrue()
                assertThat(buttonViewModel!!.isActive).isTrue()
            }
        }
    }
+10 −9
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@ import com.android.systemui.common.shared.model.Icon
data class ButtonViewModel(
    val icon: Icon,
    val label: CharSequence,
    val isActive: Boolean = true,
)
Loading