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

Commit c59de249 authored by Walter Jang's avatar Walter Jang
Browse files

Don't set super primary name on compact editor unless it changes

Also fix the contact being loaded unnecessarily when transitioning
to the full editor.

Bug 21464081

Change-Id: Ic833f64a073898c8524892428512ce65f2f14625
parent 7897ac0d
Loading
Loading
Loading
Loading
+2 −5
Original line number Original line Diff line number Diff line
@@ -345,12 +345,9 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        if (isInsert) {
        if (isInsert) {
            // For inserts, prevent any changes from being saved when the base fragment is destroyed
            // For inserts, prevent any changes from being saved when the base fragment is destroyed
            mStatus = Status.CLOSING;
            mStatus = Status.CLOSING;
        } else {
        } else if (hasPendingChanges()) {
            // Prevent a Toast from being displayed as we transition to the full editor
            mShowToastAfterSave = false;

            // Save whatever is in the form
            // Save whatever is in the form
            save(SaveMode.RELOAD, /* backPressed =*/ false);
            save(SaveMode.CLOSE, /* backPressed =*/ false);
        }
        }


        // Prepare an Intent to start the expanded editor
        // Prepare an Intent to start the expanded editor
+0 −7
Original line number Original line Diff line number Diff line
@@ -174,13 +174,6 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    @Override
    @Override
    public void onClick(View view) {
    public void onClick(View view) {
        if (view.getId() == R.id.more_fields && mListener != null ) {
        if (view.getId() == R.id.more_fields && mListener != null ) {
            // We mark the name that was displayed as super primary before expanding
            // so that a save on the expanded editor (without a name change) does not
            // cause the displayed name to change.
            if (mNameValuesDelta != null) {
                mNameValuesDelta.setSuperPrimary(true);
            }

            mListener.onExpandEditor();
            mListener.onExpandEditor();
        }
        }
    }
    }
+1 −5
Original line number Original line Diff line number Diff line
@@ -373,10 +373,6 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
    // Used to pre-populate the editor with a display name when a user edits a read-only contact.
    // Used to pre-populate the editor with a display name when a user edits a read-only contact.
    protected String mDefaultDisplayName;
    protected String mDefaultDisplayName;


    // Whether to show a Toast message after saves have completed.
    // Does not affect successful toasts shown after joins, which are never displayed.
    protected boolean mShowToastAfterSave = true;

    /**
    /**
     * The contact data loader listener.
     * The contact data loader listener.
     */
     */
@@ -1343,7 +1339,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
            Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed, long photoId) {
            Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed, long photoId) {
        if (hadChanges) {
        if (hadChanges) {
            if (saveSucceeded) {
            if (saveSucceeded) {
                if (saveMode != SaveMode.JOIN && mShowToastAfterSave) {
                if (saveMode != SaveMode.JOIN) {
                    Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
                    Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
                }
                }
            } else {
            } else {