diff options
Diffstat (limited to 'src')
6 files changed, 26 insertions, 15 deletions
diff --git a/src/com/android/contacts/drawer/DrawerAdapter.java b/src/com/android/contacts/drawer/DrawerAdapter.java index a2ab9f739..f6898b54f 100644 --- a/src/com/android/contacts/drawer/DrawerAdapter.java +++ b/src/com/android/contacts/drawer/DrawerAdapter.java @@ -357,7 +357,8 @@ public class DrawerAdapter extends BaseAdapter { final AccountDisplayInfo displayableAccount = mAccountDisplayFactory.getAccountDisplayInfoFor(item.account); final TextView textView = ((TextView) result.findViewById(R.id.title)); - textView.setText(displayableAccount.getNameLabel()); + textView.setText(mActivity.getPackageName().equals(account.accountType) ? + mActivity.getString(R.string.account_phone) : displayableAccount.getNameLabel()); final boolean activated = account.equals(mSelectedAccount) && mSelectedView == ContactsView.ACCOUNT_VIEW; textView.setTextAppearance(mActivity, activated diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java index 8e013581d..1adacf83a 100644 --- a/src/com/android/contacts/model/AccountTypeManager.java +++ b/src/com/android/contacts/model/AccountTypeManager.java @@ -80,6 +80,7 @@ public abstract class AccountTypeManager { public static final String BROADCAST_ACCOUNTS_CHANGED = AccountTypeManager.class.getName() + ".AccountsChanged"; + public static final String DEVICE_ACCOUNT_NAME = "DEVICE"; public enum AccountFilter implements Predicate<AccountInfo> { ALL { @@ -398,7 +399,7 @@ class AccountTypeManagerImpl extends AccountTypeManager */ public AccountTypeManagerImpl(Context context) { mContext = context; - mLocalAccountLocator = new DeviceLocalAccountLocator(context, AccountManager.get(context)); + mLocalAccountLocator = new DeviceLocalAccountLocator(context); mTypeProvider = new AccountTypeProvider(context); mFallbackAccountType = new FallbackAccountType(context); @@ -629,16 +630,24 @@ class AccountTypeManagerImpl extends AccountTypeManager private List<AccountWithDataSet> getAccountsWithDataSets(Account[] accounts, AccountTypeProvider typeProvider) { List<AccountWithDataSet> result = new ArrayList<>(); + // add local device account + populateAccountsDataSet(typeProvider, new Account(DEVICE_ACCOUNT_NAME, + mContext.getPackageName()), result); for (Account account : accounts) { - final List<AccountType> types = typeProvider.getAccountTypes(account.type); - for (AccountType type : types) { - result.add(new AccountWithDataSet( - account.name, account.type, type.dataSet)); - } + populateAccountsDataSet(typeProvider, account, result); } return result; } + private void populateAccountsDataSet(AccountTypeProvider typeProvider, Account account, + List<AccountWithDataSet> result) { + final List<AccountType> types = typeProvider.getAccountTypes(account.type); + for (AccountType type : types) { + result.add(new AccountWithDataSet( + account.name, account.type, type.dataSet)); + } + } + /** * Returns the default google account specified in preferences, the first google account * if it is not specified in preferences or is no longer on the device, and null otherwise. diff --git a/src/com/android/contacts/model/DeviceLocalAccountLocator.java b/src/com/android/contacts/model/DeviceLocalAccountLocator.java index e8a2ba0ff..89f1ce2db 100644 --- a/src/com/android/contacts/model/DeviceLocalAccountLocator.java +++ b/src/com/android/contacts/model/DeviceLocalAccountLocator.java @@ -21,7 +21,6 @@ import android.content.Context; import android.provider.ContactsContract; import com.android.contacts.model.account.AccountWithDataSet; -import com.android.contacts.model.account.GoogleAccountType; import java.util.Collections; import java.util.List; @@ -32,12 +31,10 @@ import java.util.List; public final class DeviceLocalAccountLocator { private final Context mContext; - private final AccountManager mAccountManager; private final List<AccountWithDataSet> mLocalAccount; - public DeviceLocalAccountLocator(Context context, AccountManager accountManager) { + public DeviceLocalAccountLocator(Context context) { mContext = context; - mAccountManager = accountManager; mLocalAccount = Collections.singletonList(AccountWithDataSet.getLocalAccount(context)); } @@ -45,10 +42,7 @@ public final class DeviceLocalAccountLocator { * Returns a list of device local accounts */ public List<AccountWithDataSet> getDeviceLocalAccounts() { - @SuppressWarnings("MissingPermission") final Account[] accounts = mAccountManager - .getAccountsByType(GoogleAccountType.ACCOUNT_TYPE); - - if (accounts.length > 0 && !mLocalAccount.get(0).hasData(mContext)) { + if (!mLocalAccount.get(0).hasData(mContext)) { return Collections.emptyList(); } else { return mLocalAccount; diff --git a/src/com/android/contacts/model/account/AccountTypeProvider.java b/src/com/android/contacts/model/account/AccountTypeProvider.java index 2888dfa38..95b998cb6 100644 --- a/src/com/android/contacts/model/account/AccountTypeProvider.java +++ b/src/com/android/contacts/model/account/AccountTypeProvider.java @@ -82,6 +82,9 @@ public class AccountTypeProvider { * </p> */ public List<AccountType> getAccountTypes(String accountType) { + if (mContext.getPackageName().equals(accountType)) { + accountType = null; + } // ConcurrentHashMap doesn't support null keys if (accountType == null || mLocalAccountTypeFactory.classifyAccount(accountType) == DeviceLocalAccountTypeFactory.TYPE_SIM) { diff --git a/src/com/android/contacts/util/AccountSelectionUtil.java b/src/com/android/contacts/util/AccountSelectionUtil.java index bfe8a08b3..2b226d0a1 100644 --- a/src/com/android/contacts/util/AccountSelectionUtil.java +++ b/src/com/android/contacts/util/AccountSelectionUtil.java @@ -126,6 +126,8 @@ public class AccountSelectionUtil { text1.setText(accountType.getDisplayLabel(context)); text2.setText(account.name); + text2.setVisibility(context.getPackageName().equals(account.type) ? + View.GONE : View.VISIBLE); icon.setImageDrawable(accountType.getDisplayIcon(getContext())); return convertView; diff --git a/src/com/android/contacts/util/AccountsListAdapter.java b/src/com/android/contacts/util/AccountsListAdapter.java index 2bcc68b84..cc80b7985 100644 --- a/src/com/android/contacts/util/AccountsListAdapter.java +++ b/src/com/android/contacts/util/AccountsListAdapter.java @@ -95,6 +95,8 @@ public final class AccountsListAdapter extends BaseAdapter { text1.setText(mAccounts.get(position).getTypeLabel()); text2.setText(mAccounts.get(position).getNameLabel()); + text2.setVisibility(mAccounts.get(position).getNameLabel().equals( + mAccounts.get(position).getTypeLabel()) ? View.GONE : View.VISIBLE); icon.setImageDrawable(mAccounts.get(position).getIcon()); |
