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

Commit 3184fc86 authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Unset super primary of writable accounts photos" into ub-contactsdialer-a-dev

parents b3182c2d 9086fb91
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    public void updatePhoto(Uri photoUri) {
        mPhotoValuesDelta.setFromTemplate(false);
        // Unset primary for all photos
        unsetSuperPrimaryFromAllWritablePhotos();
        unsetSuperPrimaryFromAllPhotos();
        // Mark the currently displayed photo as primary
        mPhotoValuesDelta.setSuperPrimary(true);

@@ -487,17 +487,15 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        mPhotoView.setFullSizedPhoto(photoUri);
    }

    private void unsetSuperPrimaryFromAllWritablePhotos() {
    private void unsetSuperPrimaryFromAllPhotos() {
        final List<KindSectionData> kindSectionDataList =
                mKindSectionDataMap.get(Photo.CONTENT_ITEM_TYPE);
        for (KindSectionData kindSectionData : kindSectionDataList) {
            if (kindSectionData.getAccountType().areContactsWritable()) {
            for (ValuesDelta valuesDelta : kindSectionData.getNonEmptyValuesDeltas()) {
                valuesDelta.setSuperPrimary(false);
            }
        }
    }
    }

    /**
     * Pass through to {@link CompactPhotoEditorView#isWritablePhotoSet}.
@@ -587,7 +585,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        final ValuesDelta valuesDelta = valuesDeltaList.get(photo.valuesDeltaListIndex);
        valuesDelta.setFromTemplate(false);
        // Unset primary for all photos
        unsetSuperPrimaryFromAllWritablePhotos();
        unsetSuperPrimaryFromAllPhotos();
        // Mark the currently displayed photo as primary
        valuesDelta.setSuperPrimary(true);
        // Update the UI