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

Commit 9086fb91 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Unset super primary of writable accounts photos

Bug: 25714956
Change-Id: I2d24f57732b069f08a4913db20702f98b853db12
parent 42d740c2
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