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

Commit 147a39dd authored by Seweryn Fornalik's avatar Seweryn Fornalik
Browse files

Create dedicated helper class, hide address book from choose account list

parent 80249c45
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
package com.android.settings.accounts;

class AccountAddressBookHelper {

    /*
     By convention all address book account types has "address_book" postfix
     e.g. "foundation.e.accountmanager.address_book"
     */
    public static final String ADDRESS_BOOK_ACCOUNT_TYPE = "address_book";

    public static boolean isAccountAddressBookType(String account_type) {
        if (account_type != null) {
            return account_type.contains(ADDRESS_BOOK_ACCOUNT_TYPE);
        } else {
            return false;
        }
    }
}
+1 −11
Original line number Diff line number Diff line
@@ -79,12 +79,6 @@ public class AccountPreferenceController extends AbstractPreferenceController
    private static final int ORDER_NEXT_TO_LAST = 1001;
    private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;

    /*
     by convention all address book account types has "address_book" postfix
     e.g. "foundation.e.accountmanager.address_book"
     */
    private static final String ADDRESS_BOOK_ACCOUNT_TYPE = "address_book";

    private UserManager mUm;
    private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
    private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver
@@ -489,12 +483,8 @@ public class AccountPreferenceController extends AbstractPreferenceController
        for (int i = 0; i < accountTypes.length; i++) {
            final String accountType = accountTypes[i];
            // Skip displaying address book accounts
            if (accountType.contains(ADDRESS_BOOK_ACCOUNT_TYPE))
            if (AccountAddressBookHelper.isAccountAddressBookType(accountType))
                continue;
            // Skip showing any account that does not have any of the requested authorities
            if (!accountTypeHasAnyRequestedAuthorities(helper, accountType)) {
                continue;
            }
            final CharSequence label = helper.getLabelForType(mContext, accountType);
            if (label == null) {
                continue;
+4 −2
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class ChooseAccountPreferenceController extends BasePreferenceController

        mProviderList = new ArrayList<>();
        mTypeToAuthDescription = new HashMap<>();

    }

    public void initialize(String[] authorities, String[] accountTypesFilter, UserHandle userHandle,
@@ -150,8 +151,9 @@ public class ChooseAccountPreferenceController extends BasePreferenceController
                    }
                }
            }
            if (addAccountPref && mAccountTypesFilter != null
                    && !mAccountTypesFilter.contains(accountType)) {
            if (addAccountPref && ((mAccountTypesFilter != null
                    && !mAccountTypesFilter.contains(accountType))
            || AccountAddressBookHelper.isAccountAddressBookType(accountType))) {
                addAccountPref = false;
            }
            if (addAccountPref) {