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

Commit ba6c41ca authored by Tingting Wang's avatar Tingting Wang
Browse files

Improve raw contact editor in Contact Editor.

1) When clicking save on raw contact editor, UI should return to
the quick contact UI.
2) Remove overflow menu on raw contact editor.

BUG 24899070

Change-Id: Iae6954744294fc48fe8dba02459f647f1764c48b
parent ff603b5e
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -184,6 +184,13 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
     */
    public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";

    /**
     * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
     * by itself.
     */
    public static final String INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE =
            "raw_contact_id_to_display_alone";

    /**
     * Intent key to pass the boolean value of if the raw contact id that should be displayed
     * in the full editor by itself is read-only.
@@ -344,6 +351,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
    //
    protected RawContactDeltaList mState;
    protected int mStatus;
    protected long mRawContactIdToDisplayAlone = -1;
    protected boolean mRawContactDisplayAloneIsReadOnly = false;

    // Whether to show the new contact blank form and if it's corresponding delta is ready.
@@ -753,7 +761,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                mState.getFirstWritableRawContact(mContext) != null);

        // help menu depending on whether this is inserting or editing
        if (isInsert(mAction)) {
        if (isInsert(mAction) || mRawContactIdToDisplayAlone != -1) {
            HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
            discardMenu.setVisible(false);
            splitMenu.setVisible(false);
@@ -781,11 +789,16 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
        // Save menu is invisible when there's only one read only contact in the editor.
        saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly);

        if (mRawContactIdToDisplayAlone != -1) {
            sendToVoiceMailMenu.setVisible(false);
            ringToneMenu.setVisible(false);
        } else {
            // Hide telephony-related settings (ringtone, send to voicemail)
            // if we don't have a telephone or are editing a new contact.
            sendToVoiceMailMenu.setChecked(mSendToVoicemailState);
            sendToVoiceMailMenu.setVisible(mArePhoneOptionsChangable);
            ringToneMenu.setVisible(mArePhoneOptionsChangable);
        }

        int size = menu.size();
        for (int i = 0; i < size; i++) {
@@ -1354,6 +1367,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                        mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR));
            }
            mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID);
            mRawContactIdToDisplayAlone = mIntentExtras.getLong(
                    INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE);
            mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean(
                    INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
        }
+4 −13
Original line number Diff line number Diff line
@@ -61,13 +61,6 @@ import java.util.List;
public class ContactEditorFragment extends ContactEditorBaseFragment implements
        RawContactReadOnlyEditorView.Listener {

    /**
     * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
     * by itself.
     */
    public static final String INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE =
            "raw_contact_id_to_display_alone";

    private static final String KEY_EXPANDED_EDITORS = "expandedEditors";

    private static final String KEY_RAW_CONTACT_ID_REQUESTING_PHOTO = "photorequester";
@@ -94,7 +87,6 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
    private PhotoHandler mCurrentPhotoHandler;
    private Uri mCurrentPhotoUri;
    private Bundle mUpdatedPhotos = new Bundle();
    private long mRawContactIdToDisplayAlone = -1;

    public ContactEditorFragment() {
    }
@@ -122,7 +114,7 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
            mCurrentPhotoUri = savedState.getParcelable(KEY_CURRENT_PHOTO_URI);
            mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
            mRawContactIdToDisplayAlone = savedState.getLong(
                    INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE);
                    ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE);
        }
    }

@@ -131,7 +123,7 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
        super.load(action, lookupUri, intentExtras);
        if (intentExtras != null) {
            mRawContactIdToDisplayAlone = intentExtras.getLong(
                    INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE);
                    ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE);
        }
    }

@@ -169,8 +161,6 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            return revert();
        } else if (item.getItemId() == R.id.menu_save && mRawContactIdToDisplayAlone != -1) {
            return super.save(SaveMode.COMPACT);
        }
        return super.onOptionsItemSelected(item);
    }
@@ -447,7 +437,8 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
        outState.putLong(KEY_RAW_CONTACT_ID_REQUESTING_PHOTO, mRawContactIdRequestingPhoto);
        outState.putParcelable(KEY_CURRENT_PHOTO_URI, mCurrentPhotoUri);
        outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
        outState.putLong(INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, mRawContactIdToDisplayAlone);
        outState.putLong(ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE,
                mRawContactIdToDisplayAlone);
        super.onSaveInstanceState(outState);
    }