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

Commit c651e64d authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Added RAT type to CellularTile

The type is added as a smaller span using sans-serif-condensed

Fixes: 123363592
Test: manual
Change-Id: I509bd3aaa07c7256de839d31cf35de296c60b333
parent 8e95f0bf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1049,4 +1049,7 @@
    <dimen name="bubble_pointer_margin">8dp</dimen>
    <!-- Height of the permission prompt shown with bubbles -->
    <dimen name="bubble_permission_height">120dp</dimen>

    <!-- Size of the RAT type for CellularTile -->
    <dimen name="celltile_rat_type_size">10sp</dimen>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -216,6 +216,12 @@
        <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
    </style>

    <!-- This is hard coded to be sans-serif-condensed to match the icons -->
    <style name="TextAppearance.RATBadge" parent="@style/TextAppearance.QS.TileLabel.Secondary">
        <item name="android:fontFamily">sans-serif-condensed</item>
        <item name="android:textSize">@dimen/celltile_rat_type_size</item>
    </style>

    <style name="TextAppearance.QS.CarrierInfo">
        <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
        <item name="android:textSize">@dimen/qs_carrier_info_text_size</item>
+20 −1
Original line number Diff line number Diff line
@@ -25,7 +25,11 @@ import android.content.Intent;
import android.content.res.Resources;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.TextAppearanceSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -188,7 +192,8 @@ public class CellularTile extends QSTileImpl<SignalState> {
            state.secondaryLabel = r.getString(R.string.status_bar_airplane);
        } else if (mobileDataEnabled) {
            state.state = Tile.STATE_ACTIVE;
            state.secondaryLabel = getMobileDataSubscriptionName(cb);
            state.secondaryLabel = appendMobileDataType(getMobileDataSubscriptionName(cb),
                    cb.dataContentDescription);
        } else {
            state.state = Tile.STATE_INACTIVE;
            state.secondaryLabel = r.getString(R.string.cell_data_off);
@@ -207,6 +212,18 @@ public class CellularTile extends QSTileImpl<SignalState> {
        state.contentDescription = state.label + ", " + contentDescriptionSuffix;
    }

    private CharSequence appendMobileDataType(CharSequence current, CharSequence dataType) {
        if (TextUtils.isEmpty(dataType)) {
            return current;
        }
        SpannableString type = new SpannableString(dataType);
        SpannableStringBuilder builder = new SpannableStringBuilder(current);
        builder.append(" ");
        builder.append(type, new TextAppearanceSpan(mContext, R.style.TextAppearance_RATBadge),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return builder;
    }

    private CharSequence getMobileDataSubscriptionName(CallbackInfo cb) {
        if (cb.roaming && !TextUtils.isEmpty(cb.dataSubscriptionName)) {
            String roaming = mContext.getString(R.string.data_connection_roaming);
@@ -232,6 +249,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
    private static final class CallbackInfo {
        boolean airplaneModeEnabled;
        CharSequence dataSubscriptionName;
        CharSequence dataContentDescription;
        boolean activityIn;
        boolean activityOut;
        boolean noSim;
@@ -250,6 +268,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
                return;
            }
            mInfo.dataSubscriptionName = mController.getMobileDataNetworkName();
            mInfo.dataContentDescription = (description != null) ? typeContentDescription : null;
            mInfo.activityIn = activityIn;
            mInfo.activityOut = activityOut;
            mInfo.roaming = roaming;