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

Commit f21b3ee1 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Hide read-only accounts from side nav

* Load writable accounts only so we don't need to remove read-only accounts.
* We don't need to add local account in side nav for now, because:
  - we only show writable accounts in side nav
  - and we add local account only when there's no writable account
  - and we don't show any account in side nav when the number of accounts
    to display in side nav is smaller than 2.
* Revert the lines to filter accounts (line 139-141) to the status before
  ag/1198595.
* With this CL, Skype account will not show up in side nav because it's
  read-only; however, the label that belongs to Skype still shows up in
  the label section of side nav (see b/29046877).

Bug 30707025

Change-Id: I3337894880db2ad787ab42fe7a10b29371ed5f16
parent d3aef2d4
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -123,22 +123,13 @@ public class AccountFilterUtil {
        final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context);
        accountTypeManager.sortAccounts(/* defaultAccount */ getDefaultAccount(context));
        final List<AccountWithDataSet> accounts =
                accountTypeManager.getAccounts(/* contactWritableOnly */ false);
        final List<AccountWithDataSet> writableAccounts =
                accountTypeManager.getAccounts(/* contactWritableOnly */ true);
        final AccountWithDataSet localAccount = AccountWithDataSet.getLocalAccount();
        if ((writableAccounts == null || writableAccounts.size() == 0)
                && !accounts.contains(localAccount)) {
            // Add "local account" if there is no writable account.
            accounts.add(localAccount);
        }

        for (AccountWithDataSet account : accounts) {
            final AccountType accountType =
                    accountTypeManager.getAccountType(account.type, account.dataSet);
            if ((accountType.isExtension() || !accountType.areContactsWritable())
                    && !account.hasData(context)) {
                // Hide extensions and read-only accounts with no raw_contacts.
            if (accountType.isExtension() && !account.hasData(context)) {
                // Hide extensions with no raw_contacts.
                continue;
            }
            final Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null;