Override primary to set check mark in photo picker
Doc at go/checkmarkinphotopicker
Bug 25092609
Change-Id: Ieca46eb4f15f125b227b138fef5b24cc3f6ce666
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index ecc8f2b..e441264 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -19,7 +19,6 @@
import com.android.contacts.ContactSaveService;
import com.android.contacts.R;
import com.android.contacts.activities.CompactContactEditorActivity;
-import com.android.contacts.activities.ContactEditorBaseActivity;
import com.android.contacts.common.model.RawContactDelta;
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountWithDataSet;
@@ -237,6 +236,7 @@
if (isEditingMultipleRawContacts()) {
final ArrayList<CompactPhotoSelectionFragment.Photo> photos = getContent().getPhotos();
if (photos.size() > 1) {
+ updatePrimaryForSelection(photos);
// For aggregate contacts, the user may select a new super primary photo from among
// the (non-default) raw contact photos, or source a new photo.
getEditorActivity().selectPhoto(photos, getPhotoMode());
@@ -248,6 +248,22 @@
getEditorActivity().changePhoto(getPhotoMode());
}
+ // This method override photo's primary flag based on photoId and set the photo currently
+ // shown in the editor to be the new primary no matter how many primary photos there are in
+ // the photo picker. This is because the photos returned by "getPhoto" may contain 0, 1,
+ // or 2+ primary photos and when we link contacts in the editor, the photos returned may change.
+ // We need to put check mark on the photo currently shown in editor, so we override "primary".
+ // This doesn't modify anything in the database,so there would be no pending changes.
+ private void updatePrimaryForSelection(ArrayList<CompactPhotoSelectionFragment.Photo> photos) {
+ for (CompactPhotoSelectionFragment.Photo photo : photos) {
+ if (photo.photoId == mPhotoId) {
+ photo.primary = true;
+ } else {
+ photo.primary = false;
+ }
+ }
+ }
+
@Override
public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly) {
final Activity activity = getActivity();