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
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 54c3c07..1e18e2c 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -185,6 +185,13 @@
     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 @@
     //
     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 @@
                 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 @@
         // Save menu is invisible when there's only one read only contact in the editor.
         saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly);
 
-        // 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);
+        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 @@
                         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);
         }
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index fc438f9..c602a1d 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -61,13 +61,6 @@
 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 @@
     private PhotoHandler mCurrentPhotoHandler;
     private Uri mCurrentPhotoUri;
     private Bundle mUpdatedPhotos = new Bundle();
-    private long mRawContactIdToDisplayAlone = -1;
 
     public ContactEditorFragment() {
     }
@@ -122,7 +114,7 @@
             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 @@
         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 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 @@
         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);
     }