Merge "Use a PopupMenu to show the available fields to add"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 905e06d..b67b010 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -72,6 +72,7 @@
             android:clearTaskOnLaunch="true"
             android:icon="@drawable/ic_launcher_phone"
             android:screenOrientation="nosensor"
+            android:enabled="@bool/dialerEnabled"
         >
             <intent-filter>
                 <action android:name="android.intent.action.DIAL" />
diff --git a/res/values/donottranslate_config.xml b/res/values/donottranslate_config.xml
index cad2a63..e41e153 100644
--- a/res/values/donottranslate_config.xml
+++ b/res/values/donottranslate_config.xml
@@ -18,6 +18,9 @@
 -->
 
 <resources>
+    <!-- Indicates whether the dialer activity is enabled in the build -->
+    <bool name="dialerEnabled">true</bool>
+
     <!-- Flag indicating whether Contacts app is allowed to import contacts from SDCard -->
     <bool name="config_allow_import_from_sdcard">true</bool>
     <!-- If true, all vcard files are imported from SDCard without asking a user.
diff --git a/src/com/android/contacts/DialtactsActivity.java b/src/com/android/contacts/DialtactsActivity.java
index 4fdd775..ce8d3f4 100644
--- a/src/com/android/contacts/DialtactsActivity.java
+++ b/src/com/android/contacts/DialtactsActivity.java
@@ -121,7 +121,7 @@
         }
         editor.putInt(PREF_LAST_MANUALLY_SELECTED_TAB, mLastManuallySelectedTab);
 
-        editor.commit();
+        editor.apply();
     }
 
     private void fixIntent(Intent intent) {
diff --git a/src/com/android/contacts/ui/widget/GenericEditorView.java b/src/com/android/contacts/ui/widget/GenericEditorView.java
index 6be238f..92c815c 100644
--- a/src/com/android/contacts/ui/widget/GenericEditorView.java
+++ b/src/com/android/contacts/ui/widget/GenericEditorView.java
@@ -83,6 +83,7 @@
     private boolean mReadOnly;
     private EditText[] mFieldEditTexts = null;
 
+    private boolean mHasShortAndLongForms;
     private boolean mHideOptional = true;
 
     private EditType mType;
@@ -94,6 +95,7 @@
     private EditorListener mListener;
 
 
+
     public GenericEditorView(Context context) {
         super(context);
     }
@@ -343,6 +345,10 @@
         return !mHideOptional;
     }
 
+    public boolean hasShortAndLongForms() {
+        return mHasShortAndLongForms;
+    }
+
     /**
      * Build the current label state based on selected {@link EditType} and
      * possible custom label string.
@@ -465,9 +471,11 @@
 
             if (field.shortForm) {
                 hidePossible = true;
+                mHasShortAndLongForms = true;
                 fieldView.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
             } else if (field.longForm) {
                 hidePossible = true;
+                mHasShortAndLongForms = true;
                 fieldView.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
             } else {
                 // Hide field when empty and optional value
diff --git a/src/com/android/contacts/views/editor/ContactEditorFragment.java b/src/com/android/contacts/views/editor/ContactEditorFragment.java
index 2d4af4f..4070ca9 100644
--- a/src/com/android/contacts/views/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/views/editor/ContactEditorFragment.java
@@ -1014,10 +1014,12 @@
                 break;
 
             case EditorListener.FIELD_CHANGED:
-                if (nameEditor.areOptionalFieldsVisible()) {
-                    eraseFullName(nameEditor.getValues());
-                } else {
-                    eraseStructuredName(nameEditor.getValues());
+                if (nameEditor.hasShortAndLongForms()) {
+                    if (nameEditor.areOptionalFieldsVisible()) {
+                        eraseFullName(nameEditor.getValues());
+                    } else {
+                        eraseStructuredName(nameEditor.getValues());
+                    }
                 }
                 acquireAggregationSuggestions(rawContactEditor);
                 break;