Loading src/com/android/contacts/common/preference/ContactsPreferences.java +2 −4 Original line number Diff line number Diff line Loading @@ -16,13 +16,10 @@ package com.android.contacts.common.preference; import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.preference.PreferenceManager; Loading Loading @@ -219,7 +216,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { return defaultAccount == null || !defaultAccount.isNullAccount(); } if (currentWritableAccounts.size() == 1) { if (currentWritableAccounts.size() == 1 && !currentWritableAccounts.get(0).isNullAccount()) { return false; } Loading src/com/android/contacts/editor/ContactEditorFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -987,6 +987,9 @@ public class ContactEditorFragment extends Fragment implements mStatus = Status.SUB_ACTIVITY; startActivityForResult(intent, REQUEST_CODE_ACCOUNTS_CHANGED); } else { // Make sure the default account is automatically set if there is only one non-device // account. mEditorUtils.maybeUpdateDefaultAccount(); // Otherwise, there should be a default account. Then either create a local contact // (if default account is null) or create a contact with the specified account. AccountWithDataSet defaultAccount = mEditorUtils.getOnlyOrDefaultAccount(); Loading src/com/android/contacts/editor/ContactEditorUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,20 @@ public class ContactEditorUtils { return mContactsPrefs.shouldShowAccountChangedNotification(getWritableAccounts()); } /** * Sets the only non-device account to be default if it is not already. */ public void maybeUpdateDefaultAccount() { final List<AccountWithDataSet> currentWritableAccounts = getWritableAccounts(); if (currentWritableAccounts.size() == 1) { final AccountWithDataSet onlyAccount = currentWritableAccounts.get(0); if (!onlyAccount.isNullAccount() && !onlyAccount.equals(mContactsPrefs.getDefaultAccount())) { mContactsPrefs.setDefaultAccount(onlyAccount); } } } @VisibleForTesting String[] getWritableAccountTypeStrings() { final Set<String> types = Sets.newHashSet(); Loading Loading
src/com/android/contacts/common/preference/ContactsPreferences.java +2 −4 Original line number Diff line number Diff line Loading @@ -16,13 +16,10 @@ package com.android.contacts.common.preference; import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.preference.PreferenceManager; Loading Loading @@ -219,7 +216,8 @@ public class ContactsPreferences implements OnSharedPreferenceChangeListener { return defaultAccount == null || !defaultAccount.isNullAccount(); } if (currentWritableAccounts.size() == 1) { if (currentWritableAccounts.size() == 1 && !currentWritableAccounts.get(0).isNullAccount()) { return false; } Loading
src/com/android/contacts/editor/ContactEditorFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -987,6 +987,9 @@ public class ContactEditorFragment extends Fragment implements mStatus = Status.SUB_ACTIVITY; startActivityForResult(intent, REQUEST_CODE_ACCOUNTS_CHANGED); } else { // Make sure the default account is automatically set if there is only one non-device // account. mEditorUtils.maybeUpdateDefaultAccount(); // Otherwise, there should be a default account. Then either create a local contact // (if default account is null) or create a contact with the specified account. AccountWithDataSet defaultAccount = mEditorUtils.getOnlyOrDefaultAccount(); Loading
src/com/android/contacts/editor/ContactEditorUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,20 @@ public class ContactEditorUtils { return mContactsPrefs.shouldShowAccountChangedNotification(getWritableAccounts()); } /** * Sets the only non-device account to be default if it is not already. */ public void maybeUpdateDefaultAccount() { final List<AccountWithDataSet> currentWritableAccounts = getWritableAccounts(); if (currentWritableAccounts.size() == 1) { final AccountWithDataSet onlyAccount = currentWritableAccounts.get(0); if (!onlyAccount.isNullAccount() && !onlyAccount.equals(mContactsPrefs.getDefaultAccount())) { mContactsPrefs.setDefaultAccount(onlyAccount); } } } @VisibleForTesting String[] getWritableAccountTypeStrings() { final Set<String> types = Sets.newHashSet(); Loading