Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModel.kt +9 −3 Original line number Diff line number Diff line Loading @@ -161,13 +161,13 @@ constructor( if (it == null) { notConnectedFlow } else { val secondary = it.contentDescription.toString() val secondary = it.contentDescription flowOf( InternetTileModel.Active( secondaryTitle = secondary, secondaryLabel = secondary?.toText(), iconId = it.res, stateDescription = null, contentDescription = ContentDescription.Loaded(secondary), contentDescription = secondary, ) ) } Loading Loading @@ -241,5 +241,11 @@ constructor( string.substring(1, length - 1) } else string } private fun ContentDescription.toText(): Text = when (this) { is ContentDescription.Loaded -> Text.Loaded(this.description) is ContentDescription.Resource -> Text.Resource(this.res) } } } packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt +9 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.settingslib.AccessibilityContentDescriptions.WIFI_OTHER_DEVIC import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription import com.android.systemui.common.shared.model.Text import com.android.systemui.common.shared.model.Text.Companion.loadText import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.flags.Flags Loading Loading @@ -355,14 +356,14 @@ class InternetTileViewModelTest : SysuiTestCase() { connectivityRepository.setEthernetConnected(default = true, validated = true) assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.secondaryTitle) .isEqualTo(ethernetIcon!!.contentDescription.toString()) assertThat(latest?.secondaryLabel.loadText(context)) .isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context)) assertThat(latest?.secondaryTitle).isNull() assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet_fully) assertThat(latest?.icon).isNull() assertThat(latest?.stateDescription).isNull() assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryLabel.loadText(context)) } @Test Loading @@ -373,14 +374,14 @@ class InternetTileViewModelTest : SysuiTestCase() { connectivityRepository.setEthernetConnected(default = true, validated = false) assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.secondaryTitle) .isEqualTo(ethernetIcon!!.contentDescription.toString()) assertThat(latest?.secondaryLabel.loadText(context)) .isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context)) assertThat(latest?.secondaryTitle).isNull() assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet) assertThat(latest?.icon).isNull() assertThat(latest?.stateDescription).isNull() assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryLabel.loadText(context)) } private fun setWifiNetworkWithHotspot(hotspot: WifiNetworkModel.HotspotDeviceType) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModel.kt +9 −3 Original line number Diff line number Diff line Loading @@ -161,13 +161,13 @@ constructor( if (it == null) { notConnectedFlow } else { val secondary = it.contentDescription.toString() val secondary = it.contentDescription flowOf( InternetTileModel.Active( secondaryTitle = secondary, secondaryLabel = secondary?.toText(), iconId = it.res, stateDescription = null, contentDescription = ContentDescription.Loaded(secondary), contentDescription = secondary, ) ) } Loading Loading @@ -241,5 +241,11 @@ constructor( string.substring(1, length - 1) } else string } private fun ContentDescription.toText(): Text = when (this) { is ContentDescription.Loaded -> Text.Loaded(this.description) is ContentDescription.Resource -> Text.Resource(this.res) } } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt +9 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.settingslib.AccessibilityContentDescriptions.WIFI_OTHER_DEVIC import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription import com.android.systemui.common.shared.model.Text import com.android.systemui.common.shared.model.Text.Companion.loadText import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.flags.Flags Loading Loading @@ -355,14 +356,14 @@ class InternetTileViewModelTest : SysuiTestCase() { connectivityRepository.setEthernetConnected(default = true, validated = true) assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.secondaryTitle) .isEqualTo(ethernetIcon!!.contentDescription.toString()) assertThat(latest?.secondaryLabel.loadText(context)) .isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context)) assertThat(latest?.secondaryTitle).isNull() assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet_fully) assertThat(latest?.icon).isNull() assertThat(latest?.stateDescription).isNull() assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryLabel.loadText(context)) } @Test Loading @@ -373,14 +374,14 @@ class InternetTileViewModelTest : SysuiTestCase() { connectivityRepository.setEthernetConnected(default = true, validated = false) assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.secondaryTitle) .isEqualTo(ethernetIcon!!.contentDescription.toString()) assertThat(latest?.secondaryLabel.loadText(context)) .isEqualTo(ethernetIcon!!.contentDescription.loadContentDescription(context)) assertThat(latest?.secondaryTitle).isNull() assertThat(latest?.iconId).isEqualTo(R.drawable.stat_sys_ethernet) assertThat(latest?.icon).isNull() assertThat(latest?.stateDescription).isNull() assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryLabel.loadText(context)) } private fun setWifiNetworkWithHotspot(hotspot: WifiNetworkModel.HotspotDeviceType) { Loading