Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2cb5e075 authored by Toha's avatar Toha Committed by Joey
Browse files

Contacts: Enable support for device contact.



Change-Id: I8f2e907deadced5316be5a418dab2538476a4033
Signed-off-by: default avatarToha <tohenk@yahoo.com>
parent d1b965cc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -276,7 +276,8 @@ public class DrawerAdapter extends BaseAdapter {
        }
        final ContactListFilter account = item.account;
        final TextView textView = ((TextView) result.findViewById(R.id.title));
        textView.setText(account.accountName);
        textView.setText(mActivity.getPackageName().equals(account.accountType) ?
                mActivity.getString(R.string.account_phone) : account.accountName);
        final boolean activated = account.equals(mSelectedAccount)
                && mSelectedView == ContactsView.ACCOUNT_VIEW;
        textView.setTextAppearance(mActivity, activated
+14 −5
Original line number Diff line number Diff line
@@ -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 {
@@ -590,15 +591,23 @@ 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) {
            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));
        }
    }
        return result;
    }

    /**
     * Returns the default google account specified in preferences, the first google account
+3 −0
Original line number Diff line number Diff line
@@ -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) {
            AccountType type = mLocalAccountTypeFactory.getAccountType(accountType);
+2 −0
Original line number Diff line number Diff line
@@ -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;
+2 −0
Original line number Diff line number Diff line
@@ -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());