Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/selector/ui/composable/VolumePanelRadioButtons.kt +18 −2 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,12 @@ import androidx.compose.ui.layout.MeasureScope import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.layout.layoutId import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntOffset Loading Loading @@ -112,10 +118,16 @@ fun VolumePanelRadioButtonBar( horizontalArrangement = Arrangement.spacedBy(spacing) horizontalArrangement = Arrangement.spacedBy(spacing) ) { ) { for (itemIndex in items.indices) { for (itemIndex in items.indices) { val item = items[itemIndex] Row( Row( modifier = modifier = Modifier.height(48.dp) Modifier.height(48.dp) .weight(1f) .weight(1f) .semantics { item.contentDescription?.let { contentDescription = it } role = Role.Switch selected = itemIndex == scope.selectedIndex } .clickable( .clickable( interactionSource = null, interactionSource = null, indication = null, indication = null, Loading @@ -124,7 +136,6 @@ fun VolumePanelRadioButtonBar( horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically, ) { ) { val item = items[itemIndex] if (item.icon !== Empty) { if (item.icon !== Empty) { with(items[itemIndex]) { icon() } with(items[itemIndex]) { icon() } } } Loading @@ -138,7 +149,8 @@ fun VolumePanelRadioButtonBar( start = indicatorBackgroundPadding, start = indicatorBackgroundPadding, top = labelIndicatorBackgroundSpacing, top = labelIndicatorBackgroundSpacing, end = indicatorBackgroundPadding end = indicatorBackgroundPadding ), ) .clearAndSetSemantics {}, horizontalArrangement = Arrangement.spacedBy(spacing), horizontalArrangement = Arrangement.spacedBy(spacing), ) { ) { for (itemIndex in items.indices) { for (itemIndex in items.indices) { Loading Loading @@ -296,6 +308,7 @@ interface VolumePanelRadioButtonBarScope { onItemSelected: () -> Unit, onItemSelected: () -> Unit, icon: @Composable RowScope.() -> Unit = Empty, icon: @Composable RowScope.() -> Unit = Empty, label: @Composable RowScope.() -> Unit = Empty, label: @Composable RowScope.() -> Unit = Empty, contentDescription: String? = null, ) ) } } Loading @@ -317,6 +330,7 @@ private class VolumePanelRadioButtonBarScopeImpl : VolumePanelRadioButtonBarScop onItemSelected: () -> Unit, onItemSelected: () -> Unit, icon: @Composable RowScope.() -> Unit, icon: @Composable RowScope.() -> Unit, label: @Composable RowScope.() -> Unit, label: @Composable RowScope.() -> Unit, contentDescription: String?, ) { ) { require(!isSelected || !hasSelectedItem) { "Only one item should be selected at a time" } require(!isSelected || !hasSelectedItem) { "Only one item should be selected at a time" } if (isSelected) { if (isSelected) { Loading @@ -327,6 +341,7 @@ private class VolumePanelRadioButtonBarScopeImpl : VolumePanelRadioButtonBarScop onItemSelected = onItemSelected, onItemSelected = onItemSelected, icon = icon, icon = icon, label = label, label = label, contentDescription = contentDescription, ) ) ) ) } } Loading @@ -340,6 +355,7 @@ private class Item( val onItemSelected: () -> Unit, val onItemSelected: () -> Unit, val icon: @Composable RowScope.() -> Unit, val icon: @Composable RowScope.() -> Unit, val label: @Composable RowScope.() -> Unit, val label: @Composable RowScope.() -> Unit, val contentDescription: String?, ) ) private const val UNSET_OFFSET = -1 private const val UNSET_OFFSET = -1 Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioPopup.kt +3 −1 Original line number Original line Diff line number Diff line Loading @@ -74,9 +74,11 @@ constructor( } } VolumePanelRadioButtonBar { VolumePanelRadioButtonBar { for (buttonViewModel in enabledModelStates) { for (buttonViewModel in enabledModelStates) { val label = buttonViewModel.button.label.toString() item( item( isSelected = buttonViewModel.button.isChecked, isSelected = buttonViewModel.button.isChecked, onItemSelected = { viewModel.setEnabled(buttonViewModel.model) }, onItemSelected = { viewModel.setEnabled(buttonViewModel.model) }, contentDescription = label, icon = { icon = { Icon( Icon( icon = buttonViewModel.button.icon, icon = buttonViewModel.button.icon, Loading @@ -86,7 +88,7 @@ constructor( label = { label = { Text( Text( modifier = Modifier.basicMarquee(), modifier = Modifier.basicMarquee(), text = buttonViewModel.button.label.toString(), text = label, style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium, color = buttonViewModel.labelColor.toColor(), color = buttonViewModel.labelColor.toColor(), textAlign = TextAlign.Center, textAlign = TextAlign.Center, Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/selector/ui/composable/VolumePanelRadioButtons.kt +18 −2 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,12 @@ import androidx.compose.ui.layout.MeasureScope import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.layout.layoutId import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntOffset Loading Loading @@ -112,10 +118,16 @@ fun VolumePanelRadioButtonBar( horizontalArrangement = Arrangement.spacedBy(spacing) horizontalArrangement = Arrangement.spacedBy(spacing) ) { ) { for (itemIndex in items.indices) { for (itemIndex in items.indices) { val item = items[itemIndex] Row( Row( modifier = modifier = Modifier.height(48.dp) Modifier.height(48.dp) .weight(1f) .weight(1f) .semantics { item.contentDescription?.let { contentDescription = it } role = Role.Switch selected = itemIndex == scope.selectedIndex } .clickable( .clickable( interactionSource = null, interactionSource = null, indication = null, indication = null, Loading @@ -124,7 +136,6 @@ fun VolumePanelRadioButtonBar( horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically, ) { ) { val item = items[itemIndex] if (item.icon !== Empty) { if (item.icon !== Empty) { with(items[itemIndex]) { icon() } with(items[itemIndex]) { icon() } } } Loading @@ -138,7 +149,8 @@ fun VolumePanelRadioButtonBar( start = indicatorBackgroundPadding, start = indicatorBackgroundPadding, top = labelIndicatorBackgroundSpacing, top = labelIndicatorBackgroundSpacing, end = indicatorBackgroundPadding end = indicatorBackgroundPadding ), ) .clearAndSetSemantics {}, horizontalArrangement = Arrangement.spacedBy(spacing), horizontalArrangement = Arrangement.spacedBy(spacing), ) { ) { for (itemIndex in items.indices) { for (itemIndex in items.indices) { Loading Loading @@ -296,6 +308,7 @@ interface VolumePanelRadioButtonBarScope { onItemSelected: () -> Unit, onItemSelected: () -> Unit, icon: @Composable RowScope.() -> Unit = Empty, icon: @Composable RowScope.() -> Unit = Empty, label: @Composable RowScope.() -> Unit = Empty, label: @Composable RowScope.() -> Unit = Empty, contentDescription: String? = null, ) ) } } Loading @@ -317,6 +330,7 @@ private class VolumePanelRadioButtonBarScopeImpl : VolumePanelRadioButtonBarScop onItemSelected: () -> Unit, onItemSelected: () -> Unit, icon: @Composable RowScope.() -> Unit, icon: @Composable RowScope.() -> Unit, label: @Composable RowScope.() -> Unit, label: @Composable RowScope.() -> Unit, contentDescription: String?, ) { ) { require(!isSelected || !hasSelectedItem) { "Only one item should be selected at a time" } require(!isSelected || !hasSelectedItem) { "Only one item should be selected at a time" } if (isSelected) { if (isSelected) { Loading @@ -327,6 +341,7 @@ private class VolumePanelRadioButtonBarScopeImpl : VolumePanelRadioButtonBarScop onItemSelected = onItemSelected, onItemSelected = onItemSelected, icon = icon, icon = icon, label = label, label = label, contentDescription = contentDescription, ) ) ) ) } } Loading @@ -340,6 +355,7 @@ private class Item( val onItemSelected: () -> Unit, val onItemSelected: () -> Unit, val icon: @Composable RowScope.() -> Unit, val icon: @Composable RowScope.() -> Unit, val label: @Composable RowScope.() -> Unit, val label: @Composable RowScope.() -> Unit, val contentDescription: String?, ) ) private const val UNSET_OFFSET = -1 private const val UNSET_OFFSET = -1 Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioPopup.kt +3 −1 Original line number Original line Diff line number Diff line Loading @@ -74,9 +74,11 @@ constructor( } } VolumePanelRadioButtonBar { VolumePanelRadioButtonBar { for (buttonViewModel in enabledModelStates) { for (buttonViewModel in enabledModelStates) { val label = buttonViewModel.button.label.toString() item( item( isSelected = buttonViewModel.button.isChecked, isSelected = buttonViewModel.button.isChecked, onItemSelected = { viewModel.setEnabled(buttonViewModel.model) }, onItemSelected = { viewModel.setEnabled(buttonViewModel.model) }, contentDescription = label, icon = { icon = { Icon( Icon( icon = buttonViewModel.button.icon, icon = buttonViewModel.button.icon, Loading @@ -86,7 +88,7 @@ constructor( label = { label = { Text( Text( modifier = Modifier.basicMarquee(), modifier = Modifier.basicMarquee(), text = buttonViewModel.button.label.toString(), text = label, style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium, color = buttonViewModel.labelColor.toColor(), color = buttonViewModel.labelColor.toColor(), textAlign = TextAlign.Center, textAlign = TextAlign.Center, Loading