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

Commit 4ceabed6 authored by Gary Mai's avatar Gary Mai
Browse files

Remove all List forms of KindSectionData

Pick and render one raw contact delta at a time in editor.
Have the account selector always visible.
  - When viewing a read only contact, header will say "Viewing"
  - Otherwise it says "Saving to"
Swap between raw contact deltas when an account is selected in the
drop down
Keep menu options available even when viewing just one raw contact.
Remove some code related to photo picker.

Test:
Tested the following editor scenarios:
  1) new contact
  2) edit other contact
  3) edit writable raw contact
  4) edit read-only raw contact (joins a new writable raw contact to it)
  5) edit aggregate w/ 1 writable and 1 read-only raw contact
  6) edit aggregate w/ 2 writable raw contacts
  7) edit local me raw contact
  8) edit local me raw contact joined with a read-only raw contact
  9) editing photo of a raw contact that is part of an aggregate
     updates the aggregate photo
  10) same with editing the name

Change-Id: Id797619e656d3a9974cc9454a3d26fee471569d5
parent 0ad2905b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -799,6 +799,9 @@
    <!-- Label for the account selector to indicate which account a contact will be saved to. [CHAR LIMIT=30] -->
    <string name="compact_editor_account_selector_title">Saving to</string>

    <!-- Label for the account selector to indicate which read-only account is being viewed. [CHAR LIMIT=30] -->
    <string name="compact_editor_account_selector_read_only_title">Viewing</string>

    <!-- Content description for the account selector to indicate which account a contact will be saved to. [CHAR LIMIT=NONE] -->
    <string name="compact_editor_account_selector_description">Currently saving to <xliff:g id="account_name">%s</xliff:g>. Double-tap to pick a different account.</string>

+6 −4
Original line number Diff line number Diff line
@@ -30,11 +30,9 @@ import android.provider.ContactsContract.RawContacts;
import android.util.Log;

import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.BuilderWrapper;
import com.android.contacts.common.model.CPOWrapper;
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

@@ -236,6 +234,10 @@ public class RawContactDelta implements Parcelable {
        return manager.getAccountType(getAccountType(), getDataSet());
    }

    public AccountWithDataSet getAccountWithDataSet() {
        return new AccountWithDataSet(getAccountName(), getAccountType(), getDataSet());
    }

    public boolean isVisible() {
        return getValues().isVisible();
    }
+7 −35
Original line number Diff line number Diff line
@@ -788,7 +788,7 @@ public class CompactContactEditorFragment extends Fragment implements
        // Set visibility of menus

        // help menu depending on whether this is inserting or editing
        if (Intent.ACTION_INSERT.equals(mAction) || mRawContactIdToDisplayAlone != -1) {
        if (Intent.ACTION_INSERT.equals(mAction)) {
            HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
            splitMenu.setVisible(false);
            joinMenu.setVisible(false);
@@ -816,7 +816,7 @@ public class CompactContactEditorFragment extends Fragment implements
            });
        }

        if (mRawContactIdToDisplayAlone != -1 || mIsUserProfile) {
        if (mIsUserProfile) {
            sendToVoiceMailMenu.setVisible(false);
            ringToneMenu.setVisible(false);
        } else {
@@ -1164,22 +1164,7 @@ public class CompactContactEditorFragment extends Fragment implements
            return;
        }

        // Prune raw contacts besides the one we want to edit
        if (mRawContactIdToDisplayAlone > 0) {
            final ImmutableList.Builder<RawContact> rawContactsBuilder =
                    new ImmutableList.Builder<>();
            for (RawContact rawContact : contact.getRawContacts()) {
                if (rawContact.getId() == mRawContactIdToDisplayAlone) {
                    rawContactsBuilder.add(rawContact);
                    break;
                }
            }
            mRawContacts = rawContactsBuilder.build();
            Log.v(TAG, "Raw contact deltas trimmed from " + contact.getRawContacts().size() +
                    " to " + mRawContacts.size());
        } else {
        mRawContacts = contact.getRawContacts();
        }

        // See if this edit operation needs to be redirected to a custom editor
        if (mRawContacts.size() == 1) {
@@ -1866,16 +1851,6 @@ public class CompactContactEditorFragment extends Fragment implements

    @Override
    public void onPhotoEditorViewClicked() {
        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());
                return;
            }
        }
        // For contacts composed of a single writable raw contact, or raw contacts have no more
        // than 1 photo, clicking the photo view simply opens the source photo dialog
        getEditorActivity().changePhoto(getPhotoMode());
@@ -1917,13 +1892,10 @@ public class CompactContactEditorFragment extends Fragment implements
    }

    @Override
    public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly) {
        final Activity activity = getActivity();
        if (activity != null && !activity.isFinishing()) {
            final Intent intent = EditorIntents.createEditContactIntentForRawContact(
                    activity, uri, rawContactId, isReadOnly);
            activity.startActivity(intent);
        }
    public void onRawContactSelected(long rawContactId, boolean isReadOnly) {
        mRawContactDisplayAloneIsReadOnly = isReadOnly;
        mRawContactIdToDisplayAlone = rawContactId;
        bindEditors();
    }

    @Override
+3 −0
Original line number Diff line number Diff line
@@ -114,7 +114,10 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli
        if (mReadOnly) {
            mPhotoIcon.setVisibility(View.GONE);
            mPhotoIconOverlay.setVisibility(View.GONE);
            mPhotoTouchInterceptOverlay.setClickable(false);
        } else {
            mPhotoIcon.setVisibility(View.VISIBLE);
            mPhotoIconOverlay.setVisibility(View.VISIBLE);
            mPhotoTouchInterceptOverlay.setOnClickListener(this);
        }
    }
+139 −284

File changed.

Preview size limit exceeded, changes collapsed.