Expandable structured support, organize editors, much more.

Wrote expandable editor support, so that StructuredName and
StructuredPostal could be displayed compactly on smaller
screens, but still expanded to edit all possible fields.

Reorganized editors to directly inflate classes instead of
using ViewHolder pattern.  This helps us prepare for focus
saving logic coming soon, and also required that each data
row have getViewId() to be uniquely identified.

When editing EAS contacts, don't use separate types for
"Email 1", "Email 2", etc, and instead use a single overall
limit on type-less values.  (This is dependant on
http://b/2065904 being resolved.)

Defined fallback "on-phone" account separately to prevent
confusion with Google account, also limited the possible
data types that could be entered.

Suspend aggregation while persisting RawContacts updates
to prevent possible re-aggregation and user confusion when
returning to View activity.  Also correctly generate
AggregationExceptions when inserting new RawContacts under
an existing aggregate.  Fixes http://b/2087517

When inserting Google contacts, add GroupMembership for
"My Contacts" to help visibility, fixing http://b/2070479

Don't reprompt for account when rotating during INSERT,
fixing http://b/2084585 and hide editor until finished
with async loading.  Ensure that specific rows exist so
we always have StructuredName to edit, and have waiting
Phone and Email fields for INSERT.

Used better method of creating generic ArrayList/HashMap.
diff --git a/res/layout/act_edit.xml b/res/layout/act_edit.xml
index de62e5e..250a0e1 100644
--- a/res/layout/act_edit.xml
+++ b/res/layout/act_edit.xml
@@ -37,12 +37,14 @@
             android:layout_width="fill_parent"
             android:layout_height="wrap_content" />
 
-        <FrameLayout
+        <include
             android:id="@android:id/tabcontent"
             android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
+            android:layout_height="0dip"
             android:layout_weight="1"
-            android:fillViewport="true" />
+            android:fillViewport="true"
+            android:visibility="invisible"
+            layout="@layout/item_contact_editor" />
 
         <LinearLayout
             android:layout_width="fill_parent"
diff --git a/res/layout/act_edit_contact.xml b/res/layout/item_contact_editor.xml
similarity index 77%
rename from res/layout/act_edit_contact.xml
rename to res/layout/item_contact_editor.xml
index 86b010f..c444889 100644
--- a/res/layout/act_edit_contact.xml
+++ b/res/layout/item_contact_editor.xml
@@ -15,7 +15,7 @@
 -->
 
 <!-- placed inside act_edit as tabcontent -->
-<RelativeLayout
+<com.android.contacts.ui.widget.ContactEditorView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
@@ -27,28 +27,33 @@
         android:layout_height="0dip" />
 
     <FrameLayout
-        android:id="@+id/hook_photo"
-        android:layout_width="76dip"
-        android:layout_height="76dip"
-        android:layout_marginTop="4dip"
-        android:layout_marginLeft="2dip"
-        android:layout_marginBottom="4dip"
-        android:layout_marginRight="4dip"
-        android:layout_below="@+id/text_summary" />
+        android:id="@+id/stub_photo"
+        android:layout_width="100dip"
+        android:layout_height="96dip"
+        android:paddingLeft="12dip"
+        android:paddingTop="10dip">
 
-    <FrameLayout
-        android:id="@+id/hook_displayname"
+        <include
+            android:id="@+id/edit_photo"
+            layout="@layout/item_photo_editor" />
+
+    </FrameLayout>
+
+    <include
+        android:id="@+id/edit_name"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:layout_alignTop="@+id/hook_photo"
-        android:layout_alignBottom="@+id/hook_photo"
-        android:layout_toRightOf="@+id/hook_photo" />
+        android:layout_below="@id/text_summary"
+        android:layout_toRightOf="@id/stub_photo"
+        android:layout_marginTop="6dip"
+        android:layout_marginBottom="4dip"
+        layout="@layout/item_generic_editor" />
 
     <LinearLayout
         android:id="@+id/sect_general"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:layout_below="@+id/hook_photo"
+        android:layout_below="@+id/edit_name"
         android:orientation="vertical" />
 
     <TextView
@@ -77,4 +82,4 @@
         android:background="@color/sect_secondary"
         android:orientation="vertical" />
 
-</RelativeLayout>
+</com.android.contacts.ui.widget.ContactEditorView>
diff --git a/res/layout/item_editor_displayname.xml b/res/layout/item_editor_displayname.xml
deleted file mode 100644
index b819d80..0000000
--- a/res/layout/item_editor_displayname.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-  
-          http://www.apache.org/licenses/LICENSE-2.0
-  
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:gravity="center_vertical">
-
-    <EditText
-        android:id="@+id/name"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginRight="?android:attr/scrollbarSize"
-        android:gravity="center_vertical"
-        android:inputType="textPersonName|textCapWords"
-        android:hint="@string/ghostData_name" />
-
-    <!-- "Phonetic name" entry widget, visible only in certain locales -->
-    <include layout="@layout/edit_phonetic_name"/>
-
-</LinearLayout>
diff --git a/res/layout/item_editor.xml b/res/layout/item_generic_editor.xml
similarity index 70%
rename from res/layout/item_editor.xml
rename to res/layout/item_generic_editor.xml
index 8d46bcc..3c1426d 100644
--- a/res/layout/item_editor.xml
+++ b/res/layout/item_generic_editor.xml
@@ -14,35 +14,46 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<com.android.contacts.ui.widget.GenericEditorView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:orientation="horizontal"
     android:baselineAligned="false"
-    android:gravity="top"
     android:paddingRight="?android:attr/scrollbarSize">
 
     <Button
         android:id="@+id/edit_label"
         android:layout_width="100dip"
         android:layout_height="wrap_content"
+        android:visibility="gone"
         android:gravity="left|center_vertical" />
 
-    <LinearLayout
-        android:id="@+id/edit_fields"
-        android:layout_width="0dip"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:layout_marginLeft="4dip"
-        android:orientation="vertical"
-        android:baselineAligned="false"
-        android:gravity="center_vertical" />
-
     <ImageButton
         android:id="@+id/edit_delete"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
         style="@style/MinusButton" />
 
-</LinearLayout>
+    <LinearLayout
+        android:id="@+id/edit_fields"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="4dip"
+        android:layout_alignWithParentIfMissing="true"
+        android:layout_toRightOf="@id/edit_label"
+        android:layout_toLeftOf="@id/edit_delete"
+        android:orientation="vertical"
+        android:baselineAligned="false"
+        android:gravity="center_vertical" />
+
+    <ImageButton
+        android:id="@+id/edit_more"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_alignBottom="@id/edit_fields"
+        android:visibility="gone"
+        style="@style/MoreButton" />
+
+</com.android.contacts.ui.widget.GenericEditorView>
diff --git a/res/layout/item_edit_kind.xml b/res/layout/item_kind_section.xml
similarity index 95%
rename from res/layout/item_edit_kind.xml
rename to res/layout/item_kind_section.xml
index fd68a00..73912aa 100644
--- a/res/layout/item_edit_kind.xml
+++ b/res/layout/item_kind_section.xml
@@ -16,7 +16,7 @@
 
 <!-- the body surrounding all editors for a specific kind -->
 
-<LinearLayout
+<com.android.contacts.ui.widget.KindSectionView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
@@ -68,4 +68,4 @@
         android:paddingBottom="6dip"
         android:orientation="vertical" />
 
-</LinearLayout>
+</com.android.contacts.ui.widget.KindSectionView>
diff --git a/res/layout/item_editor_photo.xml b/res/layout/item_photo_editor.xml
similarity index 86%
rename from res/layout/item_editor_photo.xml
rename to res/layout/item_photo_editor.xml
index 4a32a67..b2a5f33 100644
--- a/res/layout/item_editor_photo.xml
+++ b/res/layout/item_photo_editor.xml
@@ -14,10 +14,10 @@
      limitations under the License.
 -->
 
-<ImageView
+<com.android.contacts.ui.widget.PhotoEditorView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="@dimen/edit_photo_size"
+    android:layout_height="@dimen/edit_photo_size"
     android:clickable="true"
     android:focusable="true"
     android:src="@drawable/ic_menu_add_picture"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 3c2c2bc..c4384d7 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -16,4 +16,5 @@
 
 <resources>
     <dimen name="fasttrack_shadow">37dip</dimen>
+    <dimen name="edit_photo_size">76dip</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bc4d7e5..00ef14b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -856,14 +856,6 @@
 <string name="type_radio">Radio</string>
 <string name="type_assistant">Assistant</string>
 
-<string name="type_email_1">Email 1</string>
-<string name="type_email_2">Email 2</string>
-<string name="type_email_3">Email 3</string>
-
-<string name="type_im_1">Im 1</string>
-<string name="type_im_2">Im 2</string>
-<string name="type_im_3">Im 3</string>
-
 <string name="type_im_aim">AIM</string>
 <string name="type_im_msn">Windows Live</string>
 <string name="type_im_yahoo">Yahoo</string>
@@ -891,6 +883,10 @@
          group that would also cause all ungrouped contacts to stop syncing. -->
     <string name="display_warn_remove_ungrouped">Removing \'<xliff:g id="group" example="Starred">%s</xliff:g>\' from sync will also remove any ungrouped contacts from sync.</string>
 
+    <!-- Title for data source when creating or editing a contact that doesn't
+         belong to a specific account.  This contact will only exist on the phone
+         and will not be synced. -->
+    <string name="account_phone">Phone-only (unsynced)</string>
 
 <string name="call_home">Call home</string>
 <string name="call_mobile">Call mobile</string>
@@ -902,8 +898,6 @@
 <string name="call_custom">Call <xliff:g id="custom">%s</xliff:g></string>
 
 <!-- exchange specific -->
-<string name="call_home_2">Call home 2</string>
-<string name="call_work_2">Call work 2</string>
 <string name="call_car">Call car</string>
 <string name="call_company_main">Call company main</string>
 <string name="call_mms">Call MMS</string>
@@ -923,8 +917,6 @@
 <string name="sms_custom">Text <xliff:g id="custom">%s</xliff:g></string>
 
 <!-- exchange specific -->
-<string name="sms_home_2">Text home 2</string>
-<string name="sms_work_2">Text work 2</string>
 <string name="sms_car">Text car</string>
 <string name="sms_company_main">Text company main</string>
 <string name="sms_mms">Text MMS</string>
@@ -938,10 +930,6 @@
 <string name="email_other">Email other</string>
 <string name="email_custom">Email <xliff:g id="custom">%s</xliff:g></string>
 
-<string name="email_1">Email 1</string>
-<string name="email_2">Email 2</string>
-<string name="email_3">Email 2</string>
-
 
 
 
@@ -961,5 +949,15 @@
 <string name="postal_country">Country</string>
 
 
+<string name="name_given">Given name</string>
+<string name="name_family">Family name</string>
+<string name="name_prefix">Name prefix</string>
+<string name="name_middle">Middle name</string>
+<string name="name_suffix">Name suffix</string>
+<string name="name_phonetic_given">Phonetic given name</string>
+<string name="name_phonetic_middle">Phonetic middle name</string>
+<string name="name_phonetic_family">Phonetic family name</string>
+
+
 
 </resources>