diff options
author | Ihab Awad <ihab@google.com> | 2014-06-30 21:21:38 -0700 |
---|---|---|
committer | Ihab Awad <ihab@google.com> | 2014-07-02 12:37:00 -0700 |
commit | ad12d04e15a8a66c43893fb29cf08649bd0b675e (patch) | |
tree | 352610dcaeec877810a442937a4d72660368ded6 | |
parent | dcc47113e3a5705e32c9b7e769c38aefdd4bd0e9 (diff) | |
download | packages_apps_ContactsCommon-ad12d04e15a8a66c43893fb29cf08649bd0b675e.tar.gz packages_apps_ContactsCommon-ad12d04e15a8a66c43893fb29cf08649bd0b675e.tar.bz2 packages_apps_ContactsCommon-ad12d04e15a8a66c43893fb29cf08649bd0b675e.zip |
Rename Telecomm "Subscription" to "Account" (2/7)
Change-Id: I73cd3d1a2e7ae12f2e8d94f0a093c6d91bf7c912
-rw-r--r-- | src/com/android/contacts/common/CallUtil.java | 29 | ||||
-rw-r--r-- | src/com/android/contacts/common/PhoneAccountManager.java (renamed from src/com/android/contacts/common/SubscriptionManager.java) | 26 | ||||
-rw-r--r-- | src/com/android/contacts/common/dialog/SelectAccountDialogFragment.java (renamed from src/com/android/contacts/common/dialog/SelectSubscriptionDialogFragment.java) | 50 | ||||
-rw-r--r-- | src/com/android/contacts/common/model/AccountTypeManager.java | 13 | ||||
-rw-r--r-- | src/com/android/contacts/common/util/LocalizedNameResolver.java | 4 | ||||
-rw-r--r-- | tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java | 16 | ||||
-rw-r--r-- | tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java | 6 |
7 files changed, 71 insertions, 73 deletions
diff --git a/src/com/android/contacts/common/CallUtil.java b/src/com/android/contacts/common/CallUtil.java index 0d86bbe3..87440e96 100644 --- a/src/com/android/contacts/common/CallUtil.java +++ b/src/com/android/contacts/common/CallUtil.java @@ -18,9 +18,8 @@ package com.android.contacts.common; import android.content.Intent; import android.net.Uri; -import android.telecomm.Subscription; +import android.telecomm.PhoneAccount; import android.telephony.TelephonyManager; -import android.util.Log; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.phone.common.PhoneConstants; @@ -61,40 +60,40 @@ public class CallUtil { } /** - * A variant of {@link #getCallIntent(String)} but also include {@code Subscription}. + * A variant of {@link #getCallIntent(String)} but also include {@code Account}. */ - public static Intent getCallIntent(String number, Subscription subscription) { - return getCallIntent(number, null, subscription); + public static Intent getCallIntent(String number, PhoneAccount account) { + return getCallIntent(number, null, account); } /** - * A variant of {@link #getCallIntent(android.net.Uri)} but also include {@code Subscription}. + * A variant of {@link #getCallIntent(android.net.Uri)} but also include {@code Account}. */ - public static Intent getCallIntent(Uri uri, Subscription subscription) { - return getCallIntent(uri, null, subscription); + public static Intent getCallIntent(Uri uri, PhoneAccount account) { + return getCallIntent(uri, null, account); } /** - * A variant of {@link #getCallIntent(String, String)} but also include {@code Subscription}. + * A variant of {@link #getCallIntent(String, String)} but also include {@code Account}. */ public static Intent getCallIntent(String number, String callOrigin, - Subscription subscription) { - return getCallIntent(getCallUri(number), callOrigin, subscription); + PhoneAccount account) { + return getCallIntent(getCallUri(number), callOrigin, account); } /** * A variant of {@link #getCallIntent(android.net.Uri)} but also accept a call - * origin and {@code Subscription}. + * origin and {@code Account}. * For more information about call origin, see comments in Phone package (PhoneApp). */ - public static Intent getCallIntent(Uri uri, String callOrigin, Subscription subscription) { + public static Intent getCallIntent(Uri uri, String callOrigin, PhoneAccount account) { final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (callOrigin != null) { intent.putExtra(PhoneConstants.EXTRA_CALL_ORIGIN, callOrigin); } - if (subscription != null) { - intent.putExtra(TelephonyManager.EXTRA_SUBSCRIPTION, subscription); + if (account != null) { + intent.putExtra(TelephonyManager.EXTRA_ACCOUNT, account); } return intent; diff --git a/src/com/android/contacts/common/SubscriptionManager.java b/src/com/android/contacts/common/PhoneAccountManager.java index 95c0e0d0..c3d399f1 100644 --- a/src/com/android/contacts/common/SubscriptionManager.java +++ b/src/com/android/contacts/common/PhoneAccountManager.java @@ -16,36 +16,36 @@ package com.android.contacts.common; -import android.telecomm.Subscription; +import android.telecomm.PhoneAccount; import android.telephony.TelephonyManager; import java.util.List; /** - * To pass current subscription information between activities/fragments. + * To pass current account information between activities/fragments. */ -public class SubscriptionManager { - private Subscription mCurrentSubscription = null; +public class PhoneAccountManager { + private PhoneAccount mCurrentAccount = null; private TelephonyManager mTelephonyManager; - public SubscriptionManager(TelephonyManager telephonyManager, Subscription subscription) { + public PhoneAccountManager(TelephonyManager telephonyManager, PhoneAccount account) { mTelephonyManager = telephonyManager; - mCurrentSubscription = subscription; + mCurrentAccount = account; } - public SubscriptionManager(TelephonyManager telephonyManager) { + public PhoneAccountManager(TelephonyManager telephonyManager) { mTelephonyManager = telephonyManager; } - public Subscription getCurrentSubscription() { - return mCurrentSubscription; + public PhoneAccount getCurrentAccount() { + return mCurrentAccount; } - public void setCurrentSubscription(Subscription subscription) { - mCurrentSubscription = subscription; + public void setCurrentAccount(PhoneAccount account) { + mCurrentAccount = account; } - public List<Subscription> getSubscriptions() { - return mTelephonyManager.getSubscriptions(); + public List<PhoneAccount> getAccounts() { + return mTelephonyManager.getAccounts(); } } diff --git a/src/com/android/contacts/common/dialog/SelectSubscriptionDialogFragment.java b/src/com/android/contacts/common/dialog/SelectAccountDialogFragment.java index d7ecb032..5fdeba20 100644 --- a/src/com/android/contacts/common/dialog/SelectSubscriptionDialogFragment.java +++ b/src/com/android/contacts/common/dialog/SelectAccountDialogFragment.java @@ -23,10 +23,10 @@ import android.app.FragmentManager; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.telecomm.Subscription; +import android.telecomm.PhoneAccount; +import com.android.contacts.common.PhoneAccountManager; import com.android.contacts.common.R; -import com.android.contacts.common.SubscriptionManager; import java.util.ArrayList; import java.util.Arrays; @@ -35,23 +35,23 @@ import java.util.List; /** * Dialog that allows the user to switch between default SIM cards */ -public class SelectSubscriptionDialogFragment extends DialogFragment { - private SubscriptionManager mSubscriptionManager; +public class SelectAccountDialogFragment extends DialogFragment { + private PhoneAccountManager mAccountManager; private int mSelection; - private List<Subscription> mSubscriptions; + private List<PhoneAccount> mAccounts; private static final int NO_SELECTION = -1; /* Preferred way to show this dialog */ public static void show(FragmentManager fragmentManager, - SubscriptionManager subscriptionManager) { - SelectSubscriptionDialogFragment fragment = new SelectSubscriptionDialogFragment(); - fragment.mSubscriptionManager = subscriptionManager; - fragment.show(fragmentManager, "selectSubscription"); + PhoneAccountManager accountManager) { + SelectAccountDialogFragment fragment = new SelectAccountDialogFragment(); + fragment.mAccountManager = accountManager; + fragment.show(fragmentManager, "selectAccount"); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - mSubscriptions = mSubscriptionManager.getSubscriptions(); + mAccounts = mAccountManager.getAccounts(); mSelection = NO_SELECTION; final DialogInterface.OnClickListener selectionListener = @@ -66,49 +66,49 @@ public class SelectSubscriptionDialogFragment extends DialogFragment { @Override public void onClick(DialogInterface dialog, int id) { if (mSelection != NO_SELECTION) { - // No need to update the current subscription if it has not been changed - mSubscriptionManager.setCurrentSubscription(mSubscriptions.get(mSelection)); + // No need to update the current account if it has not been changed + mAccountManager.setCurrentAccount(mAccounts.get(mSelection)); } } }; - CharSequence[] names = getSubscriptionNames(); + CharSequence[] names = getAccountNames(); return new AlertDialog.Builder(getActivity()) .setTitle(R.string.menu_select_sim) - .setSingleChoiceItems(names, getSelectedSubscriptionIndex(names), selectionListener) + .setSingleChoiceItems(names, getSelectedAccountIndex(names), selectionListener) .setPositiveButton(android.R.string.ok, okListener) .setNegativeButton(android.R.string.cancel, null) .create(); } /** - * Helper function to extract the index of the currently selected subscription. + * Helper function to extract the index of the currently selected account. * Used in the dialog as the initially selected radio button. * * @param activeSubs String list of the labels referring to each of possible - * active subscriptions to choose from - * @return the index of the selected subscription in the array of subscriptions + * active accounts to choose from + * @return the index of the selected account in the array of accounts */ - private int getSelectedSubscriptionIndex(CharSequence[] activeSubs) { - Subscription initialSubscription = mSubscriptionManager.getCurrentSubscription(); - if (initialSubscription == null) { + private int getSelectedAccountIndex(CharSequence[] activeSubs) { + PhoneAccount initialAccount = mAccountManager.getCurrentAccount(); + if (initialAccount == null) { return -1; } else { - return Arrays.asList(activeSubs).indexOf(initialSubscription.getLabel(getActivity())); + return Arrays.asList(activeSubs).indexOf(initialAccount.getLabel(getActivity())); } } /** - * Extracts the label names from each of the subscriptions and returns as a list of strings + * Extracts the label names from each of the accounts and returns as a list of strings * * @return a list of strings to display in the dialog */ - private CharSequence[] getSubscriptionNames() { + private CharSequence[] getAccountNames() { Context context = getActivity(); List<String> strings = new ArrayList<String>(); - for (int i = 0; i < mSubscriptions.size(); i++) { - strings.add(mSubscriptions.get(i).getLabel(context)); + for (int i = 0; i < mAccounts.size(); i++) { + strings.add(mAccounts.get(i).getLabel(context)); } return strings.toArray(new CharSequence[strings.size()]); } diff --git a/src/com/android/contacts/common/model/AccountTypeManager.java b/src/com/android/contacts/common/model/AccountTypeManager.java index 72878804..8da09122 100644 --- a/src/com/android/contacts/common/model/AccountTypeManager.java +++ b/src/com/android/contacts/common/model/AccountTypeManager.java @@ -17,7 +17,7 @@ package com.android.contacts.common.model; import android.accounts.Account; -import android.accounts.AccountManager; +import android.accounts.PhoneAccountManager; import android.accounts.AuthenticatorDescription; import android.accounts.OnAccountsUpdateListener; import android.content.BroadcastReceiver; @@ -35,7 +35,6 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; -import android.os.RemoteException; import android.os.SystemClock; import android.provider.ContactsContract; import android.text.TextUtils; @@ -192,7 +191,7 @@ class AccountTypeManagerImpl extends AccountTypeManager 1, "xxx"); private Context mContext; - private AccountManager mAccountManager; + private PhoneAccountManager mPhoneAccountManager; private AccountType mFallbackAccountType; @@ -290,7 +289,7 @@ class AccountTypeManagerImpl extends AccountTypeManager mContext = context; mFallbackAccountType = new FallbackAccountType(context); - mAccountManager = AccountManager.get(mContext); + mPhoneAccountManager = PhoneAccountManager.get(mContext); mListenerThread = new HandlerThread("AccountChangeListener"); mListenerThread.start(); @@ -326,7 +325,7 @@ class AccountTypeManagerImpl extends AccountTypeManager filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiver(mBroadcastReceiver, filter); - mAccountManager.addOnAccountsUpdatedListener(this, mListenerHandler, false); + mPhoneAccountManager.addOnAccountsUpdatedListener(this, mListenerHandler, false); ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this); @@ -393,7 +392,7 @@ class AccountTypeManagerImpl extends AccountTypeManager final List<AccountWithDataSet> groupWritableAccounts = Lists.newArrayList(); final Set<String> extensionPackages = Sets.newHashSet(); - final AccountManager am = mAccountManager; + final PhoneAccountManager am = mPhoneAccountManager; final SyncAdapterType[] syncs = ContentResolver.getSyncAdapterTypes(); final AuthenticatorDescription[] auths = am.getAuthenticatorTypes(); @@ -476,7 +475,7 @@ class AccountTypeManagerImpl extends AccountTypeManager timings.addSplit("Loaded account types"); // Map in accounts to associate the account names with each account type entry. - Account[] accounts = mAccountManager.getAccounts(); + Account[] accounts = mPhoneAccountManager.getAccounts(); for (Account account : accounts) { boolean syncable = ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY) > 0; diff --git a/src/com/android/contacts/common/util/LocalizedNameResolver.java b/src/com/android/contacts/common/util/LocalizedNameResolver.java index 3c21946a..7187f39c 100644 --- a/src/com/android/contacts/common/util/LocalizedNameResolver.java +++ b/src/com/android/contacts/common/util/LocalizedNameResolver.java @@ -16,7 +16,7 @@ package com.android.contacts.common.util; -import android.accounts.AccountManager; +import android.accounts.PhoneAccountManager; import android.accounts.AuthenticatorDescription; import android.content.Context; import android.content.pm.PackageInfo; @@ -66,7 +66,7 @@ public class LocalizedNameResolver { * Finds "All Contacts"-Name for the specified account type. */ private static String resolveAllContactsName(Context context, String accountType) { - final AccountManager am = AccountManager.get(context); + final PhoneAccountManager am = PhoneAccountManager.get(context); for (AuthenticatorDescription auth : am.getAuthenticatorTypes()) { if (accountType.equals(auth.type)) { diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java b/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java index 2f676c70..e6a47cda 100644 --- a/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java +++ b/tests/src/com/android/contacts/common/tests/testauth/TestAuthenticator.java @@ -19,7 +19,7 @@ package com.android.contacts.common.tests.testauth; import android.accounts.AbstractAccountAuthenticator; import android.accounts.Account; import android.accounts.AccountAuthenticatorResponse; -import android.accounts.AccountManager; +import android.accounts.PhoneAccountManager; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; @@ -67,11 +67,11 @@ class TestAuthenticator extends AbstractAccountAuthenticator { final Account account = new Account(newUniqueUserName(), accountType); // Create an account. - AccountManager.get(mContext).addAccountExplicitly(account, PASSWORD, null); + PhoneAccountManager.get(mContext).addAccountExplicitly(account, PASSWORD, null); // And return it. - bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); - bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); + bundle.putString(PhoneAccountManager.KEY_ACCOUNT_NAME, account.name); + bundle.putString(PhoneAccountManager.KEY_ACCOUNT_TYPE, account.type); return bundle; } @@ -83,9 +83,9 @@ class TestAuthenticator extends AbstractAccountAuthenticator { String authTokenType, Bundle loginOptions) { Log.v(TestauthConstants.LOG_TAG, "getAuthToken() account=" + account); final Bundle bundle = new Bundle(); - bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); - bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); - bundle.putString(AccountManager.KEY_AUTHTOKEN, account.name); + bundle.putString(PhoneAccountManager.KEY_ACCOUNT_NAME, account.name); + bundle.putString(PhoneAccountManager.KEY_ACCOUNT_TYPE, account.type); + bundle.putString(PhoneAccountManager.KEY_AUTHTOKEN, account.name); return bundle; } @@ -118,7 +118,7 @@ class TestAuthenticator extends AbstractAccountAuthenticator { // return false (no) for any queries. Log.v(TestauthConstants.LOG_TAG, "hasFeatures()"); final Bundle result = new Bundle(); - result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false); + result.putBoolean(PhoneAccountManager.KEY_BOOLEAN_RESULT, false); return result; } diff --git a/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java b/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java index a7c0f83c..f0186d98 100644 --- a/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java +++ b/tests/src/com/android/contacts/common/tests/testauth/TestSyncAdapter.java @@ -16,7 +16,7 @@ package com.android.contacts.common.tests.testauth; import android.accounts.Account; -import android.accounts.AccountManager; +import android.accounts.PhoneAccountManager; import android.content.AbstractThreadedSyncAdapter; import android.content.ContentProviderClient; import android.content.ContentResolver; @@ -32,14 +32,14 @@ import android.util.Log; * */ public class TestSyncAdapter extends AbstractThreadedSyncAdapter { - private final AccountManager mAccountManager; + private final PhoneAccountManager mPhoneAccountManager; private final Context mContext; public TestSyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); mContext = context.getApplicationContext(); - mAccountManager = AccountManager.get(mContext); + mPhoneAccountManager = PhoneAccountManager.get(mContext); } /** |