Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/mediaoutput/ui/composable/MediaOutputComponent.kt +8 −3 Original line number Diff line number Diff line Loading @@ -92,7 +92,12 @@ constructor( true } }, color = MaterialTheme.colorScheme.surface, color = if (enabled) { MaterialTheme.colorScheme.surface } else { MaterialTheme.colorScheme.surfaceContainerHighest }, shape = RoundedCornerShape(28.dp), onClick = if (enabled) { Loading @@ -119,7 +124,7 @@ constructor( modifier = Modifier.basicMarquee(), text = connectedDeviceViewModel.label.toString(), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, color = connectedDeviceViewModel.labelColor.toColor(), maxLines = 1, ) connectedDeviceViewModel.deviceName?.let { Loading @@ -127,7 +132,7 @@ constructor( modifier = Modifier.basicMarquee(), text = it.toString(), style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.onSurface, color = connectedDeviceViewModel.deviceNameColor.toColor(), maxLines = 1, ) } Loading packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VolumePanelRoot.kt +15 −14 Original line number Diff line number Diff line Loading @@ -25,13 +25,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.paneTitle import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.compose.theme.PlatformTheme import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.res.R import com.android.systemui.volume.panel.ui.layout.ComponentsLayout Loading @@ -43,7 +43,6 @@ private const val VolumePanelTestTag = "VolumePanel" private val padding = 24.dp @Composable @OptIn(ExperimentalComposeUiApi::class) fun VolumePanelRoot( viewModel: VolumePanelViewModel, modifier: Modifier = Modifier, Loading @@ -54,6 +53,7 @@ fun VolumePanelRoot( with(VolumePanelComposeScope(state)) { components?.let { componentsState -> PlatformTheme { Components( componentsState, modifier Loading @@ -69,6 +69,7 @@ fun VolumePanelRoot( } } } } @Composable private fun VolumePanelComposeScope.Components( Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorTest.kt +10 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(model) .isEqualTo( MediaOutputComponentModel.Calling( AudioOutputDevice.BuiltIn(builtInDeviceName, testIcon), false, device = AudioOutputDevice.BuiltIn(builtInDeviceName, testIcon), isInAudioSharing = false, canOpenAudioSwitcher = false, ) ) } Loading @@ -101,6 +102,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { fun hasSession_stateIs_MediaSession() = with(kosmos) { testScope.runTest { localMediaRepository.updateCurrentConnectedDevice( TestMediaDevicesFactory.builtInMediaDevice() ) mediaControllerRepository.setActiveSessions(listOf(localMediaController)) val model by collectLastValue(underTest.mediaOutputModel.filterData()) Loading @@ -113,6 +117,7 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(device) .isEqualTo(AudioOutputDevice.BuiltIn("built_in_media", testIcon)) assertThat(isInAudioSharing).isFalse() assertThat(canOpenAudioSwitcher).isTrue() } } } Loading @@ -129,8 +134,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(model) .isEqualTo( MediaOutputComponentModel.Idle( AudioOutputDevice.BuiltIn("built_in_media", testIcon), true, device = AudioOutputDevice.BuiltIn("built_in_media", testIcon), isInAudioSharing = true, canOpenAudioSwitcher = false, ) ) } Loading packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt +6 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ constructor( } .map { it ?: AudioOutputDevice.Unknown } .flowOn(backgroundCoroutineContext) .stateIn(scope, SharingStarted.Eagerly, AudioOutputDevice.Unknown) .stateIn(scope, SharingStarted.Eagerly, AudioOutputDevice.Unavailable) private fun AudioDeviceInfo.toAudioOutputDevice(): AudioOutputDevice { if ( Loading Loading @@ -120,6 +120,11 @@ constructor( name = name, icon = icon, ) deviceType == MediaDeviceType.TYPE_CAST_DEVICE -> AudioOutputDevice.Remote( name = name, icon = icon, ) else -> AudioOutputDevice.BuiltIn( name = name, Loading packages/SystemUI/src/com/android/systemui/volume/domain/model/AudioOutputDevice.kt +18 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ sealed interface AudioOutputDevice { override val icon: Drawable?, ) : AudioOutputDevice /** Models a cast audio output device. */ data class Remote( override val name: String, override val icon: Drawable?, ) : AudioOutputDevice /** Models a wired audio output device. */ data class Wired( override val name: String, Loading @@ -52,4 +58,16 @@ sealed interface AudioOutputDevice { override val icon: Drawable get() = error("Unsupported for unknown device") } /** * Models a state when current audio output device is not loaded yet or the system failed to * load it. */ data object Unavailable : AudioOutputDevice { override val name: String get() = error("Unsupported for unavailable device") override val icon: Drawable get() = error("Unsupported for unavailable device") } } Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/mediaoutput/ui/composable/MediaOutputComponent.kt +8 −3 Original line number Diff line number Diff line Loading @@ -92,7 +92,12 @@ constructor( true } }, color = MaterialTheme.colorScheme.surface, color = if (enabled) { MaterialTheme.colorScheme.surface } else { MaterialTheme.colorScheme.surfaceContainerHighest }, shape = RoundedCornerShape(28.dp), onClick = if (enabled) { Loading @@ -119,7 +124,7 @@ constructor( modifier = Modifier.basicMarquee(), text = connectedDeviceViewModel.label.toString(), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, color = connectedDeviceViewModel.labelColor.toColor(), maxLines = 1, ) connectedDeviceViewModel.deviceName?.let { Loading @@ -127,7 +132,7 @@ constructor( modifier = Modifier.basicMarquee(), text = it.toString(), style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.onSurface, color = connectedDeviceViewModel.deviceNameColor.toColor(), maxLines = 1, ) } Loading
packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VolumePanelRoot.kt +15 −14 Original line number Diff line number Diff line Loading @@ -25,13 +25,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.paneTitle import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.compose.theme.PlatformTheme import com.android.systemui.compose.modifiers.sysuiResTag import com.android.systemui.res.R import com.android.systemui.volume.panel.ui.layout.ComponentsLayout Loading @@ -43,7 +43,6 @@ private const val VolumePanelTestTag = "VolumePanel" private val padding = 24.dp @Composable @OptIn(ExperimentalComposeUiApi::class) fun VolumePanelRoot( viewModel: VolumePanelViewModel, modifier: Modifier = Modifier, Loading @@ -54,6 +53,7 @@ fun VolumePanelRoot( with(VolumePanelComposeScope(state)) { components?.let { componentsState -> PlatformTheme { Components( componentsState, modifier Loading @@ -69,6 +69,7 @@ fun VolumePanelRoot( } } } } @Composable private fun VolumePanelComposeScope.Components( Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorTest.kt +10 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(model) .isEqualTo( MediaOutputComponentModel.Calling( AudioOutputDevice.BuiltIn(builtInDeviceName, testIcon), false, device = AudioOutputDevice.BuiltIn(builtInDeviceName, testIcon), isInAudioSharing = false, canOpenAudioSwitcher = false, ) ) } Loading @@ -101,6 +102,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { fun hasSession_stateIs_MediaSession() = with(kosmos) { testScope.runTest { localMediaRepository.updateCurrentConnectedDevice( TestMediaDevicesFactory.builtInMediaDevice() ) mediaControllerRepository.setActiveSessions(listOf(localMediaController)) val model by collectLastValue(underTest.mediaOutputModel.filterData()) Loading @@ -113,6 +117,7 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(device) .isEqualTo(AudioOutputDevice.BuiltIn("built_in_media", testIcon)) assertThat(isInAudioSharing).isFalse() assertThat(canOpenAudioSwitcher).isTrue() } } } Loading @@ -129,8 +134,9 @@ class MediaOutputComponentInteractorTest : SysuiTestCase() { assertThat(model) .isEqualTo( MediaOutputComponentModel.Idle( AudioOutputDevice.BuiltIn("built_in_media", testIcon), true, device = AudioOutputDevice.BuiltIn("built_in_media", testIcon), isInAudioSharing = true, canOpenAudioSwitcher = false, ) ) } Loading
packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt +6 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ constructor( } .map { it ?: AudioOutputDevice.Unknown } .flowOn(backgroundCoroutineContext) .stateIn(scope, SharingStarted.Eagerly, AudioOutputDevice.Unknown) .stateIn(scope, SharingStarted.Eagerly, AudioOutputDevice.Unavailable) private fun AudioDeviceInfo.toAudioOutputDevice(): AudioOutputDevice { if ( Loading Loading @@ -120,6 +120,11 @@ constructor( name = name, icon = icon, ) deviceType == MediaDeviceType.TYPE_CAST_DEVICE -> AudioOutputDevice.Remote( name = name, icon = icon, ) else -> AudioOutputDevice.BuiltIn( name = name, Loading
packages/SystemUI/src/com/android/systemui/volume/domain/model/AudioOutputDevice.kt +18 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ sealed interface AudioOutputDevice { override val icon: Drawable?, ) : AudioOutputDevice /** Models a cast audio output device. */ data class Remote( override val name: String, override val icon: Drawable?, ) : AudioOutputDevice /** Models a wired audio output device. */ data class Wired( override val name: String, Loading @@ -52,4 +58,16 @@ sealed interface AudioOutputDevice { override val icon: Drawable get() = error("Unsupported for unknown device") } /** * Models a state when current audio output device is not loaded yet or the system failed to * load it. */ data object Unavailable : AudioOutputDevice { override val name: String get() = error("Unsupported for unavailable device") override val icon: Drawable get() = error("Unsupported for unavailable device") } }