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

Commit 614d8120 authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Don't show removed default account in settings

Test: manually verify that default account is cleared when account
is removed.

Bug 30742139

Change-Id: I0f7130d8ed73762ff7cd176636e0949064b16be6
parent d9c6188c
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;

import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.account.AccountInfo;
import com.android.contacts.model.account.AccountWithDataSet;
import com.android.contacts.util.AccountsListAdapter;
@@ -33,7 +32,6 @@ import java.util.List;
public class DefaultAccountPreference extends DialogPreference {
    private ContactsPreferences mPreferences;
    private AccountsListAdapter mListAdapter;
    private AccountTypeManager mAccountTypeManager;
    private List<AccountInfo> mAccounts;
    private int mChosenIndex = -1;

@@ -51,6 +49,7 @@ public class DefaultAccountPreference extends DialogPreference {
        mAccounts = accounts;
        if (mListAdapter != null) {
            mListAdapter.setAccounts(accounts, null);
            notifyChanged();
        }
    }

@@ -66,7 +65,6 @@ public class DefaultAccountPreference extends DialogPreference {
        if (mAccounts != null) {
            mListAdapter.setAccounts(mAccounts, null);
        }
        mAccountTypeManager = AccountTypeManager.getInstance(getContext());
    }

    @Override
@@ -77,11 +75,11 @@ public class DefaultAccountPreference extends DialogPreference {
    @Override
    public CharSequence getSummary() {
        final AccountWithDataSet defaultAccount = mPreferences.getDefaultAccount();
        if (defaultAccount == null ||
                !mAccountTypeManager.exists(defaultAccount)) {
        if (defaultAccount == null || mAccounts == null ||
                !AccountInfo.contains(mAccounts, defaultAccount)) {
            return null;
        } else {
            return mAccountTypeManager.getAccountInfoForAccount(defaultAccount).getNameLabel();
            return AccountInfo.getAccount(mAccounts, defaultAccount).getNameLabel();
        }
    }

+3 −8
Original line number Diff line number Diff line
@@ -294,15 +294,10 @@ public class DisplayOptionsPreferenceFragment extends PreferenceFragment
    @Override
    public void onAccountsLoaded(List<AccountInfo> accounts) {
        // Hide accounts preferences if no writable accounts exist
        if (accounts.isEmpty()) {
            getPreferenceScreen().removePreference(findPreference(KEY_DEFAULT_ACCOUNT));
            getPreferenceScreen().removePreference(findPreference(KEY_CUSTOM_CONTACTS_FILTER));
        } else {
        final DefaultAccountPreference preference =
                (DefaultAccountPreference) findPreference(KEY_DEFAULT_ACCOUNT);
        preference.setAccounts(accounts);
    }
    }

    @Override
    public Context getContext() {