Refactor editor layout file dependencies out of common.

Editor view layout files are only needed by the Contacts app. But they were
being referenced from within AccountTypeManager and several other classes.
These references are un-necessary and would have caused too many editor
dependencies, such as the EditorView classes, to go into common.

With the refactor, many layout files can be moved back into Contacts.

Bug: 6993891
Change-Id: I146b3038f1b2273a3af2dfac3d2e86bf40bb5bd7
diff --git a/res/layout-sw580dp/text_fields_editor_view.xml b/res/layout-sw580dp/text_fields_editor_view.xml
new file mode 100644
index 0000000..89970c6
--- /dev/null
+++ b/res/layout-sw580dp/text_fields_editor_view.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<com.android.contacts.editor.TextFieldsEditorView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:focusable="true"
+        android:clickable="true">
+
+        <include
+            android:id="@+id/editors"
+            layout="@layout/edit_field_list" />
+
+        <include
+            android:id="@+id/expansion_view_container"
+            layout="@layout/edit_expansion_view"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/spinner"
+            layout="@layout/edit_spinner"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/delete_button_container"
+            layout="@layout/edit_delete_button"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+</com.android.contacts.editor.TextFieldsEditorView>
diff --git a/res/layout/edit_date_picker.xml b/res/layout/edit_date_picker.xml
new file mode 100644
index 0000000..b53fa0f
--- /dev/null
+++ b/res/layout/edit_date_picker.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- Button to select a date in the contact editor. -->
+
+<Button
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/date_view"
+    style="?android:attr/spinnerStyle"
+    android:layout_width="0dip"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:layout_weight="1"
+    android:gravity="center_vertical"
+    android:layout_marginLeft="@dimen/editor_field_left_padding"
+    android:layout_marginRight="@dimen/editor_field_right_padding"
+    android:textAppearance="?android:attr/textAppearanceMedium"
+    android:paddingLeft="12dip" />
diff --git a/res/layout/edit_delete_button.xml b/res/layout/edit_delete_button.xml
new file mode 100644
index 0000000..962d437
--- /dev/null
+++ b/res/layout/edit_delete_button.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- "Delete field" button in the contact editor. -->
+
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:layout_marginRight="2dip"
+    android:layout_gravity="bottom">
+    <ImageView
+        android:id="@+id/delete_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:duplicateParentState="true"
+        android:background="?android:attr/selectableItemBackground"
+        android:src="@drawable/ic_menu_remove_field_holo_light"
+        android:paddingLeft="@dimen/editor_round_button_padding_left"
+        android:paddingRight="@dimen/editor_round_button_padding_right"
+        android:paddingTop="@dimen/editor_round_button_padding_top"
+        android:paddingBottom="@dimen/editor_round_button_padding_bottom"
+        android:contentDescription="@string/description_minus_button" />
+</FrameLayout>
diff --git a/res/layout/edit_expansion_view.xml b/res/layout/edit_expansion_view.xml
new file mode 100644
index 0000000..3ba59d4
--- /dev/null
+++ b/res/layout/edit_expansion_view.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- "More" or "less" expansion button in the contact editor. -->
+
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:layout_gravity="top">
+    <ImageView
+        android:id="@+id/expansion_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:duplicateParentState="true"
+        android:background="?android:attr/selectableItemBackground"
+        android:paddingLeft="@dimen/editor_round_button_padding_left"
+        android:paddingRight="@dimen/editor_round_button_padding_right"
+        android:paddingTop="@dimen/editor_round_button_padding_top"
+        android:paddingBottom="@dimen/editor_round_button_padding_bottom" />
+</FrameLayout>
diff --git a/res/layout/edit_field_list.xml b/res/layout/edit_field_list.xml
new file mode 100644
index 0000000..fddb28b
--- /dev/null
+++ b/res/layout/edit_field_list.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- Layout to contain a list of fields in the contact editor. -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/editors"
+    android:layout_width="0dip"
+    android:layout_weight="1"
+    android:layout_height="wrap_content"
+    android:paddingLeft="@dimen/editor_field_left_padding"
+    android:orientation="vertical" />
diff --git a/res/layout/edit_field_list_with_anchor_view.xml b/res/layout/edit_field_list_with_anchor_view.xml
new file mode 100644
index 0000000..0683a0a
--- /dev/null
+++ b/res/layout/edit_field_list_with_anchor_view.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- Layout that behaves similarly to edit_field_list.xml,
+     but also has an anchor view for ListPopupWindow -->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="0dip"
+    android:layout_height="wrap_content"
+    android:layout_weight="1"
+    android:paddingLeft="@dimen/editor_field_left_padding"
+    android:orientation="vertical">
+    <LinearLayout
+         android:id="@+id/editors"
+         android:layout_width="match_parent"
+         android:layout_height="wrap_content"
+         android:orientation="vertical" />
+    <View
+         android:id="@+id/anchor_view"
+         android:layout_width="match_parent"
+         android:layout_height="0px" />
+</LinearLayout>
diff --git a/res/layout/edit_spinner.xml b/res/layout/edit_spinner.xml
new file mode 100644
index 0000000..f21baa8
--- /dev/null
+++ b/res/layout/edit_spinner.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- Spinner for a field in the contact editor. -->
+
+<!-- Note: explicitly override the default left and right padding on spinner -->
+<Spinner
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/spinner"
+    android:layout_gravity="bottom"
+    android:layout_width="@dimen/editor_type_label_width"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:paddingLeft="0dip"
+    android:paddingRight="10dip"/>
diff --git a/res/layout/event_field_editor_view.xml b/res/layout/event_field_editor_view.xml
new file mode 100644
index 0000000..e51c5bb
--- /dev/null
+++ b/res/layout/event_field_editor_view.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<!-- Editor for a single event entry in the contact editor -->
+
+<com.android.contacts.editor.EventFieldEditorView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:focusable="true"
+        android:clickable="true">
+
+        <include
+            android:id="@+id/date_view"
+            layout="@layout/edit_date_picker" />
+
+        <Spinner
+            android:id="@+id/spinner"
+            android:layout_width="@dimen/editor_type_label_width"
+            android:layout_height="match_parent"
+            android:layout_gravity="bottom"
+            android:paddingLeft="0dip"
+            android:paddingRight="10dip"
+            android:visibility="gone"/>
+
+        <include
+            android:id="@+id/delete_button_container"
+            layout="@layout/edit_delete_button"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+</com.android.contacts.editor.EventFieldEditorView>
diff --git a/res/layout/name_edit_expansion_view.xml b/res/layout/name_edit_expansion_view.xml
new file mode 100644
index 0000000..4a7f364
--- /dev/null
+++ b/res/layout/name_edit_expansion_view.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2012 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.
+  -->
+
+<!-- "More" or "less" expansion button in the contact editor. -->
+
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="@dimen/editor_min_line_item_height"
+    android:layout_gravity="top"
+    android:contentDescription="@string/expand_collapse_name_fields_description"
+    android:importantForAccessibility="yes">
+    <ImageView
+        android:id="@+id/expansion_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:duplicateParentState="true"
+        android:background="?android:attr/selectableItemBackground"
+        android:paddingLeft="@dimen/editor_round_button_padding_left"
+        android:paddingRight="@dimen/editor_round_button_padding_right"
+        android:paddingTop="@dimen/editor_round_button_padding_top"
+        android:paddingBottom="@dimen/editor_round_button_padding_bottom" />
+</FrameLayout>
diff --git a/res/layout/phonetic_name_editor_view.xml b/res/layout/phonetic_name_editor_view.xml
new file mode 100644
index 0000000..4a4b64c
--- /dev/null
+++ b/res/layout/phonetic_name_editor_view.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<com.android.contacts.editor.PhoneticNameEditorView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:minHeight="@dimen/editor_min_line_item_height"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/spinner"
+        layout="@layout/edit_spinner"
+        android:visibility="gone" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:focusable="true"
+        android:clickable="true">
+
+        <include
+            android:id="@+id/editors"
+            layout="@layout/edit_field_list" />
+
+        <include
+            android:id="@+id/expansion_view_container"
+            layout="@layout/name_edit_expansion_view"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/delete_button_container"
+            layout="@layout/edit_delete_button"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+</com.android.contacts.editor.PhoneticNameEditorView>
diff --git a/res/layout/structured_name_editor_view.xml b/res/layout/structured_name_editor_view.xml
new file mode 100644
index 0000000..8b4a8ad
--- /dev/null
+++ b/res/layout/structured_name_editor_view.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<com.android.contacts.editor.StructuredNameEditorView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:minHeight="@dimen/editor_min_line_item_height"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/spinner"
+        layout="@layout/edit_spinner"
+        android:visibility="gone" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:focusable="true"
+        android:clickable="true">
+
+        <include
+            layout="@layout/edit_field_list_with_anchor_view" />
+
+        <include
+            android:id="@+id/expansion_view_container"
+            layout="@layout/name_edit_expansion_view"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/delete_button_container"
+            layout="@layout/edit_delete_button"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+</com.android.contacts.editor.StructuredNameEditorView>
diff --git a/res/layout/text_fields_editor_view.xml b/res/layout/text_fields_editor_view.xml
new file mode 100644
index 0000000..de49215
--- /dev/null
+++ b/res/layout/text_fields_editor_view.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2011 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.
+  -->
+
+<com.android.contacts.editor.TextFieldsEditorView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:focusable="true"
+        android:clickable="true">
+
+        <include
+            layout="@layout/edit_field_list_with_anchor_view" />
+
+        <include
+            android:id="@+id/expansion_view_container"
+            layout="@layout/edit_expansion_view"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/spinner"
+            layout="@layout/edit_spinner"
+            android:visibility="gone" />
+
+        <include
+            android:id="@+id/delete_button_container"
+            layout="@layout/edit_delete_button"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
+</com.android.contacts.editor.TextFieldsEditorView>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 4a4cea9..e72a0ee 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -19,4 +19,5 @@
     <dimen name="dialpad_digits_margin_bottom">50dip</dimen>
     <!-- Center vertically -->
     <dimen name="quick_contact_top_position">-1px</dimen>
+    <dimen name="editor_type_label_width">120dip</dimen>
 </resources>
diff --git a/res/values-sw580dp/dimens.xml b/res/values-sw580dp/dimens.xml
index ae507f9..3e55240 100644
--- a/res/values-sw580dp/dimens.xml
+++ b/res/values-sw580dp/dimens.xml
@@ -15,7 +15,9 @@
 -->
 <resources>
     <dimen name="editor_padding_top">32dip</dimen>
-
+    <dimen name="editor_round_button_padding_left">16dip</dimen>
+    <dimen name="editor_round_button_padding_right">16dip</dimen>
+    <dimen name="editor_type_label_width">122dip</dimen>
     <dimen name="editor_add_field_label_left_padding">16dip</dimen>
     <dimen name="detail_item_vertical_margin">16dip</dimen>
     <dimen name="detail_item_icon_margin">8dip</dimen>
diff --git a/res/values-sw680dp/dimens.xml b/res/values-sw680dp/dimens.xml
index 6353786..495526d 100644
--- a/res/values-sw680dp/dimens.xml
+++ b/res/values-sw680dp/dimens.xml
@@ -14,6 +14,9 @@
      limitations under the License.
 -->
 <resources>
+    <dimen name="editor_type_label_width">180dip</dimen>
+    <dimen name="editor_round_button_padding_left">8dip</dimen>
+    <dimen name="editor_round_button_padding_right">8dip</dimen>
     <dimen name="group_editor_side_padding">16dip</dimen>
     <dimen name="quick_contact_photo_container_height">360dip</dimen>
     <dimen name="contact_picker_contact_list_min_height">650dip</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 57c863d..598846a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -23,6 +23,24 @@
     <!-- Top padding of the entire contact editor  -->
     <dimen name="editor_padding_top">0dip</dimen>
 
+    <!-- Padding of the rounded plus/minus/expand/collapse buttons in the editor  -->
+    <dimen name="editor_round_button_padding_left">8dip</dimen>
+    <dimen name="editor_round_button_padding_right">8dip</dimen>
+    <dimen name="editor_round_button_padding_top">8dip</dimen>
+    <dimen name="editor_round_button_padding_bottom">8dip</dimen>
+
+    <!-- Minimum height of a row in the Editor -->
+    <dimen name="editor_min_line_item_height">48dip</dimen>
+
+    <!-- Right padding of a field in the Editor -->
+    <dimen name="editor_field_right_padding">4dip</dimen>
+
+    <!-- Left padding of a field in the Editor -->
+    <dimen name="editor_field_left_padding">4dip</dimen>
+
+    <!-- Width of the Type-Label in the Editor -->
+    <dimen name="editor_type_label_width">100dip</dimen>
+
     <!-- Left padding of the label in the add field button for the contact editor -->
     <dimen name="editor_add_field_label_left_padding">16dip</dimen>
 
diff --git a/src/com/android/contacts/activities/ConfirmAddDetailActivity.java b/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
index ae4cf94..fd12d7f 100644
--- a/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
+++ b/src/com/android/contacts/activities/ConfirmAddDetailActivity.java
@@ -60,6 +60,7 @@
 
 import com.android.contacts.R;
 import com.android.contacts.editor.Editor;
+import com.android.contacts.editor.EditorUiUtils;
 import com.android.contacts.editor.ViewIdGenerator;
 import com.android.contacts.common.model.AccountTypeManager;
 import com.android.contacts.model.RawContact;
@@ -700,7 +701,8 @@
      * to the end of mEditors
      */
     private void inflateEditorView(DataKind dataKind, ValuesDelta valuesDelta, RawContactDelta state) {
-        final View view = mInflater.inflate(dataKind.editorLayoutResourceId, mEditorContainerView,
+        final int layoutResId = EditorUiUtils.getLayoutResourceId(dataKind.mimeType);
+        final View view = mInflater.inflate(layoutResId, mEditorContainerView,
                 false);
 
         if (view instanceof Editor) {
diff --git a/src/com/android/contacts/editor/EditorUiUtils.java b/src/com/android/contacts/editor/EditorUiUtils.java
new file mode 100644
index 0000000..f3cf20a
--- /dev/null
+++ b/src/com/android/contacts/editor/EditorUiUtils.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package com.android.contacts.editor;
+
+import static android.provider.ContactsContract.CommonDataKinds.Event;
+import static android.provider.ContactsContract.CommonDataKinds.GroupMembership;
+import static android.provider.ContactsContract.CommonDataKinds.Photo;
+import static android.provider.ContactsContract.CommonDataKinds.StructuredName;
+
+import com.android.contacts.R;
+import com.android.contacts.common.model.dataitem.DataKind;
+import com.google.common.collect.Maps;
+
+import java.util.HashMap;
+
+/**
+ * Utility methods for creating contact editor.
+ */
+public class EditorUiUtils {
+
+    // Maps DataKind.mimeType to editor view layouts.
+    private static final HashMap<String, Integer> mimetypeLayoutMap = Maps.newHashMap();
+    static {
+        // Generally there should be a layout mapped to each existing DataKind mimetype but lots of
+        // them use the default text_fields_editor_view which we return as default so they don't
+        // need to be mapped.
+        //
+        // Other possible mime mappings are:
+        // DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME
+        // Nickname.CONTENT_ITEM_TYPE
+        // Email.CONTENT_ITEM_TYPE
+        // StructuredPostal.CONTENT_ITEM_TYPE
+        // Im.CONTENT_ITEM_TYPE
+        // Note.CONTENT_ITEM_TYPE
+        // Organization.CONTENT_ITEM_TYPE
+        // Phone.CONTENT_ITEM_TYPE
+        // SipAddress.CONTENT_ITEM_TYPE
+        // Website.CONTENT_ITEM_TYPE
+        // Relation.CONTENT_ITEM_TYPE
+        //
+        // Un-supported mime types need to mapped with -1.
+
+        mimetypeLayoutMap.put(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME,
+                R.layout.phonetic_name_editor_view);
+        mimetypeLayoutMap.put(StructuredName.CONTENT_ITEM_TYPE,
+                R.layout.structured_name_editor_view);
+        mimetypeLayoutMap.put(GroupMembership.CONTENT_ITEM_TYPE, -1);
+        mimetypeLayoutMap.put(Photo.CONTENT_ITEM_TYPE, -1);
+        mimetypeLayoutMap.put(Event.CONTENT_ITEM_TYPE, R.layout.event_field_editor_view);
+    }
+
+    /**
+     * Fetches a layout for a given mimetype.
+     *
+     * @param mimetype The mime type (e.g. StructuredName.CONTENT_ITEM_TYPE)
+     * @return The layout resource id.
+     */
+    public static int getLayoutResourceId(String mimetype) {
+        final Integer id = mimetypeLayoutMap.get(mimetype);
+        if (id == null) {
+            return R.layout.text_fields_editor_view;
+        }
+        return id;
+    }
+}
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index a119cb2..fb9c253 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -186,12 +186,13 @@
      */
     private View createEditorView(ValuesDelta entry) {
         final View view;
+        final int layoutResId = EditorUiUtils.getLayoutResourceId(mKind.mimeType);
         try {
-            view = mInflater.inflate(mKind.editorLayoutResourceId, mEditors, false);
+            view = mInflater.inflate(layoutResId, mEditors, false);
         } catch (Exception e) {
             throw new RuntimeException(
                     "Cannot allocate editor with layout resource ID " +
-                    mKind.editorLayoutResourceId + " for MIME type " + mKind.mimeType +
+                    layoutResId + " for MIME type " + mKind.mimeType +
                     " with error " + e.toString());
         }
 
diff --git a/tests/src/com/android/contacts/RawContactModifierTests.java b/tests/src/com/android/contacts/RawContactModifierTests.java
index 8008cd0..91358ca 100644
--- a/tests/src/com/android/contacts/RawContactModifierTests.java
+++ b/tests/src/com/android/contacts/RawContactModifierTests.java
@@ -91,14 +91,14 @@
                 this.accountType = TEST_ACCOUNT_TYPE;
 
                 final DataKind nameKind = new DataKind(StructuredName.CONTENT_ITEM_TYPE,
-                        R.string.nameLabelsGroup, -1, true, -1);
+                        R.string.nameLabelsGroup, -1, true);
                 nameKind.typeOverallMax = 1;
                 addKind(nameKind);
 
                 // Phone allows maximum 2 home, 1 work, and unlimited other, with
                 // constraint of 5 numbers maximum.
                 final DataKind phoneKind = new DataKind(
-                        Phone.CONTENT_ITEM_TYPE, -1, 10, true, -1);
+                        Phone.CONTENT_ITEM_TYPE, -1, 10, true);
 
                 phoneKind.typeOverallMax = 5;
                 phoneKind.typeColumn = Phone.TYPE;
@@ -115,24 +115,21 @@
                 addKind(phoneKind);
 
                 // Email is unlimited
-                final DataKind emailKind = new DataKind(
-                        Email.CONTENT_ITEM_TYPE, -1, 10, true, -1);
+                final DataKind emailKind = new DataKind(Email.CONTENT_ITEM_TYPE, -1, 10, true);
                 emailKind.typeOverallMax = -1;
                 emailKind.fieldList = Lists.newArrayList();
                 emailKind.fieldList.add(new EditField(Email.DATA, -1, -1));
                 addKind(emailKind);
 
                 // IM is only one
-                final DataKind imKind = new DataKind(Im.CONTENT_ITEM_TYPE, -1, 10,
-                        true, -1);
+                final DataKind imKind = new DataKind(Im.CONTENT_ITEM_TYPE, -1, 10, true);
                 imKind.typeOverallMax = 1;
                 imKind.fieldList = Lists.newArrayList();
                 imKind.fieldList.add(new EditField(Im.DATA, -1, -1));
                 addKind(imKind);
 
                 // Organization is only one
-                final DataKind orgKind = new DataKind(
-                        Organization.CONTENT_ITEM_TYPE, -1, 10, true, -1);
+                final DataKind orgKind = new DataKind(Organization.CONTENT_ITEM_TYPE, -1, 10, true);
                 orgKind.typeOverallMax = 1;
                 orgKind.fieldList = Lists.newArrayList();
                 orgKind.fieldList.add(new EditField(Organization.COMPANY, -1, -1));