Merge "Add multiselect to contact picker"
diff --git a/src/com/android/contacts/activities/GroupMembersActivity.java b/src/com/android/contacts/activities/GroupMembersActivity.java
index b25c49a..e6e838b 100644
--- a/src/com/android/contacts/activities/GroupMembersActivity.java
+++ b/src/com/android/contacts/activities/GroupMembersActivity.java
@@ -28,6 +28,7 @@
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.RawContacts;
import android.support.v4.view.GravityCompat;
+import android.support.v7.app.ActionBar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -194,6 +195,10 @@
R.string.enter_contact_name);
mActionBarAdapter.setShowHomeIcon(true);
+ // Avoid showing default "Contacts" title before group metadata is loaded. The title will
+ // be changed to group name when onGroupMetadataLoaded() is called.
+ setActionBarTitle("");
+
// Decide whether to prompt for the account and group name or start loading existing members
if (mIsInsertAction) {
// Check if we are in the middle of the insert flow.
@@ -616,11 +621,18 @@
public void onGroupMetadataLoaded(GroupMetadata groupMetadata) {
mGroupMetadata = groupMetadata;
if (!mIsInsertAction) {
- getSupportActionBar().setTitle(mGroupMetadata.groupName);
+ setActionBarTitle(mGroupMetadata.groupName);
}
invalidateOptionsMenu();
}
+ private void setActionBarTitle(String title) {
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setTitle(title);
+ }
+ }
+
@Override
public void onGroupMetadataLoadFailed() {
setResultCanceledAndFinish(R.string.groupLoadErrorToast);
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 9ac7152..5e882f8 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -16,6 +16,7 @@
package com.android.contacts.activities;
+import android.accounts.Account;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
@@ -29,6 +30,7 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.ProviderStatus;
import android.provider.ContactsContract.QuickContact;
import android.support.v13.app.FragmentPagerAdapter;
@@ -1348,6 +1350,15 @@
Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
Bundle extras = getIntent().getExtras();
if (extras != null) {
+ final ContactListFilter filter = mContactListFilterController.getFilter();
+ // If we are in account view, we pass the account explicitly in order to
+ // create contact in the account. This will prevent the default account dialog
+ // from being displayed.
+ if (!isAllContactsFilter(filter)) {
+ final Account account = new Account(filter.accountName, filter.accountType);
+ extras.putParcelable(Intents.Insert.EXTRA_ACCOUNT, account);
+ extras.putString(Intents.Insert.EXTRA_DATA_SET, filter.dataSet);
+ }
intent.putExtras(extras);
}
try {
diff --git a/src/com/android/contacts/editor/ContactEditorUtils.java b/src/com/android/contacts/editor/ContactEditorUtils.java
index 3aae923..4a06698 100644
--- a/src/com/android/contacts/editor/ContactEditorUtils.java
+++ b/src/com/android/contacts/editor/ContactEditorUtils.java
@@ -203,10 +203,11 @@
}
/**
- * @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 @@
*/
@NeededForTesting
public boolean shouldShowAccountChangedNotification() {
+ final List<AccountWithDataSet> currentWritableAccounts = getWritableAccounts();
+
+ if (currentWritableAccounts.size() == 1) {
+ return false;
+ }
+
if (isFirstLaunch()) {
return true;
}
- final List<AccountWithDataSet> 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 2b6c667..2e0306a 100644
--- a/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java
+++ b/tests/src/com/android/contacts/editor/ContactEditorUtilsTest.java
@@ -175,7 +175,6 @@
* 0 accounts.
*/
public void testShouldShowAccountChangedNotification_0Accounts() {
- // There's always at least one writable type...
setAccountTypes(TYPE1);
// First launch -- always true.
@@ -250,8 +249,8 @@
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 @@
* 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.