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

Commit 686a76a7 authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge "[QS] Load text from the ethernet description" into main

parents 72c28487 855c6382
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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,
                    )
                )
            }
@@ -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)
            }
    }
}
+9 −8
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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) {