From 37ad9fbba748664acfeaf058a36c221600aa62d5 Mon Sep 17 00:00:00 2001 From: Tingting Wang Date: Tue, 21 Jun 2016 14:08:53 -0700 Subject: Always hide default account picker when one writable account. BUG 25467864 Change-Id: I81fa329831a6cb3d7252702b8a68bb19ead22b85 --- src/com/android/contacts/editor/ContactEditorUtils.java | 17 +++++++++++------ .../android/contacts/editor/ContactEditorUtilsTest.java | 6 ++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/com/android/contacts/editor/ContactEditorUtils.java b/src/com/android/contacts/editor/ContactEditorUtils.java index 3aae92380..4a06698c2 100644 --- a/src/com/android/contacts/editor/ContactEditorUtils.java +++ b/src/com/android/contacts/editor/ContactEditorUtils.java @@ -203,10 +203,11 @@ public class ContactEditorUtils { } /** - * @return true if the contact editor should show the "accounts changed" notification, that is: - * - If it's the first launch. - * - Or, if the default account has been removed. - * (And some extra sanity check) + * @return false if there is only one writable account or no requirement to return true is met. + * true if the contact editor should show the "accounts changed" notification, that is: + * - If it's the first launch. + * - Or, if the default account has been removed. + * (And some extra sanity check) * * Note if this method returns {@code false}, the caller can safely assume that * {@link #getDefaultAccount} will return a valid account. (Either an account which still @@ -214,12 +215,16 @@ public class ContactEditorUtils { */ @NeededForTesting public boolean shouldShowAccountChangedNotification() { + final List currentWritableAccounts = getWritableAccounts(); + + if (currentWritableAccounts.size() == 1) { + return false; + } + if (isFirstLaunch()) { return true; } - final List currentWritableAccounts = getWritableAccounts(); - final AccountWithDataSet defaultAccount = getDefaultAccount(); // Does default account still exist? diff --git a/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java b/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java index 2b6c667f6..2e0306aff 100644 --- a/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java +++ b/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java @@ -175,7 +175,6 @@ public class ContactEditorUtilsTest extends AndroidTestCase { * 0 accounts. */ public void testShouldShowAccountChangedNotification_0Accounts() { - // There's always at least one writable type... setAccountTypes(TYPE1); // First launch -- always true. @@ -250,8 +249,8 @@ public class ContactEditorUtilsTest extends AndroidTestCase { setAccountTypes(TYPE1, TYPE2); setAccounts(ACCOUNT_1_A); - // First launch -- always true. - assertTrue(mTarget.shouldShowAccountChangedNotification()); + // Always returns false when 1 writable account. + assertFalse(mTarget.shouldShowAccountChangedNotification()); // User saves a new contact. mTarget.saveDefaultAndAllAccounts(ACCOUNT_1_A); @@ -267,7 +266,6 @@ public class ContactEditorUtilsTest extends AndroidTestCase { * 0 accounts, and the user selected "local only". */ public void testShouldShowAccountChangedNotification_0Account_localOnly() { - // There's always at least one writable type... setAccountTypes(TYPE1); // First launch -- always true. -- cgit v1.2.3