Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt +12 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt +4 −4 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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, Loading @@ -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 ) { Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioPopup.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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) }) } Loading Loading @@ -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) }, Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class CaptioningViewModelTest : SysuiTestCase() { val buttonViewModel by collectLastValue(underTest.buttonViewModel) runCurrent() assertThat(buttonViewModel!!.isChecked).isFalse() assertThat(buttonViewModel!!.isActive).isFalse() } } } Loading @@ -78,7 +78,7 @@ class CaptioningViewModelTest : SysuiTestCase() { val buttonViewModel by collectLastValue(underTest.buttonViewModel) runCurrent() assertThat(buttonViewModel!!.isChecked).isTrue() assertThat(buttonViewModel!!.isActive).isTrue() } } } Loading packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt +10 −9 Original line number Diff line number Diff line Loading @@ -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
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt +12 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt +4 −4 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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, Loading @@ -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 ) { Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioPopup.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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) }) } Loading Loading @@ -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) }, Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/captioning/ui/viewmodel/CaptioningViewModelTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class CaptioningViewModelTest : SysuiTestCase() { val buttonViewModel by collectLastValue(underTest.buttonViewModel) runCurrent() assertThat(buttonViewModel!!.isChecked).isFalse() assertThat(buttonViewModel!!.isActive).isFalse() } } } Loading @@ -78,7 +78,7 @@ class CaptioningViewModelTest : SysuiTestCase() { val buttonViewModel by collectLastValue(underTest.buttonViewModel) runCurrent() assertThat(buttonViewModel!!.isChecked).isTrue() assertThat(buttonViewModel!!.isActive).isTrue() } } } Loading
packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt +10 −9 Original line number Diff line number Diff line Loading @@ -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, )