diff options
author | Walter Jang <wjang@google.com> | 2016-11-07 09:24:43 -0800 |
---|---|---|
committer | Abhisek Devkota <ciwrl@lineageos.org> | 2017-02-03 23:15:43 +0000 |
commit | f2ee7f03f49ee28823a1665d9ee111b05214c7e4 (patch) | |
tree | 2b22b87394abf6fb7021e0447e49554ac572cb25 /src/com/android/contacts/common/util | |
parent | 086f5bc849d2406d3686fe8f006c0247bb8b96dd (diff) | |
download | packages_apps_ContactsCommon-f2ee7f03f49ee28823a1665d9ee111b05214c7e4.tar.gz packages_apps_ContactsCommon-f2ee7f03f49ee28823a1665d9ee111b05214c7e4.tar.bz2 packages_apps_ContactsCommon-f2ee7f03f49ee28823a1665d9ee111b05214c7e4.zip |
resolve merge conflicts of 9f523b4 to nyc-dev
Bug: 32219099
Merged-In: Ib141ad682488aeabf6d90e8d169d5fff6df7a8dd
Change-Id: I895b1f9f8ade2dcfa47d1c17e0aaac2edeb75a74
(cherry picked from commit b7eecdd9a1276b721bb9644a0762dfd969e52709)
(cherry picked from commit d47661ad82d402c1e0c90eb83970687d784add1b)
# Conflicts:
# src/com/android/contacts/common/activity/RequestPermissionsActivity.java
# src/com/android/contacts/common/activity/RequestPermissionsActivityBase.java
# src/com/android/contacts/common/util/AccountSelectionUtil.java
# src/com/android/contacts/common/vcard/ImportVCardActivity.java
mh0rst: Backport from android-7.1.1_r9
Diffstat (limited to 'src/com/android/contacts/common/util')
-rw-r--r-- | src/com/android/contacts/common/util/AccountSelectionUtil.java | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/com/android/contacts/common/util/AccountSelectionUtil.java b/src/com/android/contacts/common/util/AccountSelectionUtil.java index 7d1d2f4f..219bb215 100644 --- a/src/com/android/contacts/common/util/AccountSelectionUtil.java +++ b/src/com/android/contacts/common/util/AccountSelectionUtil.java @@ -16,6 +16,7 @@ package com.android.contacts.common.util; +import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; @@ -59,33 +60,33 @@ public class AccountSelectionUtil { public static class AccountSelectedListener implements DialogInterface.OnClickListener { - final private Context mContext; + final private Activity mActivity; final private int mResId; final private int mSubscriptionId; protected List<AccountWithDataSet> mAccountList; - public AccountSelectedListener(Context context, List<AccountWithDataSet> accountList, + public AccountSelectedListener(Activity activity, List<AccountWithDataSet> accountList, int resId, int subscriptionId) { if (accountList == null || accountList.size() == 0) { Log.e(LOG_TAG, "The size of Account list is 0."); } - mContext = context; + mActivity = activity; mAccountList = accountList; mResId = resId; mSubscriptionId = subscriptionId; } - public AccountSelectedListener(Context context, List<AccountWithDataSet> accountList, + public AccountSelectedListener(Activity activity, List<AccountWithDataSet> accountList, int resId) { // Subscription id is only needed for importing from SIM card. We can safely ignore // its value for SD card importing. - this(context, accountList, resId, /* subscriptionId = */ -1); + this(activity, accountList, resId, /* subscriptionId = */ -1); } public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); - doImport(mContext, mResId, mAccountList.get(which)); + doImport(mActivity, mResId, mAccountList.get(which)); } /** * Reset the account list for this listener, to make sure the selected @@ -102,19 +103,19 @@ public class AccountSelectionUtil { mImportSub = subscription; } - public static Dialog getSelectAccountDialog(Context context, int resId) { - return getSelectAccountDialog(context, resId, null, null); + public static Dialog getSelectAccountDialog(Activity activity, int resId) { + return getSelectAccountDialog(activity, resId, null, null); } - public static Dialog getSelectAccountDialog(Context context, int resId, + public static Dialog getSelectAccountDialog(Activity activity, int resId, DialogInterface.OnClickListener onClickListener) { - return getSelectAccountDialog(context, resId, onClickListener, null); + return getSelectAccountDialog(activity, resId, onClickListener, null); } - public static Dialog getSelectAccountDialog(Context context, int resId, + public static Dialog getSelectAccountDialog(Activity activity, int resId, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener) { - return getSelectAccountDialog(context, resId, onClickListener, + return getSelectAccountDialog(activity, resId, onClickListener, onCancelListener, true); } @@ -122,10 +123,10 @@ public class AccountSelectionUtil { * When OnClickListener or OnCancelListener is null, uses a default listener. * The default OnCancelListener just closes itself with {@link Dialog#dismiss()}. */ - public static Dialog getSelectAccountDialog(Context context, int resId, + public static Dialog getSelectAccountDialog(Activity activity, int resId, DialogInterface.OnClickListener onClickListener, DialogInterface.OnCancelListener onCancelListener, boolean includeSIM) { - final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context); + final AccountTypeManager accountTypes = AccountTypeManager.getInstance(activity); List<AccountWithDataSet> writableAccountList; if (includeSIM) { writableAccountList = accountTypes.getAccounts(true); @@ -140,11 +141,11 @@ public class AccountSelectionUtil { // Wrap our context to inflate list items using correct theme final Context dialogContext = new ContextThemeWrapper( - context, android.R.style.Theme_Light); + activity, android.R.style.Theme_Light); final LayoutInflater dialogInflater = (LayoutInflater)dialogContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayAdapter<AccountWithDataSet> accountAdapter = - new ArrayAdapter<AccountWithDataSet>(context, android.R.layout.simple_list_item_2, + new ArrayAdapter<AccountWithDataSet>(activity, android.R.layout.simple_list_item_2, writableAccountList) { @Override @@ -175,7 +176,7 @@ public class AccountSelectionUtil { if (onClickListener == null) { AccountSelectedListener accountSelectedListener = - new AccountSelectedListener(context, writableAccountList, resId); + new AccountSelectedListener(activity, writableAccountList, resId); onClickListener = accountSelectedListener; } else if (onClickListener instanceof AccountSelectedListener) { // Because the writableAccountList is different if includeSIM or not, so @@ -192,22 +193,22 @@ public class AccountSelectionUtil { } }; } - return new AlertDialog.Builder(context) + return new AlertDialog.Builder(activity) .setTitle(R.string.dialog_new_contact_account) .setSingleChoiceItems(accountAdapter, 0, onClickListener) .setOnCancelListener(onCancelListener) .create(); } - public static void doImport(Context context, int resId, + public static void doImport(Activity activity, int resId, AccountWithDataSet account) { switch (resId) { case R.string.import_from_sim: { - doImportFromSim(context, account); + doImportFromSim(activity, account); break; } case R.string.import_from_vcf_file: { - doImportFromVcfFile(context, account); + doImportFromVcfFile(activity, account); break; } } @@ -228,8 +229,8 @@ public class AccountSelectionUtil { context.startActivity(importIntent); } - public static void doImportFromVcfFile(Context context, AccountWithDataSet account) { - Intent importIntent = new Intent(context, ImportVCardActivity.class); + public static void doImportFromVcfFile(Activity activity, AccountWithDataSet account) { + Intent importIntent = new Intent(activity, ImportVCardActivity.class); if (account != null) { importIntent.putExtra("account_name", account.name); importIntent.putExtra("account_type", account.type); @@ -242,6 +243,6 @@ public class AccountSelectionUtil { } mVCardShare = false; mPath = null; - context.startActivity(importIntent); + activity.startActivityForResult(importIntent, 0); } } |