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

Commit d8a0543b authored by Walter Jang's avatar Walter Jang Committed by Android (Google) Code Review
Browse files

Merge "Use selected photo ID as the "photo to display" lookup parameter" into...

Merge "Use selected photo ID as the "photo to display" lookup parameter" into ub-contactsdialer-a-dev
parents 0333b843 da258ff1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -215,6 +215,9 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl

    public void setPrimaryPhoto(CompactPhotoSelectionFragment.Photo photo) {
        getContent().setPrimaryPhoto(photo);

        // Update the photo ID we will try to match when selecting the photo to display
        mPhotoId = photo.photoId;
    }

    @Override
+8 −10
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ public class CompactPhotoSelectionFragment extends Fragment {
         */
        public boolean primary;

        public long rawContactId;

        /**
         * Pointer back to the KindSectionDataList this photo came from.
         * See {@link CompactRawContactsEditorView#getPhotos}
@@ -121,6 +119,8 @@ public class CompactPhotoSelectionFragment extends Fragment {
        /** Newly taken or selected photo that has not yet been saved to CP2. */
        public Uri updatedPhotoUri;

        public long photoId;

        @Override
        public int describeContents() {
            return 0;
@@ -136,6 +136,7 @@ public class CompactPhotoSelectionFragment extends Fragment {
            dest.writeInt(kindSectionDataListIndex);
            dest.writeInt(valuesDeltaListIndex);
            dest.writeParcelable(updatedPhotoUri, flags);
            dest.writeLong(photoId);
        }

        private void readFromParcel(Parcel source) {
@@ -148,6 +149,7 @@ public class CompactPhotoSelectionFragment extends Fragment {
            kindSectionDataListIndex = source.readInt();
            valuesDeltaListIndex = source.readInt();
            updatedPhotoUri = source.readParcelable(classLoader);
            photoId = source.readLong();
        }
    }

@@ -197,19 +199,15 @@ public class CompactPhotoSelectionFragment extends Fragment {
                if (convertView == null || convertView.findViewById(R.id.account_type) != null) {
                    return mLayoutInflater.inflate(R.layout.take_a_photo_button, /* root =*/ null);
                }
                else{
                return convertView;
            }
            }

            if (getItemViewType(position) == 1) {
                if (convertView == null || convertView.findViewById(R.id.account_type) != null) {
                    return mLayoutInflater.inflate(R.layout.all_photos_button, /* root =*/ null);
                }
                else {
                return convertView;
            }
            }

            // when position greater than 1, we should make sure account_type *is* in convertView
            // before reusing it.
@@ -298,8 +296,8 @@ public class CompactPhotoSelectionFragment extends Fragment {
        mGridView.setAdapter(photoAdapter);
        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final PhotoSourceDialogFragment.Listener listener = (PhotoSourceDialogFragment.Listener)
                        getActivity();
                final PhotoSourceDialogFragment.Listener listener =
                        (PhotoSourceDialogFragment.Listener) getActivity();
                if (position == 0){
                    listener.onTakePhotoChosen();
                } else if (position == 1) {
+8 −6
Original line number Diff line number Diff line
@@ -549,6 +549,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
                photo.valuesDeltaListIndex = j;
                photo.accountType = accountType.getDisplayLabel(getContext()).toString();
                photo.accountName = kindSectionData.getRawContactDelta().getAccountName();
                photo.photoId = valuesDelta.getId();

                if (updatedPhotos != null) {
                    photo.updatedPhotoUri = (Uri) updatedPhotos.get(String.valueOf(
@@ -582,12 +583,13 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
            wlog("Invalid values delta list index");
            return;
        }

        // Update values delta
        final ValuesDelta valuesDelta = valuesDeltaList.get(photo.valuesDeltaListIndex);
        valuesDelta.setFromTemplate(false);
        // Unset primary for all photos
        unsetSuperPrimaryFromAllPhotos();
        // Mark the currently displayed photo as primary
        valuesDelta.setSuperPrimary(true);

        // Update the UI
        mPhotoView.setPhoto(valuesDelta, mMaterialPalette);
    }
@@ -944,15 +946,15 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        mPhotoView.setPhoto(photoToDisplay.second, mMaterialPalette);

        // Find the raw contact ID and values delta that will be written when the photo is edited
        final Pair<KindSectionData, ValuesDelta> pair = kindSectionDataList.getEntryToWrite(
        final Pair<KindSectionData, ValuesDelta> photoToWrite = kindSectionDataList.getEntryToWrite(
                mPhotoId, mPrimaryAccount, mIsUserProfile);
        if (pair == null) {
        if (photoToWrite == null) {
            mPhotoView.setReadOnly(true);
            return;
        }
        mPhotoView.setReadOnly(false);
        mPhotoRawContactId = pair.first.getRawContactDelta().getRawContactId();
        mPhotoValuesDelta = pair.second;
        mPhotoRawContactId = photoToWrite.first.getRawContactDelta().getRawContactId();
        mPhotoValuesDelta = photoToWrite.second;
    }

    private void addKindSectionViews() {
+4 −1
Original line number Diff line number Diff line
@@ -1398,7 +1398,10 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                        mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR),
                        mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR));
            }
            // If the user selected a different photo, don't restore the one from the Intent
            if (mPhotoId < 0) {
                mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID);
            }
            mRawContactIdToDisplayAlone = mIntentExtras.getLong(
                    INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, -1);
            mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean(