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

Commit 45b86d5e authored by Walter Jang's avatar Walter Jang
Browse files

Put back setting of photo from template

* Mistakenly remove it in ag/790426
* Also looks like we weren't setting from template it to true
  after removing the photo.
* Finally, don't set super primary on the local profile

Bug 24981999
Bug 19697372
Bug 23589603

Change-Id: I3e759d5ea75e10c62108728874b771446ac61631
parent e5e7aefb
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.contacts.editor;
import com.android.contacts.ContactSaveService;
import com.android.contacts.R;
import com.android.contacts.activities.CompactContactEditorActivity;
import com.android.contacts.activities.ContactEditorActivity;
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;
@@ -202,10 +200,8 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        if (activity == null || activity.isFinishing()) {
            return;
        }
        if (!mIsUserProfile) {
        acquireAggregationSuggestions(activity, rawContactId, valuesDelta);
    }
    }

    @Override
    public void onRebindEditorsForNewContact(RawContactDelta oldState,
+17 −10
Original line number Diff line number Diff line
@@ -16,6 +16,13 @@

package com.android.contacts.editor;

import com.android.contacts.R;
import com.android.contacts.common.model.RawContactDelta;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.dataitem.DataKind;

import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract.CommonDataKinds.Event;
@@ -30,14 +37,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.contacts.R;
import com.android.contacts.common.model.RawContactDelta;
import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.dataitem.DataKind;

import java.util.ArrayList;
import java.util.List;

@@ -152,6 +151,7 @@ public class CompactKindSectionView extends LinearLayout {
    private ViewIdGenerator mViewIdGenerator;
    private CompactRawContactsEditorView.Listener mListener;

    private boolean mIsUserProfile;
    private boolean mShowOneEmptyEditor = false;
    private boolean mHideIfEmpty = true;

@@ -190,6 +190,10 @@ public class CompactKindSectionView extends LinearLayout {
        mIcon = (ImageView) findViewById(R.id.kind_icon);
    }

    public void setIsUserProfile(boolean isUserProfile) {
        mIsUserProfile = isUserProfile;
    }

    /**
     * @param showOneEmptyEditor If true, we will always show one empty editor, otherwise an empty
     *         editor will not be shown until the user enters a value.  Note, this does not apply
@@ -364,8 +368,11 @@ public class CompactKindSectionView extends LinearLayout {
        // Structured name
        final StructuredNameEditorView nameView = (StructuredNameEditorView) mLayoutInflater
                .inflate(R.layout.structured_name_editor_view, mEditors, /* attachToRoot =*/ false);
        nameView.setEditorListener(new StructuredNameEditorListener(valuesDelta,
                rawContactDelta.getRawContactId(), mListener));
        if (!mIsUserProfile) {
            // Don't set super primary for the me contact
            nameView.setEditorListener(new StructuredNameEditorListener(
                    valuesDelta, rawContactDelta.getRawContactId(), mListener));
        }
        nameView.setDeletable(false);
        nameView.setValues(
                accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME),
+17 −9
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    }

    public void removePhoto() {
        mPhotoValuesDelta.setFromTemplate(false);
        mPhotoValuesDelta.setFromTemplate(true);
        mPhotoValuesDelta.put(Photo.PHOTO, (byte[]) null);

        mPhotoView.removePhoto();
@@ -517,11 +517,15 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    }

    public void updatePhoto(Uri photoUri) {
        mPhotoValuesDelta.setFromTemplate(false);

        if (!mIsUserProfile) {
            // Unset primary for all photos
            unsetSuperPrimary();

            // Mark the currently displayed photo as primary
            mPhotoValuesDelta.setSuperPrimary(true);
        }

        mPhotoView.setFullSizedPhoto(photoUri);
    }
@@ -603,9 +607,6 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
     * UI.
     */
    public void setPrimaryPhoto(CompactPhotoSelectionFragment.Photo photo) {
        // Unset primary for all photos
        unsetSuperPrimary();

        // Find the values delta to mark as primary
        final KindSectionDataList kindSectionDataList =
                mKindSectionDataMap.get(Photo.CONTENT_ITEM_TYPE);
@@ -623,7 +624,13 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        }
        final ValuesDelta valuesDelta = valuesDeltaList.get(photo.valuesDeltaListIndex);
        valuesDelta.setFromTemplate(false);

        if (!mIsUserProfile) {
            // Unset primary for all other photos
            unsetSuperPrimary();

            valuesDelta.setSuperPrimary(true);
        }

        // Update the UI
        mPhotoView.setPhoto(valuesDelta, mMaterialPalette);
@@ -1029,6 +1036,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        final CompactKindSectionView kindSectionView = (CompactKindSectionView)
                mLayoutInflater.inflate(R.layout.compact_item_kind_section, viewGroup,
                        /* attachToRoot =*/ false);
        kindSectionView.setIsUserProfile(mIsUserProfile);

        if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)
                || Email.CONTENT_ITEM_TYPE.equals(mimeType)) {