Fix bugs on Contact editor.

1) Remove primary photo checkbox in full editor. Primary photo should
be set in photo picker.
2) Remove save menu if there's only one read only contact in the full editor.
3) Add account type icon in account info when there's only one account
for a contact.
4) Return back to Compact editor after saving results in full editor.

BUG 24547289

Change-Id: I02f8ee01f7cc7d1b0b06ad338570dc4b17c55e31
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index f808d4d..a6f2d1c 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -129,7 +129,7 @@
         /**
          * Invoked when a rawcontact from merged contacts is selected in editor.
          */
-        public void onRawContactSelected(Uri uri, long rawContactId);
+        public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly);
     }
 
     /**
@@ -382,6 +382,7 @@
     private View mAccountHeaderContainer;
     private TextView mAccountHeaderType;
     private TextView mAccountHeaderName;
+    private ImageView mAccountHeaderIcon;
 
     // Account selector
     private View mAccountSelectorContainer;
@@ -430,6 +431,7 @@
         mAccountHeaderContainer = findViewById(R.id.account_container);
         mAccountHeaderType = (TextView) findViewById(R.id.account_type);
         mAccountHeaderName = (TextView) findViewById(R.id.account_name);
+        mAccountHeaderIcon = (ImageView) findViewById(R.id.account_type_icon);
 
         // Account selector
         mAccountSelectorContainer = findViewById(R.id.account_selector_container);
@@ -824,6 +826,10 @@
         }
         mAccountHeaderType.setText(accountInfo.second);
 
+        final AccountType primaryAccountType = mPrimaryRawContactDelta.getRawContactAccountType(
+                getContext());
+        mAccountHeaderIcon.setImageDrawable(primaryAccountType.getDisplayIcon(getContext()));
+
         mAccountHeaderContainer.setContentDescription(
                 EditorUiUtils.getAccountInfoContentDescription(
                         accountInfo.first, accountInfo.second));
@@ -906,19 +912,19 @@
                     public void onItemClick(AdapterView<?> parent, View view, int position,
                                             long id) {
                         UiClosables.closeQuietly(popup);
-                        final RawContactDelta rawContactDelta = adapter.getItem(position);
-                        final long rawContactId = adapter.getItemId(position);
-                        final Uri rawContactUri = ContentUris.withAppendedId(
-                                ContactsContract.RawContacts.CONTENT_URI, rawContactId);
-                        // Start new activity for the raw contact in selected account.
-                        final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
-                        intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
-
-                        ArrayList<ContentValues> values = rawContactDelta.getContentValues();
-                        intent.putExtra(ContactsContract.Intents.Insert.DATA, values);
 
                         if (mListener != null) {
-                            mListener.onRawContactSelected(rawContactUri, rawContactId);
+                            final long rawContactId = adapter.getItemId(position);
+                            final Uri rawContactUri = ContentUris.withAppendedId(
+                                    ContactsContract.RawContacts.CONTENT_URI, rawContactId);
+                            final RawContactDelta rawContactDelta = adapter.getItem(position);
+                            final AccountTypeManager accountTypes = AccountTypeManager.getInstance(
+                                    getContext());
+                            final AccountType accountType = rawContactDelta.getAccountType(
+                                    accountTypes);
+                            final boolean isReadOnly = !accountType.areContactsWritable();
+
+                            mListener.onRawContactSelected(rawContactUri, rawContactId, isReadOnly);
                         }
                     }
                 });