Added cellular data popup in DataUsage

+ If the user attempts to enable data usage on a SIM that is not the
default, the system will confirm that the user wants data to go through
the new SIM.

Change-Id: Ia1652a30a3641bb29eadad20b2dc61321227a961
This commit is contained in:
PauloftheWest
2014-10-29 14:46:44 -07:00
parent 6f5b23f3fc
commit de33844d81
2 changed files with 56 additions and 2 deletions

View File

@@ -2114,6 +2114,10 @@
<string name="sim_multi_sims_title">Multiple SIMs found</string>
<!-- Multiple SIMs found summary. [CHAR LIMIT=100] -->
<string name="sim_multi_sims_summary">Choose the SIM you prefer for cellular data.</string>
<!-- Title asking user if they wish to change the default sim for cellular data. [CHAR LIMIT=30] -->
<string name="sim_change_data_title">Change data SIM?</string>
<!-- Message confirming the user wishes to change the default data SIM from one to another. [CHAR LIMIT=NONE] -->
<string name="sim_change_data_message">Use <xliff:g id="new_sim">%1$s</xliff:g> instead of <xliff:g id="old_sim">%2$s</xliff:g> for cellular data?</string>
<!-- Instructions telling the user that they entered the wrong SIM PIN for the last time.
Displayed in a dialog box. [CHAR LIMIT=100] -->

View File

@@ -1112,7 +1112,12 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
final String currentTab = mCurrentTab;
if (isMobileTab(currentTab)) {
if (dataEnabled) {
setMobileDataEnabled(true);
// If we are showing the Sim Card tile then we are a Multi-Sim device.
if (Utils.showSimCardTile(getActivity())) {
handleMultiSimDataDialog();
} else {
setMobileDataEnabled(true);
}
} else {
// disabling data; show confirmation dialog which eventually
// calls setMobileDataEnabled() once user confirms.
@@ -1124,6 +1129,36 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
}
};
private void handleMultiSimDataDialog() {
final SubInfoRecord currentSir = getCurrentTabSubInfo(getActivity());
final SubInfoRecord nextSir = SubscriptionManager.getSubInfoForSubscriber(
SubscriptionManager.getDefaultDataSubId());
if (currentSir.subId == nextSir.subId) {
setMobileDataEnabled(true);
updateBody();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.sim_change_data_title);
builder.setMessage(getActivity().getResources().getString(R.string.sim_change_data_message,
currentSir.displayName, nextSir.displayName));
builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
SubscriptionManager.setDefaultDataSubId(currentSir.subId);
setMobileDataEnabled(true);
updateBody();
}
});
builder.setNegativeButton(R.string.cancel, null);
builder.create().show();
}
private View.OnClickListener mDisableAtLimitListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -2553,7 +2588,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
private void addMobileTab(Context context, List<SubInfoRecord> subInfoList) {
if (subInfoList != null) {
for (SubInfoRecord subInfo : mSubInfoList) {
if (hasReadyMobileRadio(context,subInfo.subId)) {
if (hasReadyMobileRadio(context, subInfo.subId)) {
mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.subId),
subInfo.displayName));
}
@@ -2561,6 +2596,21 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
}
}
private SubInfoRecord getCurrentTabSubInfo(Context context) {
if (mSubInfoList != null && mTabHost != null) {
final int currentTagIndex = mTabHost.getCurrentTab();
int i = 0;
for (SubInfoRecord subInfo : mSubInfoList) {
if (hasReadyMobileRadio(context, subInfo.subId)) {
if (i++ == currentTagIndex) {
return subInfo;
}
}
}
}
return null;
}
/**
* Init a map with subId key and mobile tag name
* @param subInfoList The subscription Info List