Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.contacts.common.interactions; |
| 18 | |
Sai Cheemalapati | 8ee2e27 | 2014-08-06 10:30:21 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 20 | import android.app.AlertDialog; |
| 21 | import android.app.Dialog; |
Brian Attwell | c2e912c | 2014-10-27 12:29:44 -0700 | [diff] [blame] | 22 | import android.app.DialogFragment; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 23 | import android.app.FragmentManager; |
| 24 | import android.content.Context; |
| 25 | import android.content.DialogInterface; |
Marcus Hagerott | a8b448a | 2016-11-18 12:51:39 -0800 | [diff] [blame] | 26 | import android.content.Intent; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 27 | import android.content.res.Resources; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 29 | import android.text.TextUtils; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 30 | import android.util.Log; |
| 31 | import android.view.LayoutInflater; |
| 32 | import android.view.View; |
| 33 | import android.view.ViewGroup; |
| 34 | import android.widget.ArrayAdapter; |
| 35 | import android.widget.TextView; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 36 | |
Marcus Hagerott | 819214d | 2016-09-29 14:58:27 -0700 | [diff] [blame] | 37 | import com.android.contacts.SimImportFragment; |
Marcus Hagerott | a8b448a | 2016-11-18 12:51:39 -0800 | [diff] [blame] | 38 | import com.android.contacts.activities.SimImportActivity; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 39 | import com.android.contacts.common.R; |
Wenyi Wang | 13d952e | 2015-12-09 09:44:44 -0800 | [diff] [blame] | 40 | import com.android.contacts.common.compat.CompatUtils; |
Brandon Maxwell | 62cfa6e | 2015-12-04 15:27:45 -0800 | [diff] [blame] | 41 | import com.android.contacts.common.compat.PhoneNumberUtilsCompat; |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 42 | import com.android.contacts.common.database.SimContactDao; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 43 | import com.android.contacts.common.model.AccountTypeManager; |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 44 | import com.android.contacts.common.model.SimCard; |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 45 | import com.android.contacts.common.model.SimContact; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 46 | import com.android.contacts.common.model.account.AccountWithDataSet; |
| 47 | import com.android.contacts.common.util.AccountSelectionUtil; |
| 48 | import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter; |
Walter Jang | 55d0e71 | 2016-08-31 17:11:36 -0700 | [diff] [blame] | 49 | import com.android.contacts.editor.SelectAccountDialogFragment; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 50 | |
| 51 | import java.util.List; |
| 52 | |
| 53 | /** |
| 54 | * An dialog invoked to import/export contacts. |
| 55 | */ |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 56 | public class ImportDialogFragment extends DialogFragment { |
James Laskey | 1e2102f | 2016-09-19 10:09:08 -0700 | [diff] [blame] | 57 | public static final String TAG = "ImportDialogFragment"; |
Wenyi Wang | c33f492 | 2015-09-24 15:28:59 -0700 | [diff] [blame] | 58 | |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 59 | public static final String KEY_RES_ID = "resourceId"; |
| 60 | public static final String KEY_SUBSCRIPTION_ID = "subscriptionId"; |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 61 | |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 62 | public static final String EXTRA_SIM_ONLY = "extraSimOnly"; |
| 63 | |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 64 | public static final String EXTRA_SIM_CONTACT_COUNT_PREFIX = "simContactCount_"; |
| 65 | |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 66 | private boolean mSimOnly = false; |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 67 | private SimContactDao mSimDao; |
Wenyi Wang | c33f492 | 2015-09-24 15:28:59 -0700 | [diff] [blame] | 68 | |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 69 | /** Preferred way to show this dialog */ |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 70 | public static void show(FragmentManager fragmentManager) { |
| 71 | final ImportDialogFragment fragment = new ImportDialogFragment(); |
| 72 | fragment.show(fragmentManager, TAG); |
| 73 | } |
| 74 | |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 75 | public static void show(FragmentManager fragmentManager, List<SimCard> sims, |
| 76 | boolean includeVcf) { |
James Laskey | 1e2102f | 2016-09-19 10:09:08 -0700 | [diff] [blame] | 77 | final ImportDialogFragment fragment = new ImportDialogFragment(); |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 78 | final Bundle args = new Bundle(); |
| 79 | args.putBoolean(EXTRA_SIM_ONLY, !includeVcf); |
| 80 | for (SimCard sim : sims) { |
| 81 | final List<SimContact> contacts = sim.getContacts(); |
| 82 | if (contacts == null) { |
| 83 | continue; |
| 84 | } |
| 85 | args.putInt(EXTRA_SIM_CONTACT_COUNT_PREFIX + sim.getSimId(), contacts.size()); |
| 86 | } |
| 87 | |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 88 | fragment.setArguments(args); |
James Laskey | 1e2102f | 2016-09-19 10:09:08 -0700 | [diff] [blame] | 89 | fragment.show(fragmentManager, TAG); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | @Override |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 93 | public void onCreate(Bundle savedInstanceState) { |
| 94 | super.onCreate(savedInstanceState); |
| 95 | |
Sean Midford | 9da13ab | 2016-11-07 14:15:54 -0800 | [diff] [blame] | 96 | setStyle(STYLE_NORMAL, R.style.ContactsAlertDialogTheme); |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 97 | |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 98 | final Bundle args = getArguments(); |
| 99 | mSimOnly = args != null && args.getBoolean(EXTRA_SIM_ONLY, false); |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 100 | mSimDao = SimContactDao.create(getContext()); |
Marcus Hagerott | 02f5dba | 2016-10-18 12:34:57 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | @Override |
Wenyi Wang | 9342fbb | 2015-11-17 19:36:35 -0800 | [diff] [blame] | 104 | public Context getContext() { |
| 105 | return getActivity(); |
| 106 | } |
| 107 | |
| 108 | @Override |
Sai Cheemalapati | 8ee2e27 | 2014-08-06 10:30:21 -0700 | [diff] [blame] | 109 | public void onAttach(Activity activity) { |
| 110 | super.onAttach(activity); |
Sai Cheemalapati | 8ee2e27 | 2014-08-06 10:30:21 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Override |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 114 | public Dialog onCreateDialog(Bundle savedInstanceState) { |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 115 | final LayoutInflater dialogInflater = (LayoutInflater) |
| 116 | getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 117 | |
| 118 | // Adapter that shows a list of string resources |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 119 | final ArrayAdapter<AdapterEntry> adapter = new ArrayAdapter<AdapterEntry>(getActivity(), |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 120 | R.layout.select_dialog_item) { |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 121 | |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 122 | @Override |
| 123 | public View getView(int position, View convertView, ViewGroup parent) { |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 124 | final View result = convertView != null ? convertView : |
| 125 | dialogInflater.inflate(R.layout.select_dialog_item, parent, false); |
| 126 | final TextView primaryText = (TextView) result.findViewById(R.id.primary_text); |
| 127 | final TextView secondaryText = (TextView) result.findViewById(R.id.secondary_text); |
| 128 | final AdapterEntry entry = getItem(position); |
| 129 | secondaryText.setVisibility(View.GONE); |
| 130 | if (entry.mChoiceResourceId == R.string.import_from_sim) { |
| 131 | final CharSequence secondary = getSimSecondaryText(entry.mSim); |
| 132 | if (TextUtils.isEmpty(secondary)) { |
| 133 | secondaryText.setVisibility(View.GONE); |
| 134 | } else { |
| 135 | secondaryText.setText(secondary); |
| 136 | secondaryText.setVisibility(View.VISIBLE); |
| 137 | } |
| 138 | } |
| 139 | primaryText.setText(entry.mLabel); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 140 | return result; |
| 141 | } |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 142 | |
| 143 | CharSequence getSimSecondaryText(SimCard sim) { |
| 144 | int count = getSimContactCount(sim); |
| 145 | |
| 146 | CharSequence phone = sim.getFormattedPhone(); |
| 147 | if (phone == null) { |
| 148 | phone = sim.getPhone(); |
| 149 | } |
| 150 | if (phone != null) { |
| 151 | phone = PhoneNumberUtilsCompat.createTtsSpannable(phone); |
| 152 | } |
| 153 | |
| 154 | if (count != -1 && phone != null) { |
| 155 | // We use a template instead of format string so that the TTS span is preserved |
| 156 | final CharSequence template = getResources() |
| 157 | .getQuantityString(R.plurals.import_from_sim_secondary_template, count); |
| 158 | return TextUtils.expandTemplate(template, String.valueOf(count), phone); |
| 159 | } else if (phone != null) { |
| 160 | return phone; |
| 161 | } else if (count != -1) { |
| 162 | // count != -1 |
| 163 | return getResources() |
| 164 | .getQuantityString( |
| 165 | R.plurals.import_from_sim_secondary_contact_count_fmt, count, |
| 166 | count); |
| 167 | } else { |
| 168 | return null; |
| 169 | } |
| 170 | } |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 171 | }; |
| 172 | |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 173 | addItems(adapter); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 174 | |
| 175 | final DialogInterface.OnClickListener clickListener = |
| 176 | new DialogInterface.OnClickListener() { |
| 177 | @Override |
| 178 | public void onClick(DialogInterface dialog, int which) { |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 179 | final int resId = adapter.getItem(which).mChoiceResourceId; |
Marcus Hagerott | 819214d | 2016-09-29 14:58:27 -0700 | [diff] [blame] | 180 | if (resId == R.string.import_from_sim) { |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 181 | handleSimImportRequest(adapter.getItem(which).mSim); |
Marcus Hagerott | 819214d | 2016-09-29 14:58:27 -0700 | [diff] [blame] | 182 | } else if (resId == R.string.import_from_vcf_file) { |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 183 | handleImportRequest(resId, SimCard.NO_SUBSCRIPTION_ID); |
Sailesh Nepal | b4a522e | 2016-02-20 21:17:32 -0800 | [diff] [blame] | 184 | } else { |
Sailesh Nepal | b4a522e | 2016-02-20 21:17:32 -0800 | [diff] [blame] | 185 | Log.e(TAG, "Unexpected resource: " |
| 186 | + getActivity().getResources().getResourceEntryName(resId)); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 187 | } |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 188 | dialog.dismiss(); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 189 | } |
| 190 | }; |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 191 | |
| 192 | final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getTheme()) |
| 193 | .setTitle(R.string.dialog_import) |
| 194 | .setNegativeButton(android.R.string.cancel, null); |
| 195 | if (adapter.isEmpty()) { |
| 196 | // Handle edge case; e.g. SIM card was removed. |
| 197 | builder.setMessage(R.string.nothing_to_import_message); |
| 198 | } else { |
| 199 | builder.setSingleChoiceItems(adapter, -1, clickListener); |
| 200 | } |
| 201 | |
| 202 | return builder.create(); |
| 203 | } |
| 204 | |
| 205 | private int getSimContactCount(SimCard sim) { |
| 206 | if (sim.getContacts() != null) { |
| 207 | return sim.getContacts().size(); |
| 208 | } |
| 209 | final Bundle args = getArguments(); |
| 210 | if (args == null) { |
| 211 | return -1; |
| 212 | } |
| 213 | return args.getInt(EXTRA_SIM_CONTACT_COUNT_PREFIX + sim.getSimId(), -1); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 214 | } |
| 215 | |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 216 | private void addItems(ArrayAdapter<AdapterEntry> adapter) { |
| 217 | final Resources res = getActivity().getResources(); |
| 218 | if (res.getBoolean(R.bool.config_allow_import_from_vcf_file) && !mSimOnly) { |
| 219 | adapter.add(new AdapterEntry(getString(R.string.import_from_vcf_file), |
| 220 | R.string.import_from_vcf_file)); |
| 221 | } |
| 222 | final List<SimCard> sims = mSimDao.getSimCards(); |
| 223 | |
| 224 | if (sims.size() == 1) { |
| 225 | adapter.add(new AdapterEntry(getString(R.string.import_from_sim), |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 226 | R.string.import_from_sim, sims.get(0))); |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 227 | return; |
| 228 | } |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 229 | for (int i = 0; i < sims.size(); i++) { |
| 230 | final SimCard sim = sims.get(i); |
| 231 | adapter.add(new AdapterEntry(getSimDescription(sim, i), R.string.import_from_sim, sim)); |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 235 | private void handleSimImportRequest(SimCard sim) { |
Marcus Hagerott | a8b448a | 2016-11-18 12:51:39 -0800 | [diff] [blame] | 236 | startActivity(new Intent(getActivity(), SimImportActivity.class) |
| 237 | .putExtra(SimImportActivity.EXTRA_SUBSCRIPTION_ID, sim.getSubscriptionId())); |
Marcus Hagerott | 819214d | 2016-09-29 14:58:27 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 240 | /** |
Marcus Hagerott | 819214d | 2016-09-29 14:58:27 -0700 | [diff] [blame] | 241 | * Handle "import from SD". |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 242 | */ |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 243 | private void handleImportRequest(int resId, int subscriptionId) { |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 244 | // There are three possibilities: |
| 245 | // - more than one accounts -> ask the user |
| 246 | // - just one account -> use the account without asking the user |
| 247 | // - no account -> use phone-local storage without asking the user |
| 248 | final AccountTypeManager accountTypes = AccountTypeManager.getInstance(getActivity()); |
| 249 | final List<AccountWithDataSet> accountList = accountTypes.getAccounts(true); |
| 250 | final int size = accountList.size(); |
| 251 | if (size > 1) { |
| 252 | // Send over to the account selector |
| 253 | final Bundle args = new Bundle(); |
| 254 | args.putInt(KEY_RES_ID, resId); |
Jay Shrauner | cf08222 | 2014-11-25 13:52:50 -0800 | [diff] [blame] | 255 | args.putInt(KEY_SUBSCRIPTION_ID, subscriptionId); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 256 | SelectAccountDialogFragment.show( |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 257 | getFragmentManager(), R.string.dialog_new_contact_account, |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 258 | AccountListFilter.ACCOUNTS_CONTACT_WRITABLE, args); |
Wenyi Wang | c332228 | 2016-11-11 14:53:29 -0800 | [diff] [blame] | 259 | } else { |
| 260 | AccountSelectionUtil.doImport(getActivity(), resId, |
| 261 | (size == 1 ? accountList.get(0) : null), |
| 262 | (CompatUtils.isMSIMCompatible() ? subscriptionId : -1)); |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 263 | } |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 264 | } |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 265 | |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 266 | private CharSequence getSimDescription(SimCard sim, int index) { |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 267 | final CharSequence name = sim.getDisplayName(); |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 268 | if (name != null) { |
Marcus Hagerott | 216e297 | 2016-10-26 15:53:42 -0700 | [diff] [blame] | 269 | return getString(R.string.import_from_sim_summary_fmt, name); |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 270 | } else { |
| 271 | return getString(R.string.import_from_sim_summary_fmt, String.valueOf(index)); |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 272 | } |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | private static class AdapterEntry { |
Ihab Awad | 3732180 | 2014-12-05 16:23:11 -0800 | [diff] [blame] | 276 | public final CharSequence mLabel; |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 277 | public final int mChoiceResourceId; |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 278 | public final SimCard mSim; |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 279 | |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 280 | public AdapterEntry(CharSequence label, int resId, SimCard sim) { |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 281 | mLabel = label; |
| 282 | mChoiceResourceId = resId; |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 283 | mSim = sim; |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | public AdapterEntry(String label, int resId) { |
Brian Attwell | 87ffb82 | 2015-02-03 10:28:11 -0800 | [diff] [blame] | 287 | // Store a nonsense value for mSubscriptionId. If this constructor is used, |
| 288 | // the mSubscriptionId value should not be read later. |
Marcus Hagerott | 8636d1e | 2016-10-27 19:14:12 -0700 | [diff] [blame] | 289 | this(label, resId, /* sim= */ null); |
Brian Attwell | c07c8bb | 2014-10-06 14:55:49 -0700 | [diff] [blame] | 290 | } |
| 291 | } |
Chiao Cheng | 6fe32c0 | 2012-12-04 15:44:17 -0800 | [diff] [blame] | 292 | } |