Merge "Don't allow read-only photos to be changed in compact editor" into mnc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d7ee9c8..4bee141 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -359,22 +359,23 @@
             </intent-filter>
         </activity>
 
-        <!-- Create a new or edit an existing contact -->
+        <!-- Edit or create a contact with all fields displayed. -->
         <activity
             android:name=".activities.ContactEditorActivity"
             android:label="@string/launcherActivityLabel"
             android:theme="@style/EditorActivityTheme"
-            android:windowSoftInputMode="stateHidden|adjustResize">
+            android:windowSoftInputMode="stateHidden|adjustResize"
+            android:exported="false">
 
             <intent-filter android:label="@string/editContactDescription">
-                <action android:name="android.intent.action.EDIT" />
+                <action android:name="com.android.contacts.action.FULL_EDIT" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <data android:mimeType="vnd.android.cursor.item/person" />
                 <data android:mimeType="vnd.android.cursor.item/contact" />
                 <data android:mimeType="vnd.android.cursor.item/raw_contact" />
             </intent-filter>
             <intent-filter android:label="@string/insertContactDescription">
-                <action android:name="android.intent.action.INSERT" />
+                <action android:name="com.android.contacts.action.FULL_INSERT" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <data android:mimeType="vnd.android.cursor.dir/person" />
                 <data android:mimeType="vnd.android.cursor.dir/contact" />
diff --git a/src/com/android/contacts/activities/ContactEditorBaseActivity.java b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
index fe09bec..b9edabc 100644
--- a/src/com/android/contacts/activities/ContactEditorBaseActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
@@ -55,14 +55,14 @@
      *
      * Only used to open the "fully expanded" editor -- {@link ContactEditorActivity}.
      */
-    public static final String ACTION_EDIT = "com.google.android.contacts.action.EDIT";
+    public static final String ACTION_EDIT = "com.android.contacts.action.FULL_EDIT";
 
     /**
      * Intent action to insert a new contact with all available field inputs displayed.
      *
      * Only used to open the "fully expanded" editor -- {@link ContactEditorActivity}.
      */
-    public static final String ACTION_INSERT = "com.google.android.contacts.action.INSERT";
+    public static final String ACTION_INSERT = "com.android.contacts.action.FULL_INSERT";
 
     public static final String ACTION_JOIN_COMPLETED = "joinCompleted";
     public static final String ACTION_SAVE_COMPLETED = "saveCompleted";
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index 9757a7d..669e400 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -365,7 +365,7 @@
     }
 
     private void addStructuredNameView(RawContactDeltaList rawContactDeltas, long nameId) {
-        // Look for a match for the photo ID that was passed in
+        // Look for a match for the name ID that was passed in
         for (RawContactDelta rawContactDelta : rawContactDeltas) {
             if (!rawContactDelta.isVisible()) continue;
             final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager);
@@ -387,7 +387,8 @@
                     final NameEditorListener nameEditorListener = new NameEditorListener(
                             mNameValuesDelta, rawContactDelta.getRawContactId(), mListener);
                     mNames.addView(inflateStructuredNameEditorView(mNames, accountType,
-                            mNameValuesDelta, rawContactDelta, nameEditorListener));
+                            mNameValuesDelta, rawContactDelta, nameEditorListener,
+                            !accountType.areContactsWritable()));
                     return;
                 }
             }
@@ -408,7 +409,8 @@
                 final NameEditorListener nameEditorListener = new NameEditorListener(
                         superPrimaryValuesDelta, rawContactDelta.getRawContactId(), mListener);
                 mNames.addView(inflateStructuredNameEditorView(mNames, accountType,
-                        superPrimaryValuesDelta, rawContactDelta, nameEditorListener));
+                        superPrimaryValuesDelta, rawContactDelta, nameEditorListener,
+                        !accountType.areContactsWritable()));
                 return;
             }
         }
@@ -424,14 +426,13 @@
             final List<ValuesDelta> nonEmptyValuesDeltas = getNonEmptyValuesDeltas(
                     rawContactDelta, StructuredName.CONTENT_ITEM_TYPE, dataKind);
             if (nonEmptyValuesDeltas != null && !nonEmptyValuesDeltas.isEmpty()) {
-                // Take the first non-empty name, also make it super primary before expanding to the
-                // full editor (see #onCLick) so that name does not change if the user saves from
-                // the fully expanded editor.
+                // Take the first non-empty name
                 mNameValuesDelta = nonEmptyValuesDeltas.get(0);
                 final NameEditorListener nameEditorListener = new NameEditorListener(
                         mNameValuesDelta, rawContactDelta.getRawContactId(), mListener);
                 mNames.addView(inflateStructuredNameEditorView(mNames, accountType,
-                        mNameValuesDelta, rawContactDelta, nameEditorListener));
+                        mNameValuesDelta, rawContactDelta, nameEditorListener,
+                        !accountType.areContactsWritable()));
                 return;
             }
         }
@@ -451,7 +452,8 @@
                 final NameEditorListener nameEditorListener = new NameEditorListener(
                         mNameValuesDelta, rawContactDelta.getRawContactId(), mListener);
                 mNames.addView(inflateStructuredNameEditorView(mNames, accountType,
-                        mNameValuesDelta, rawContactDelta, nameEditorListener));
+                        mNameValuesDelta, rawContactDelta, nameEditorListener,
+                        !accountType.areContactsWritable()));
                 return;
             }
         }
@@ -594,7 +596,7 @@
 
     private StructuredNameEditorView inflateStructuredNameEditorView(ViewGroup viewGroup,
             AccountType accountType, ValuesDelta valuesDelta, RawContactDelta rawContactDelta,
-            NameEditorListener nameEditorListener) {
+            NameEditorListener nameEditorListener, boolean readOnly) {
         final StructuredNameEditorView result = (StructuredNameEditorView) mLayoutInflater.inflate(
                 R.layout.structured_name_editor_view, viewGroup, /* attachToRoot =*/ false);
         if (nameEditorListener != null) {
@@ -605,7 +607,7 @@
                 accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME),
                 valuesDelta,
                 rawContactDelta,
-                /* readOnly =*/ false,
+                readOnly,
                 mViewIdGenerator);
         return result;
     }