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

Commit 78e07fa4 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Only show carrier name when multiple subs"

parents 2c6925f2 f1c32a03
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2234,6 +2234,9 @@
    <!-- Quick settings tile secondary label format combining roaming with the mobile data type. [CHAR LIMIT=NONE] -->
    <string name="mobile_data_text_format"><xliff:g name="roaming_status" example="Roaming">%1$s</xliff:g> \u2014 <xliff:g name="mobile_data_type" example="LTE">%2$s</xliff:g></string>

    <!-- Quick settings tile secondary label format combining carrier name with the mobile data tye. [CHAR LIMIT=NONE] -->
    <string name="mobile_carrier_text_format"><xliff:g id="carrier_name" example="Test">%1$s</xliff:g>, <xliff:g id="mobile_data_type" example="LTE">%2$s</xliff:g></string>

    <!-- Label for when wifi is off in QS detail panel [CHAR LIMIT=NONE] -->
    <string name="wifi_is_off">Wi-Fi is off</string>

+14 −16
Original line number Diff line number Diff line
@@ -25,11 +25,7 @@ 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;
@@ -192,8 +188,10 @@ 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 = appendMobileDataType(getMobileDataSubscriptionName(cb),
                    cb.dataContentDescription);
            state.secondaryLabel = appendMobileDataType(
                    // Only show carrier name if there are more than 1 subscription
                    cb.multipleSubs ? cb.dataSubscriptionName : "",
                    getMobileDataContentName(cb));
        } else {
            state.state = Tile.STATE_INACTIVE;
            state.secondaryLabel = r.getString(R.string.cell_data_off);
@@ -216,24 +214,22 @@ public class CellularTile extends QSTileImpl<SignalState> {
        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;
        if (TextUtils.isEmpty(current)) {
            return dataType;
        }
        return mContext.getString(R.string.mobile_carrier_text_format, current, dataType);
    }

    private CharSequence getMobileDataSubscriptionName(CallbackInfo cb) {
        if (cb.roaming && !TextUtils.isEmpty(cb.dataSubscriptionName)) {
    private CharSequence getMobileDataContentName(CallbackInfo cb) {
        if (cb.roaming && !TextUtils.isEmpty(cb.dataContentDescription)) {
            String roaming = mContext.getString(R.string.data_connection_roaming);
            String dataDescription = cb.dataSubscriptionName.toString();
            String dataDescription = cb.dataContentDescription.toString();
            return mContext.getString(R.string.mobile_data_text_format, roaming, dataDescription);
        }
        if (cb.roaming) {
            return mContext.getString(R.string.data_connection_roaming);
        }
        return cb.dataSubscriptionName;
        return cb.dataContentDescription;
    }

    @Override
@@ -254,6 +250,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
        boolean activityOut;
        boolean noSim;
        boolean roaming;
        boolean multipleSubs;
    }

    private final class CellSignalCallback implements SignalCallback {
@@ -272,6 +269,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
            mInfo.activityIn = activityIn;
            mInfo.activityOut = activityOut;
            mInfo.roaming = roaming;
            mInfo.multipleSubs = mController.getNumberSubscriptions() > 1;
            refreshState(mInfo);
        }

+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
    DataUsageController getMobileDataController();
    DataSaverController getDataSaverController();
    String getMobileDataNetworkName();
    int getNumberSubscriptions();

    boolean hasVoiceCallingFeature();

+5 −0
Original line number Diff line number Diff line
@@ -376,6 +376,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
        return controller != null ? controller.getState().networkNameData : "";
    }

    @Override
    public int getNumberSubscriptions() {
        return mMobileSignalControllers.size();
    }

    public boolean isEmergencyOnly() {
        if (mMobileSignalControllers.size() == 0) {
            // When there are no active subscriptions, determine emengency state from last
+5 −0
Original line number Diff line number Diff line
@@ -93,4 +93,9 @@ public class FakeNetworkController extends BaseLeakChecker<SignalCallback>
    public String getMobileDataNetworkName() {
        return "";
    }

    @Override
    public int getNumberSubscriptions() {
        return 0;
    }
}