am b62bfe71: Merge "Show toast when cellular data option is changing." into lmp-mr1-dev
* commit 'b62bfe715552fb86330958755f0e12ab0ffe7cad':
Show toast when cellular data option is changing.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 74062ae..58b8b8e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5519,6 +5519,8 @@
<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 switching data SIM; switching takes a while -->
+ <string name="data_switch_started">Switching data SIM, this may take up to a minute...</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] -->
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 6aceb46..da5769e 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -39,6 +39,7 @@
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -115,6 +116,7 @@
private static void setDefaultDataSubId(final Context context, final int subId) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
subscriptionManager.setDefaultDataSubId(subId);
+ Toast.makeText(context, R.string.data_switch_started, Toast.LENGTH_LONG).show();
}
private static void setDefaultSmsSubId(final Context context, final int subId) {
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 450ffff..92a10d6 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -18,26 +18,21 @@
import android.app.AlertDialog;
import android.content.Context;
-import android.content.ContentUris;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
-import android.database.Cursor;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
-import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.provider.SearchIndexableResource;
-import android.provider.Telephony;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.PhoneNumberUtils;
-import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.text.TextUtils;
@@ -49,12 +44,8 @@
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
-import android.app.Dialog;
import android.view.ViewGroup;
import android.widget.AdapterView;
-import android.widget.ListAdapter;
-
-import com.android.internal.telephony.PhoneFactory;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -62,9 +53,6 @@
import com.android.settings.R;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
public class SimSettings extends RestrictedSettingsFragment implements Indexable {
@@ -122,6 +110,7 @@
private SubscriptionManager mSubscriptionManager;
private Utils mUtils;
+
public SimSettings() {
super(DISALLOW_CONFIG_SIM);
}
@@ -283,152 +272,6 @@
return true;
}
- @Override
- public Dialog onCreateDialog(final int id) {
- final ArrayList<String> list = new ArrayList<String>();
- final int selectableSubInfoLength = mSelectableSubInfos.size();
-
- final DialogInterface.OnClickListener selectionListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int value) {
-
- final SubscriptionInfo sir;
-
- if (id == DATA_PICK) {
- sir = mSelectableSubInfos.get(value);
- mSubscriptionManager.setDefaultDataSubId(sir.getSubscriptionId());
- } else if (id == CALLS_PICK) {
- final TelecomManager telecomManager =
- TelecomManager.from(getActivity());
- final List<PhoneAccountHandle> phoneAccountsList =
- telecomManager.getCallCapablePhoneAccounts();
- telecomManager.setUserSelectedOutgoingPhoneAccount(
- value < 1 ? null : phoneAccountsList.get(value - 1));
- } else if (id == SMS_PICK) {
- sir = mSelectableSubInfos.get(value);
- mSubscriptionManager.setDefaultSmsSubId(sir.getSubscriptionId());
- }
-
- updateActivitesCategory();
- }
- };
-
- if (id == CALLS_PICK) {
- final TelecomManager telecomManager = TelecomManager.from(getActivity());
- final Iterator<PhoneAccountHandle> phoneAccounts =
- telecomManager.getCallCapablePhoneAccounts().listIterator();
-
- list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
- while (phoneAccounts.hasNext()) {
- final PhoneAccount phoneAccount =
- telecomManager.getPhoneAccount(phoneAccounts.next());
- list.add((String)phoneAccount.getLabel());
- }
- } else {
- for (int i = 0; i < selectableSubInfoLength; ++i) {
- final SubscriptionInfo sir = mSelectableSubInfos.get(i);
- CharSequence displayName = sir.getDisplayName();
- if (displayName == null) {
- displayName = "";
- }
- list.add(displayName.toString());
- }
- }
-
- String[] arr = list.toArray(new String[0]);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-
- ListAdapter adapter = new SelectAccountListAdapter(
- builder.getContext(),
- R.layout.select_account_list_item,
- arr, id);
-
- 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 class SelectAccountListAdapter extends ArrayAdapter<String> {
- private Context mContext;
- private int mResId;
- private int mDialogId;
- private final float OPACITY = 0.54f;
-
- public SelectAccountListAdapter(
- Context context, int resource, String[] arr, int dialogId) {
- super(context, resource, arr);
- mContext = context;
- mResId = resource;
- mDialogId = dialogId;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater)
- mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View rowView;
- final ViewHolder holder;
- SubscriptionInfo sir;
-
- if (convertView == null) {
- // Cache views for faster scrolling
- rowView = inflater.inflate(mResId, null);
- holder = new ViewHolder();
- holder.title = (TextView) rowView.findViewById(R.id.title);
- holder.summary = (TextView) rowView.findViewById(R.id.summary);
- holder.icon = (ImageView) rowView.findViewById(R.id.icon);
- rowView.setTag(holder);
- } else {
- rowView = convertView;
- holder = (ViewHolder) rowView.getTag();
- }
-
- if (mDialogId == CALLS_PICK) {
- holder.title.setText(getItem(position));
- if (position == 0) {
- holder.icon.setImageDrawable(getResources()
- .getDrawable(R.drawable.ic_live_help));
- holder.icon.setAlpha(OPACITY);
- holder.summary.setText("");
- } else {
- final TelecomManager telecomManager = TelecomManager.from(getActivity());
- final Iterator<PhoneAccountHandle> phoneAccounts =
- telecomManager.getCallCapablePhoneAccounts().listIterator();
- while (phoneAccounts.hasNext()) {
- final PhoneAccount phoneAccount =
- telecomManager.getPhoneAccount(phoneAccounts.next());
- if (getItem(position).equals((String) phoneAccount.getLabel())) {
- holder.icon.setImageBitmap(phoneAccount.getIconBitmap());
- holder.summary
- .setText(phoneAccount.getAddress().getSchemeSpecificPart());
- }
- }
- }
- } else {
- sir = mSelectableSubInfos.get(position);
- holder.title.setText(sir.getDisplayName());
- holder.summary.setText(getPhoneNumber(sir));
- holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
- }
- return rowView;
- }
-
- private class ViewHolder {
- TextView title;
- TextView summary;
- ImageView icon;
- }
- }
-
private class SimPreference extends Preference{
private SubscriptionInfo mSubInfoRecord;
private int mSlotId;