Fix Autofill profile editor UI.

Move the save button into the action bar to conserve space.
Update the IME options so that we don't enter extract mode.

Bug: 5210430
Change-Id: I0c5d6c200071130c9b6ed19a1def7ac0fd42ac10
diff --git a/res/layout-port/autofill_settings_fragment.xml b/res/layout-port/autofill_settings_fragment.xml
index 63dba4d..16f674d 100644
--- a/res/layout-port/autofill_settings_fragment.xml
+++ b/res/layout-port/autofill_settings_fragment.xml
@@ -43,35 +43,19 @@
                 android:layout_width="match_parent" />
 
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_name" />
             <EditText android:id="@+id/autofill_profile_editor_name_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:inputType="textPersonName|textCapWords"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textPersonName|textCapWords" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_company_name" />
             <EditText android:id="@+id/autofill_profile_editor_company_name_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:inputType="textCapWords"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
@@ -91,13 +75,9 @@
                     android:text="@string/autofill_profile_editor_address_line_1_hint" />
             </LinearLayout>
             <EditText android:id="@+id/autofill_profile_editor_address_line_1_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:inputType="textCapWords"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
@@ -117,115 +97,50 @@
                     android:text="@string/autofill_profile_editor_address_line_2_hint" />
             </LinearLayout>
             <EditText android:id="@+id/autofill_profile_editor_address_line_2_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="bottom"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:inputType="textCapWords"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_city" />
             <EditText android:id="@+id/autofill_profile_editor_city_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:inputType="textCapWords"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_state" />
             <EditText android:id="@+id/autofill_profile_editor_state_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:inputType="textCapWords"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_zip_code" />
             <EditText android:id="@+id/autofill_profile_editor_zip_code_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:inputType="textCapCharacters"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapCharacters" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_country" />
             <EditText android:id="@+id/autofill_profile_editor_country_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:inputType="textCapWords"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textCapWords" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_phone_number" />
             <EditText android:id="@+id/autofill_profile_editor_phone_number_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:singleLine="true"
+                style="@style/AutofillProfileEditText"
                 android:phoneNumber="true" />
+
             <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                style="@style/AutofillProfileTextView"
                 android:text="@string/autofill_profile_editor_email_address" />
             <EditText android:id="@+id/autofill_profile_editor_email_address_edit"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:layout_margin="2dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:inputType="textEmailAddress"
-                android:singleLine="true" />
+                style="@style/AutofillProfileEditText"
+                android:inputType="textEmailAddress" />
         </LinearLayout>
     </ScrollView>
-
-    <View
-        android:layout_height="12dip"
-        android:layout_width="match_parent" />
-
-    <Button
-        android:id="@+id/autofill_profile_editor_save_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/autofill_profile_editor_save_profile"
-        android:textAppearance="?android:attr/textAppearanceMedium" />
-
 </LinearLayout>
diff --git a/res/layout/autofill_settings_fragment.xml b/res/layout/autofill_settings_fragment.xml
index 8c90dd7..ab23ffb 100644
--- a/res/layout/autofill_settings_fragment.xml
+++ b/res/layout/autofill_settings_fragment.xml
@@ -49,37 +49,19 @@
                 android:stretchColumns="1">
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_name" />
                     <EditText android:id="@+id/autofill_profile_editor_name_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:inputType="textPersonName|textCapWords"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textPersonName|textCapWords" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_company_name" />
                     <EditText android:id="@+id/autofill_profile_editor_company_name_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:inputType="textCapWords"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -101,13 +83,8 @@
                             android:text="@string/autofill_profile_editor_address_line_1_hint" />
                     </LinearLayout>
                     <EditText android:id="@+id/autofill_profile_editor_address_line_1_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:inputType="textCapWords"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -129,130 +106,59 @@
                             android:text="@string/autofill_profile_editor_address_line_2_hint" />
                     </LinearLayout>
                     <EditText android:id="@+id/autofill_profile_editor_address_line_2_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="bottom"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:inputType="textCapWords"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_city" />
                     <EditText android:id="@+id/autofill_profile_editor_city_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:inputType="textCapWords"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_state" />
                     <EditText android:id="@+id/autofill_profile_editor_state_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:inputType="textCapWords"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_zip_code" />
                     <EditText android:id="@+id/autofill_profile_editor_zip_code_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:inputType="textCapCharacters"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapCharacters" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_country" />
                     <EditText android:id="@+id/autofill_profile_editor_country_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:inputType="textCapWords"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textCapWords" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_phone_number" />
                     <EditText android:id="@+id/autofill_profile_editor_phone_number_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:singleLine="true"
+                        style="@style/AutofillProfileEditText"
                         android:phoneNumber="true" />
                 </TableRow>
                 <TableRow>
                     <TextView
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        style="@style/AutofillProfileTextView"
                         android:text="@string/autofill_profile_editor_email_address" />
                     <EditText android:id="@+id/autofill_profile_editor_email_address_edit"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:gravity="center_vertical"
-                        android:layout_margin="2dip"
-                        android:textAppearance="?android:attr/textAppearanceMedium"
-                        android:inputType="textEmailAddress"
-                        android:singleLine="true" />
+                        style="@style/AutofillProfileEditText"
+                        android:inputType="textEmailAddress" />
                 </TableRow>
             </TableLayout>
        </LinearLayout>
     </ScrollView>
-
-    <View
-        android:layout_height="12dip"
-        android:layout_width="match_parent" />
-
-    <Button
-        android:id="@+id/autofill_profile_editor_save_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/autofill_profile_editor_save_profile"
-        android:textAppearance="?android:attr/textAppearanceMedium" />
-
 </LinearLayout>
 
diff --git a/res/menu/autofill_profile_editor.xml b/res/menu/autofill_profile_editor.xml
index 4e746e5..9dab635 100644
--- a/res/menu/autofill_profile_editor.xml
+++ b/res/menu/autofill_profile_editor.xml
@@ -15,6 +15,11 @@
 -->
 
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/autofill_profile_editor_save_profile_menu_id"
+        android:title="@string/autofill_profile_editor_save_profile"
+        android:icon="@android:drawable/ic_menu_save"
+        android:showAsAction="ifRoom|withText" />
+
     <item android:id="@+id/autofill_profile_editor_delete_profile_menu_id"
         android:title="@string/autofill_profile_editor_delete_profile"
         android:icon="@android:drawable/ic_menu_delete"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 361702e..3c87e22 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -80,4 +80,17 @@
         <item name="android:textColor">?android:attr/textColorSecondary</item>
         <item name="android:textStyle">normal</item>
     </style>
+
+    <style name="AutofillProfileTextView">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:gravity">center_vertical</item>
+        <item name="android:layout_margin">2dip</item>
+        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+    </style>
+    <style name="AutofillProfileEditText" parent="@style/AutofillProfileTextView">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:imeOptions">flagNoExtractUi</item>
+        <item name="android:singleLine">true</item>
+    </style>
 </resources>
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index 04f45b5..639fcdc 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -52,7 +52,7 @@
     private EditText mCountryEdit;
     private EditText mPhoneEdit;
 
-    private Button mSaveButton;
+    private MenuItem mSaveMenuItem;
 
     // Used to display toast after DB interactions complete.
     private Handler mHandler;
@@ -87,7 +87,7 @@
                 mPhoneEdit.setError(null);
             }
 
-            updateButtonState();
+            updateSaveMenuItemState();
         }
 
         public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -99,7 +99,7 @@
 
     private class FieldChangedListener implements TextWatcher {
         public void afterTextChanged(Editable s) {
-            updateButtonState();
+            updateSaveMenuItemState();
         }
 
         public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -147,11 +147,14 @@
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         inflater.inflate(R.menu.autofill_profile_editor, menu);
+        mSaveMenuItem = menu.findItem(R.id.autofill_profile_editor_save_profile_menu_id);
+        updateSaveMenuItemState();
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        if (item.getItemId() == R.id.autofill_profile_editor_delete_profile_menu_id) {
+        switch (item.getItemId()) {
+        case R.id.autofill_profile_editor_delete_profile_menu_id:
             // Clear the UI.
             mFullNameEdit.setText("");
             mEmailEdit.setText("");
@@ -168,10 +171,30 @@
             // trigger the current profile to get deleted from the DB.
             mSettings.setAutoFillProfile(null,
                     mHandler.obtainMessage(PROFILE_DELETED_MSG));
-            updateButtonState();
+            updateSaveMenuItemState();
             return true;
+
+        case R.id.autofill_profile_editor_save_profile_menu_id:
+            AutoFillProfile newProfile = new AutoFillProfile(
+                    mUniqueId,
+                    mFullNameEdit.getText().toString(),
+                    mEmailEdit.getText().toString(),
+                    mCompanyEdit.getText().toString(),
+                    mAddressLine1Edit.getText().toString(),
+                    mAddressLine2Edit.getText().toString(),
+                    mCityEdit.getText().toString(),
+                    mStateEdit.getText().toString(),
+                    mZipEdit.getText().toString(),
+                    mCountryEdit.getText().toString(),
+                    mPhoneEdit.getText().toString());
+
+            mSettings.setAutoFillProfile(newProfile,
+                    mHandler.obtainMessage(PROFILE_SAVED_MSG));
+            return true;
+
+        default:
+            return false;
         }
-        return false;
     }
 
     @Override
@@ -203,27 +226,6 @@
         mCountryEdit.addTextChangedListener(mFieldChangedListener);
         mPhoneEdit.addTextChangedListener(new PhoneNumberValidator());
 
-        mSaveButton = (Button)v.findViewById(R.id.autofill_profile_editor_save_button);
-        mSaveButton.setOnClickListener(new OnClickListener() {
-            public void onClick(View button) {
-                AutoFillProfile newProfile = new AutoFillProfile(
-                        mUniqueId,
-                        mFullNameEdit.getText().toString(),
-                        mEmailEdit.getText().toString(),
-                        mCompanyEdit.getText().toString(),
-                        mAddressLine1Edit.getText().toString(),
-                        mAddressLine2Edit.getText().toString(),
-                        mCityEdit.getText().toString(),
-                        mStateEdit.getText().toString(),
-                        mZipEdit.getText().toString(),
-                        mCountryEdit.getText().toString(),
-                        mPhoneEdit.getText().toString());
-
-                mSettings.setAutoFillProfile(newProfile,
-                        mHandler.obtainMessage(PROFILE_SAVED_MSG));
-            }
-        });
-
         // Populate the text boxes with any pre existing AutoFill data.
         AutoFillProfile activeProfile = mSettings.getAutoFillProfile();
         if (activeProfile != null) {
@@ -239,14 +241,18 @@
             mPhoneEdit.setText(activeProfile.getPhoneNumber());
         }
 
-        updateButtonState();
+        updateSaveMenuItemState();
 
         return v;
     }
 
-    public void updateButtonState() {
+    private void updateSaveMenuItemState() {
+        if (mSaveMenuItem == null) {
+            return;
+        }
 
-        boolean valid = (mFullNameEdit.getText().toString().length() > 0 ||
+        boolean currentState = mSaveMenuItem.isEnabled();
+        boolean newState = (mFullNameEdit.getText().toString().length() > 0 ||
             mEmailEdit.getText().toString().length() > 0 ||
             mCompanyEdit.getText().toString().length() > 0 ||
             mAddressLine1Edit.getText().toString().length() > 0 ||
@@ -257,9 +263,9 @@
             mCountryEdit.getText().toString().length() > 0) &&
             mPhoneEdit.getError() == null;
 
-        // Only enable the save buttons if we have at least one field completed
-        // and the phone number (if present is valid).
-        mSaveButton.setEnabled(valid);
+        if (currentState != newState) {
+            mSaveMenuItem.setEnabled(newState);
+        }
     }
 
     private void closeEditor() {