Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +3 −3 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ public interface QSTile { public String spec; /** Get the state text. */ public String getStateText(int arrayResId, Resources resources) { public CharSequence getStateText(int arrayResId, Resources resources) { if (state == Tile.STATE_UNAVAILABLE || this instanceof QSTile.BooleanState) { String[] array = resources.getStringArray(arrayResId); return array[state]; Loading @@ -184,13 +184,13 @@ public interface QSTile { } /** Get the text for secondaryLabel. */ public String getSecondaryLabel(String stateText) { public CharSequence getSecondaryLabel(CharSequence stateText) { // Use a local reference as the value might change from other threads CharSequence localSecondaryLabel = secondaryLabel; if (TextUtils.isEmpty(localSecondaryLabel)) { return stateText; } return localSecondaryLabel.toString(); return localSecondaryLabel; } public boolean copyTo(State other) { Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt +3 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.systemui.qs.tileimpl.QSTileImpl /** Model describing the state that the QS Internet tile should be in. */ sealed interface InternetTileModel { val secondaryTitle: String? val secondaryTitle: CharSequence? val secondaryLabel: Text? val iconId: Int? val icon: QSTile.Icon? Loading Loading @@ -62,7 +62,7 @@ sealed interface InternetTileModel { } data class Active( override val secondaryTitle: String? = null, override val secondaryTitle: CharSequence? = null, override val secondaryLabel: Text? = null, override val iconId: Int? = null, override val icon: QSTile.Icon? = null, Loading @@ -71,7 +71,7 @@ sealed interface InternetTileModel { ) : InternetTileModel data class Inactive( override val secondaryTitle: String? = null, override val secondaryTitle: CharSequence? = null, override val secondaryLabel: Text? = null, override val iconId: Int? = null, override val icon: QSTile.Icon? = null, Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModel.kt +13 −9 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.content.Context import com.android.systemui.res.R import android.text.Html import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Text import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tileimpl.QSTileImpl.ResourceIcon import com.android.systemui.res.R import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepository import com.android.systemui.statusbar.pipeline.ethernet.domain.EthernetInteractor import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor Loading Loading @@ -120,7 +121,7 @@ constructor( InternetTileModel.Active( secondaryTitle = secondary, icon = SignalIcon(signalIcon.toSignalDrawableState()), stateDescription = ContentDescription.Loaded(secondary), stateDescription = ContentDescription.Loaded(secondary.toString()), contentDescription = ContentDescription.Loaded(internetLabel), ) } Loading @@ -130,22 +131,25 @@ constructor( private fun mobileDataContentConcat( networkName: String?, dataContentDescription: CharSequence? ): String { ): CharSequence { if (dataContentDescription == null) { return networkName ?: "" } if (networkName == null) { return dataContentDescription.toString() return Html.fromHtml(dataContentDescription.toString(), 0) } return context.getString( return Html.fromHtml( context.getString( R.string.mobile_carrier_text_format, networkName, dataContentDescription ), 0 ) } private fun loadString(resId: Int): String? = private fun loadString(resId: Int): CharSequence? = if (resId > 0) { context.getString(resId) } else { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -337,12 +337,12 @@ class InternetTileViewModelTest : SysuiTestCase() { networkName.value = NetworkNameModel.Default("test network") } assertThat(latest?.secondaryTitle).contains("test network") assertThat(latest?.secondaryTitle.toString()).contains("test network") assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.icon).isInstanceOf(SignalIcon::class.java) assertThat(latest?.iconId).isNull() assertThat(latest?.stateDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryTitle.toString()) assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(internet) } Loading Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +3 −3 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ public interface QSTile { public String spec; /** Get the state text. */ public String getStateText(int arrayResId, Resources resources) { public CharSequence getStateText(int arrayResId, Resources resources) { if (state == Tile.STATE_UNAVAILABLE || this instanceof QSTile.BooleanState) { String[] array = resources.getStringArray(arrayResId); return array[state]; Loading @@ -184,13 +184,13 @@ public interface QSTile { } /** Get the text for secondaryLabel. */ public String getSecondaryLabel(String stateText) { public CharSequence getSecondaryLabel(CharSequence stateText) { // Use a local reference as the value might change from other threads CharSequence localSecondaryLabel = secondaryLabel; if (TextUtils.isEmpty(localSecondaryLabel)) { return stateText; } return localSecondaryLabel.toString(); return localSecondaryLabel; } public boolean copyTo(State other) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt +3 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.systemui.qs.tileimpl.QSTileImpl /** Model describing the state that the QS Internet tile should be in. */ sealed interface InternetTileModel { val secondaryTitle: String? val secondaryTitle: CharSequence? val secondaryLabel: Text? val iconId: Int? val icon: QSTile.Icon? Loading Loading @@ -62,7 +62,7 @@ sealed interface InternetTileModel { } data class Active( override val secondaryTitle: String? = null, override val secondaryTitle: CharSequence? = null, override val secondaryLabel: Text? = null, override val iconId: Int? = null, override val icon: QSTile.Icon? = null, Loading @@ -71,7 +71,7 @@ sealed interface InternetTileModel { ) : InternetTileModel data class Inactive( override val secondaryTitle: String? = null, override val secondaryTitle: CharSequence? = null, override val secondaryLabel: Text? = null, override val iconId: Int? = null, override val icon: QSTile.Icon? = null, Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModel.kt +13 −9 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ package com.android.systemui.statusbar.pipeline.shared.ui.viewmodel import android.content.Context import com.android.systemui.res.R import android.text.Html import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Text import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tileimpl.QSTileImpl.ResourceIcon import com.android.systemui.res.R import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepository import com.android.systemui.statusbar.pipeline.ethernet.domain.EthernetInteractor import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor Loading Loading @@ -120,7 +121,7 @@ constructor( InternetTileModel.Active( secondaryTitle = secondary, icon = SignalIcon(signalIcon.toSignalDrawableState()), stateDescription = ContentDescription.Loaded(secondary), stateDescription = ContentDescription.Loaded(secondary.toString()), contentDescription = ContentDescription.Loaded(internetLabel), ) } Loading @@ -130,22 +131,25 @@ constructor( private fun mobileDataContentConcat( networkName: String?, dataContentDescription: CharSequence? ): String { ): CharSequence { if (dataContentDescription == null) { return networkName ?: "" } if (networkName == null) { return dataContentDescription.toString() return Html.fromHtml(dataContentDescription.toString(), 0) } return context.getString( return Html.fromHtml( context.getString( R.string.mobile_carrier_text_format, networkName, dataContentDescription ), 0 ) } private fun loadString(resId: Int): String? = private fun loadString(resId: Int): CharSequence? = if (resId > 0) { context.getString(resId) } else { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -337,12 +337,12 @@ class InternetTileViewModelTest : SysuiTestCase() { networkName.value = NetworkNameModel.Default("test network") } assertThat(latest?.secondaryTitle).contains("test network") assertThat(latest?.secondaryTitle.toString()).contains("test network") assertThat(latest?.secondaryLabel).isNull() assertThat(latest?.icon).isInstanceOf(SignalIcon::class.java) assertThat(latest?.iconId).isNull() assertThat(latest?.stateDescription.loadContentDescription(context)) .isEqualTo(latest?.secondaryTitle) .isEqualTo(latest?.secondaryTitle.toString()) assertThat(latest?.contentDescription.loadContentDescription(context)) .isEqualTo(internet) } Loading