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

Commit 4d928f4a authored by cretin45's avatar cretin45 Committed by Gerrit Code Review
Browse files

Settings: Don't allow disabling slot 1, just disable the switch

Change-Id: I1157fa645e35d2d111fdfee010458127cd928b1b
parent 0569db7c
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ public class MultiSimEnablerPreference extends SwitchPreference implements
    private static final int PROGRESS_DLG_TIME_OUT = 30000;
    private static final int MSG_DELAY_TIME = 2000;

    private boolean mExplicitlyDisabled = false;

    public MultiSimEnablerPreference(Context context, SubInfoRecord sir,
            Handler handler, int slotId) {
        super(context);
@@ -109,6 +111,9 @@ public class MultiSimEnablerPreference extends SwitchPreference implements

        boolean isSubValid = isCurrentSubValid();
        setEnabled(isSubValid);
        if (mSwitch != null) {
            mSwitch.setEnabled(!mExplicitlyDisabled);
        }

        logd("update() isSubValid " + isSubValid);
        if (isSubValid) {
@@ -184,6 +189,11 @@ public class MultiSimEnablerPreference extends SwitchPreference implements
        builder.show();
    }

    public void setExplicitlyDisabled(boolean disabled) {
        super.setEnabled(!disabled);
        mExplicitlyDisabled = disabled;
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
@@ -196,7 +206,7 @@ public class MultiSimEnablerPreference extends SwitchPreference implements

    @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
        if (mClicking) {
        if (mClicking || mExplicitlyDisabled) {
            return false;
        }

+11 −7
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    private int mNumSims;
    private TelephonyManager mTelephonyManager;

    private boolean mDisableAltAlwaysSmsCallSimPref = false;

    public SimSettings() {
        super(DISALLOW_CONFIG_SIM);
    }
@@ -106,6 +108,9 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable

        mNumSlots = mTelephonyManager.getSimCount();

        mDisableAltAlwaysSmsCallSimPref = getResources()
                .getBoolean(R.bool.config_disableAltAlwaysSmsCallSimPref);

        createPreferences();
        updateAllOptions();
        IntentFilter intentFilter =
@@ -238,12 +243,11 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            final SubInfoRecord sir = findRecordBySlotId(i);
            if (mNumSlots > 1 && sir != null) {
                MultiSimEnablerPreference multiSimEnablerPreference =
                        new MultiSimEnablerPreference(getActivity(), sir, mHandler, sir.slotId);
                if (!getResources()
                        .getBoolean(R.bool.config_disableAltAlwaysSmsCallSimPref)
                        || sir.slotId > 0) {
                        new MultiSimEnablerPreference(getActivity(), sir, mHandler, i);
                mSimEnablers.add(multiSimEnablerPreference);
                simEnablers.addPreference(multiSimEnablerPreference);
                if (mDisableAltAlwaysSmsCallSimPref && i == 0) {
                    multiSimEnablerPreference.setExplicitlyDisabled(true);
                }
            } else {
                removePreference(SIM_ENABLER_CATEGORY);
@@ -455,7 +459,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            final SubInfoRecord sir = mAvailableSubInfos.get(i);
            if(sir != null){
                if (i > 0 && (keyPref.equals(KEY_CALLS) || keyPref.equals(KEY_SMS)) &&
                        getResources().getBoolean(R.bool.config_disableAltAlwaysSmsCallSimPref)) {
                        mDisableAltAlwaysSmsCallSimPref) {
                    continue;
                }
                simPref.addItem(sir.displayName + " - " + Integer.toString(i+1), sir);