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

Commit 37cbf672 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Settings: Fix option "Display numbers" can't be set"

parents b09d44e2 b8d64862
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -41,9 +41,12 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.os.Message;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
@@ -53,6 +56,7 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
@@ -88,6 +92,8 @@ public class MultiSimEnablerPreference extends Preference implements OnCheckedCh
    private static final int RESULT_ALERT_DLG_ID = 3;
    private static final int SIM_ID[] = {1, 2};

    private static final String DISPLAY_NUMBERS_TYPE = "display_numbers_type";

    private int mSlotId;
    private SubscriptionInfo mSir;
    private boolean mCurrentState;
@@ -526,6 +532,23 @@ public class MultiSimEnablerPreference extends Preference implements OnCheckedCh
        TextView carrierView = (TextView)dialogLayout.findViewById(R.id.carrier);
        carrierView.setText(getNetOperatorName());

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
        final Editor editor = prefs.edit();
        Spinner displayNumbers = (Spinner)dialogLayout.findViewById(R.id.display_numbers);
        displayNumbers.setSelection(prefs.getInt(DISPLAY_NUMBERS_TYPE, 0));
        displayNumbers.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position,
                    long id) {
                editor.putInt(DISPLAY_NUMBERS_TYPE, position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // do nothing
            }
        });

        final Resources res = mContext.getResources();
        builder.setTitle(res.getString(R.string.sim_editor_title, mSlotId + 1));

@@ -533,14 +556,12 @@ public class MultiSimEnablerPreference extends Preference implements OnCheckedCh
            @Override
            public void onClick(DialogInterface dialog, int whichButton) {
                final EditText nameText = (EditText)dialogLayout.findViewById(R.id.sim_name);
                final Spinner displayNumbers =
                    (Spinner)dialogLayout.findViewById(R.id.display_numbers);

                mSir.setDisplayName(nameText.getText());
                SubscriptionManager.from(mContext).setDisplayName(mSir.getDisplayName().toString(),
                        mSir.getSubscriptionId(), SubscriptionManager.NAME_SOURCE_USER_INPUT);

                update();
                editor.commit();
            }
        });

+22 −3
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.ContentUris;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.DialogInterface;
import android.database.Cursor;
import android.net.Uri;
@@ -32,6 +34,7 @@ import android.os.Message;
import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.provider.SearchIndexableResource;
import android.provider.Settings.SettingNotFoundException;
@@ -89,6 +92,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    private static final String KEY_ACTIVITIES = "activities";
    private static final String KEY_PRIMARY_SUB_SELECT = "select_primary_sub";
    private static final String SETTING_USER_PREF_DATA_SUB = "user_preferred_data_sub";
    private static final String DISPLAY_NUMBERS_TYPE = "display_numbers_type";

    private int mPreferredDataSubscription;

@@ -665,6 +669,23 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            TextView carrierView = (TextView)dialogLayout.findViewById(R.id.carrier);
            carrierView.setText(mSubscriptionInfo.getDisplayName());

            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
            final Editor editor = prefs.edit();
            Spinner displayNumbers = (Spinner)dialogLayout.findViewById(R.id.display_numbers);
            displayNumbers.setSelection(prefs.getInt(DISPLAY_NUMBERS_TYPE, 0));
            displayNumbers.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                    @Override
                    public void onItemSelected(AdapterView<?> parent, View view, int position,
                            long id) {
                        editor.putInt(DISPLAY_NUMBERS_TYPE, position);
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> arg0) {
                        // do nothing
                    }
                });

            final Resources res = getResources();
            builder.setTitle(res.getString(R.string.sim_editor_title, mSlotId + 1));

@@ -672,9 +693,6 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    final EditText nameText = (EditText)dialogLayout.findViewById(R.id.sim_name);
                    final Spinner displayNumbers =
                        (Spinner)dialogLayout.findViewById(R.id.display_numbers);

                    mSubscriptionInfo.setDisplayName(nameText.getText());
                    SubscriptionManager.from(getActivity()).setDisplayName(
                            mSubscriptionInfo.getDisplayName().toString(),
@@ -683,6 +701,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable

                    updateAllOptions();
                    update();
                    editor.commit();
                }
            });