Commit with dialog box but using subinfo records
Change-Id: I144aa8899eb050db29a9d78aaf7af4c1f31d9eab
This commit is contained in:
@@ -5493,6 +5493,10 @@
|
|||||||
<string name="sim_cellular_data_unavailable_summary">Touch to select a data SIM</string>
|
<string name="sim_cellular_data_unavailable_summary">Touch to select a data SIM</string>
|
||||||
<!-- Checkbox to always use for calls. [CHAR LIMIT=40] -->
|
<!-- Checkbox to always use for calls. [CHAR LIMIT=40] -->
|
||||||
<string name="sim_calls_always_use">Always use this for calls</string>
|
<string name="sim_calls_always_use">Always use this for calls</string>
|
||||||
|
<!-- Message for selecting sim for data in settings. [CHAR LIMIT=40] -->
|
||||||
|
<string name="select_sim_for_data">Select a SIM for data</string>
|
||||||
|
<!-- Message for selecting sim for call in settings. [CHAR LIMIT=40] -->
|
||||||
|
<string name="select_sim_for_calls">Call with</string>
|
||||||
<!-- Title for selecting a SIM card. [CHAR LIMIT=40] -->
|
<!-- Title for selecting a SIM card. [CHAR LIMIT=40] -->
|
||||||
<string name="sim_select_card">Select a SIM card</string>
|
<string name="sim_select_card">Select a SIM card</string>
|
||||||
<!-- Label for a numbered SIM card. [CHAR LIMIT=40] -->
|
<!-- Label for a numbered SIM card. [CHAR LIMIT=40] -->
|
||||||
@@ -5539,7 +5543,7 @@
|
|||||||
<!-- This is a divider in the SIM cards preferences that is the header of various settings where the user chooses which SIM to use for phone calls, data, and SMS messages [CHAR LIMIT=50] -->
|
<!-- This is a divider in the SIM cards preferences that is the header of various settings where the user chooses which SIM to use for phone calls, data, and SMS messages [CHAR LIMIT=50] -->
|
||||||
<string name="sim_pref_divider">Preferred SIM for</string>
|
<string name="sim_pref_divider">Preferred SIM for</string>
|
||||||
<!-- When a user chooses this "Ask first" preference for the SIM to use for phone calls, they'll be prompted to choose a SIM every time they initiate a call [CHAR LIMIT=50] -->
|
<!-- When a user chooses this "Ask first" preference for the SIM to use for phone calls, they'll be prompted to choose a SIM every time they initiate a call [CHAR LIMIT=50] -->
|
||||||
<string name="sim_calls_ask_first_prefs_title">Ask first</string>
|
<string name="sim_calls_ask_first_prefs_title">Ask everytime</string>
|
||||||
<!-- When a SIM preference hasn't been selected yet, this string is displayed as the pref summary until the user chooses a SIM subscription from the preference list [CHAR LIMIT=50] -->
|
<!-- When a SIM preference hasn't been selected yet, this string is displayed as the pref summary until the user chooses a SIM subscription from the preference list [CHAR LIMIT=50] -->
|
||||||
<string name="sim_selection_required_pref">Selection required</string>
|
<string name="sim_selection_required_pref">Selection required</string>
|
||||||
|
|
||||||
|
@@ -23,20 +23,18 @@
|
|||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="sim_activities"
|
android:key="sim_activities"
|
||||||
android:title="@string/sim_pref_divider">
|
android:title="@string/sim_pref_divider" >
|
||||||
|
|
||||||
<com.android.settings.notification.DropDownPreference
|
<Preference android:key="sim_cellular_data"
|
||||||
android:key="sim_cellular_data"
|
|
||||||
android:title="@string/cellular_data_title" />
|
android:title="@string/cellular_data_title" />
|
||||||
|
|
||||||
<com.android.settings.notification.DropDownPreference
|
<Preference android:key="sim_calls"
|
||||||
android:key="sim_calls"
|
|
||||||
android:title="@string/calls_title" />
|
android:title="@string/calls_title" />
|
||||||
|
|
||||||
<com.android.settings.notification.DropDownPreference
|
<Preference android:key="sim_sms"
|
||||||
android:key="sim_sms"
|
|
||||||
android:title="@string/sms_messages_title" />
|
android:title="@string/sms_messages_title" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -58,6 +58,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.telephony.PhoneFactory;
|
import com.android.internal.telephony.PhoneFactory;
|
||||||
@@ -107,6 +112,9 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
private static final int ROAMING_PROTOCOL_INDEX = 19;
|
private static final int ROAMING_PROTOCOL_INDEX = 19;
|
||||||
private static final int MVNO_TYPE_INDEX = 20;
|
private static final int MVNO_TYPE_INDEX = 20;
|
||||||
private static final int MVNO_MATCH_DATA_INDEX = 21;
|
private static final int MVNO_MATCH_DATA_INDEX = 21;
|
||||||
|
private static final int DATA_PICK = 0;
|
||||||
|
private static final int CALLS_PICK = 1;
|
||||||
|
private static final int SMS_PICK = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
|
* By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
|
||||||
@@ -224,10 +232,6 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateActivitesCategory() {
|
private void updateActivitesCategory() {
|
||||||
createDropDown((DropDownPreference) findPreference(KEY_CELLULAR_DATA));
|
|
||||||
createDropDown((DropDownPreference) findPreference(KEY_CALLS));
|
|
||||||
createDropDown((DropDownPreference) findPreference(KEY_SMS));
|
|
||||||
|
|
||||||
updateCellularDataValues();
|
updateCellularDataValues();
|
||||||
updateCallValues();
|
updateCallValues();
|
||||||
updateSmsValues();
|
updateSmsValues();
|
||||||
@@ -271,34 +275,43 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSmsValues() {
|
private void updateSmsValues() {
|
||||||
final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_SMS);
|
final Preference simPref = (Preference) findPreference(KEY_SMS);
|
||||||
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultSmsSubId());
|
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultSmsSubId());
|
||||||
|
simPref.setTitle(R.string.sms_messages_title);
|
||||||
if (mSubInfoList.size() == 1) {
|
if (mSubInfoList.size() == 1) {
|
||||||
simPref.setSelectedItem(mSubInfoList.get(0).slotId + 1);
|
simPref.setSummary(mSubInfoList.get(0).displayName);
|
||||||
} else if (sir != null) {
|
} else if (sir != null) {
|
||||||
simPref.setSelectedItem(sir.slotId + 1);
|
simPref.setSummary(sir.displayName);
|
||||||
|
} else if (sir == null) {
|
||||||
|
simPref.setSummary(R.string.sim_selection_required_pref);
|
||||||
}
|
}
|
||||||
simPref.setEnabled(mNumSims >= 1);
|
simPref.setEnabled(mNumSims >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCellularDataValues() {
|
private void updateCellularDataValues() {
|
||||||
final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_CELLULAR_DATA);
|
final Preference simPref = (Preference) findPreference(KEY_CELLULAR_DATA);
|
||||||
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultDataSubId());
|
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultDataSubId());
|
||||||
|
simPref.setTitle(R.string.cellular_data_title);
|
||||||
if (mSubInfoList.size() == 1) {
|
if (mSubInfoList.size() == 1) {
|
||||||
simPref.setSelectedItem(mSubInfoList.get(0).slotId);
|
simPref.setSummary(mSubInfoList.get(0).displayName);
|
||||||
} else if (sir != null) {
|
} else if (sir != null) {
|
||||||
simPref.setSelectedItem(sir.slotId);
|
simPref.setSummary(sir.displayName);
|
||||||
|
} else if (sir == null) {
|
||||||
|
simPref.setSummary(R.string.sim_selection_required_pref);
|
||||||
}
|
}
|
||||||
simPref.setEnabled(mNumSims >= 1);
|
simPref.setEnabled(mNumSims >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCallValues() {
|
private void updateCallValues() {
|
||||||
final DropDownPreference simPref = (DropDownPreference) findPreference(KEY_CALLS);
|
final Preference simPref = (Preference) findPreference(KEY_CALLS);
|
||||||
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultVoiceSubId());
|
final SubInfoRecord sir = findRecordBySubId(SubscriptionManager.getDefaultVoiceSubId());
|
||||||
|
simPref.setTitle(R.string.calls_title);
|
||||||
if (mSubInfoList.size() == 1) {
|
if (mSubInfoList.size() == 1) {
|
||||||
simPref.setSelectedItem(mSubInfoList.get(0).slotId + 1);
|
simPref.setSummary(mSubInfoList.get(0).displayName);
|
||||||
} else if (sir != null) {
|
} else if (sir != null) {
|
||||||
simPref.setSelectedItem(sir.slotId + 1);
|
simPref.setSummary(sir.displayName);
|
||||||
|
} else if (sir == null) {
|
||||||
|
simPref.setSummary(R.string.sim_calls_ask_first_prefs_title);
|
||||||
}
|
}
|
||||||
simPref.setEnabled(mNumSims >= 1);
|
simPref.setEnabled(mNumSims >= 1);
|
||||||
}
|
}
|
||||||
@@ -317,47 +330,72 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
final Preference preference) {
|
final Preference preference) {
|
||||||
if (preference instanceof SimPreference) {
|
if (preference instanceof SimPreference) {
|
||||||
((SimPreference)preference).createEditDialog((SimPreference)preference);
|
((SimPreference)preference).createEditDialog((SimPreference)preference);
|
||||||
|
} else if ((Preference) findPreference(KEY_CELLULAR_DATA) == preference) {
|
||||||
|
showDialog(DATA_PICK);
|
||||||
|
} else if ((Preference) findPreference(KEY_CALLS) == preference) {
|
||||||
|
showDialog(CALLS_PICK);
|
||||||
|
} else if ((Preference) findPreference(KEY_SMS) == preference) {
|
||||||
|
showDialog(SMS_PICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createDropDown(DropDownPreference preference) {
|
|
||||||
final DropDownPreference simPref = preference;
|
|
||||||
final String keyPref = simPref.getKey();
|
|
||||||
final boolean askFirst = keyPref.equals(KEY_CALLS) || keyPref.equals(KEY_SMS);
|
|
||||||
|
|
||||||
simPref.clearItems();
|
|
||||||
|
|
||||||
if (askFirst) {
|
|
||||||
simPref.addItem(getResources().getString(
|
|
||||||
R.string.sim_calls_ask_first_prefs_title), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int subAvailableSize = mAvailableSubInfos.size();
|
|
||||||
for (int i = 0; i < subAvailableSize; ++i) {
|
|
||||||
final SubInfoRecord sir = mAvailableSubInfos.get(i);
|
|
||||||
if(sir != null){
|
|
||||||
simPref.addItem(sir.displayName, sir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
simPref.setCallback(new DropDownPreference.Callback() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemSelected(int pos, Object value) {
|
public Dialog onCreateDialog(final int id) {
|
||||||
final long subId = value == null ? 0 : ((SubInfoRecord)value).subId;
|
final ArrayList<String> list = new ArrayList<String>();
|
||||||
|
final int availableSubInfoLength = mAvailableSubInfos.size();
|
||||||
|
|
||||||
if (simPref.getKey().equals(KEY_CELLULAR_DATA)) {
|
final DialogInterface.OnClickListener selectionListener =
|
||||||
SubscriptionManager.setDefaultDataSubId(subId);
|
new DialogInterface.OnClickListener() {
|
||||||
} else if (simPref.getKey().equals(KEY_CALLS)) {
|
@Override
|
||||||
SubscriptionManager.setDefaultVoiceSubId(subId);
|
public void onClick(DialogInterface dialog, int value) {
|
||||||
} else if (simPref.getKey().equals(KEY_SMS)) {
|
|
||||||
SubscriptionManager.setDefaultSmsSubId(subId);
|
final SubInfoRecord sir;
|
||||||
|
|
||||||
|
if (id == DATA_PICK) {
|
||||||
|
sir = mAvailableSubInfos.get(value);
|
||||||
|
SubscriptionManager.setDefaultDataSubId(sir.subId);
|
||||||
|
} else if (id == CALLS_PICK) {
|
||||||
|
if (value != 0) {
|
||||||
|
sir = mAvailableSubInfos.get(value -1);
|
||||||
|
SubscriptionManager.setDefaultVoiceSubId(sir.subId);
|
||||||
|
} //have to figure out value of subid when user selects "ask everytime"
|
||||||
|
} else if (id == SMS_PICK) {
|
||||||
|
sir = mAvailableSubInfos.get(value);
|
||||||
|
SubscriptionManager.setDefaultSmsSubId(sir.subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
updateActivitesCategory();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (id == CALLS_PICK) {
|
||||||
|
list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < availableSubInfoLength; ++i) {
|
||||||
|
final SubInfoRecord sir = mAvailableSubInfos.get(i);
|
||||||
|
list.add(sir.displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] arr = new String[availableSubInfoLength];
|
||||||
|
arr = list.toArray(arr);
|
||||||
|
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
|
||||||
|
android.R.layout.simple_list_item_1, arr);
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
||||||
|
if (id == DATA_PICK) {
|
||||||
|
builder.setTitle(R.string.select_sim_for_data);
|
||||||
|
} else if (id == CALLS_PICK) {
|
||||||
|
builder.setTitle(R.string.select_sim_for_calls);
|
||||||
|
} else if (id == SMS_PICK) {
|
||||||
|
builder.setTitle(R.string.sim_card_select_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.setAdapter(adapter, selectionListener)
|
||||||
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActivity(Preference preference, SubInfoRecord sir) {
|
private void setActivity(Preference preference, SubInfoRecord sir) {
|
||||||
@@ -390,12 +428,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
public void update() {
|
public void update() {
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
|
|
||||||
if (mSubInfoRecord != null) {
|
if(mSubInfoRecord.displayName.length() == 0) {
|
||||||
if(TextUtils.isEmpty(mSubInfoRecord.displayName)) {
|
|
||||||
setTitle(getCarrierName());
|
setTitle(getCarrierName());
|
||||||
} else {
|
} else {
|
||||||
setTitle(mSubInfoRecord.displayName);
|
setTitle(mSubInfoRecord.displayName);
|
||||||
}
|
}
|
||||||
|
if (mSubInfoRecord != null) {
|
||||||
setSummary(mSubInfoRecord.number.toString());
|
setSummary(mSubInfoRecord.number.toString());
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user