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

Commit ba53a846 authored by PauloftheWest's avatar PauloftheWest Committed by Android (Google) Code Review
Browse files

Merge "Added cellular data popup in DataUsage" into lmp-mr1-dev

parents 8d4f7f94 de33844d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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] -->
+52 −2
Original line number Diff line number Diff line
@@ -1112,7 +1112,12 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
            final String currentTab = mCurrentTab;
            if (isMobileTab(currentTab)) {
                if (dataEnabled) {
                    // 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) {
@@ -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