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

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

Merge "[QS] Don't convert secondaryLabel to string" into main

parents 3d182295 f38d3410
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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];
@@ -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) {
+3 −3
Original line number Diff line number Diff line
@@ -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?
@@ -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,
@@ -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,
+13 −9
Original line number Diff line number Diff line
@@ -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
@@ -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),
                    )
                }
@@ -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 {
+2 −2
Original line number Diff line number Diff line
@@ -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)
        }