1. Directly instantiate EditText instead of inflating 2. Remove a superfluous LinearLayout
Change-Id: Ic5903bd440a042c4b53fba92756e7b1c40140dfd
diff --git a/res/layout/item_contact_editor.xml b/res/layout/item_contact_editor.xml
index 57d641f..bcbb3ba 100644
--- a/res/layout/item_contact_editor.xml
+++ b/res/layout/item_contact_editor.xml
@@ -19,117 +19,108 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
+ android:orientation="vertical"
>
- <!-- The content -->
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical"
+ <!-- Account info header -->
+ <RelativeLayout android:id="@+id/header"
+ android:layout_height="64dip"
+ android:layout_width="match_parent"
>
- <!-- Account info header -->
- <RelativeLayout android:id="@+id/header"
- android:layout_height="64dip"
+ <ImageView android:id="@+id/header_color_bar"
android:layout_width="match_parent"
- >
+ android:layout_height="4dip"
+ android:layout_marginBottom="5dip"
+ android:background="@color/edit_divider"
+ />
- <ImageView android:id="@+id/header_color_bar"
- android:layout_width="match_parent"
- android:layout_height="4dip"
- android:layout_marginBottom="5dip"
- android:background="@color/edit_divider"
- />
-
- <ImageView android:id="@+id/header_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="7dip"
- android:layout_marginRight="7dip"
- android:layout_centerVertical="true"
- android:layout_below="@id/header_color_bar"
- />
-
- <TextView android:id="@+id/header_account_type"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/header_icon"
- android:layout_alignTop="@id/header_icon"
- android:layout_marginTop="-4dip"
-
- android:textSize="24sp"
- android:textColor="?android:attr/textColorPrimary"
- android:singleLine="true"
- />
-
- <TextView android:id="@+id/header_account_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/header_icon"
- android:layout_alignBottom="@+id/header_icon"
- android:layout_marginBottom="2dip"
-
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorPrimary"
- android:singleLine="true"
- />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:layout_alignParentBottom="true"
-
- android:background="?android:attr/listDivider"
- />
-
- </RelativeLayout>
-
- <FrameLayout
- android:id="@+id/stub_photo"
- android:layout_width="match_parent"
+ <ImageView android:id="@+id/header_icon"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="12dip"
- android:paddingTop="10dip">
+ android:layout_marginLeft="7dip"
+ android:layout_marginRight="7dip"
+ android:layout_centerVertical="true"
+ android:layout_below="@id/header_color_bar"
+ />
- <include
- android:id="@+id/edit_photo"
- layout="@layout/item_photo_editor" />
-
- </FrameLayout>
-
- <include
- android:id="@+id/edit_name"
- android:layout_width="match_parent"
+ <TextView android:id="@+id/header_account_type"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@id/stub_photo"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="4dip"
- layout="@layout/item_generic_editor" />
+ android:layout_toRightOf="@+id/header_icon"
+ android:layout_alignTop="@id/header_icon"
+ android:layout_marginTop="-4dip"
- <LinearLayout
- android:id="@+id/sect_fields"
- android:layout_width="match_parent"
+ android:textSize="24sp"
+ android:textColor="?android:attr/textColorPrimary"
+ android:singleLine="true"
+ />
+
+ <TextView android:id="@+id/header_account_name"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
+ android:layout_toRightOf="@+id/header_icon"
+ android:layout_alignBottom="@+id/header_icon"
+ android:layout_marginBottom="2dip"
+
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorPrimary"
+ android:singleLine="true"
/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_alignParentBottom="true"
+
android:background="?android:attr/listDivider"
/>
- <Button
- android:id="@+id/button_add_field"
- android:text="@string/add_field"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:layout_marginTop="10dip"
- />
- </LinearLayout>
+ </RelativeLayout>
+
+ <FrameLayout
+ android:id="@+id/stub_photo"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="12dip"
+ android:paddingTop="10dip">
+
+ <include
+ android:id="@+id/edit_photo"
+ layout="@layout/item_photo_editor" />
+
+ </FrameLayout>
+
+ <include
+ android:id="@+id/edit_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/stub_photo"
+ android:layout_marginTop="6dip"
+ android:layout_marginBottom="4dip"
+ layout="@layout/item_generic_editor" />
+
+ <LinearLayout
+ android:id="@+id/sect_fields"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_alignParentBottom="true"
+ android:background="?android:attr/listDivider"
+ />
+
+ <Button
+ android:id="@+id/button_add_field"
+ android:text="@string/add_field"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:layout_marginTop="10dip"
+ />
</com.android.contacts.ui.widget.ContactEditorView>
diff --git a/res/layout/item_editor_field.xml b/res/layout/item_editor_field.xml
deleted file mode 100644
index 9ad8689..0000000
--- a/res/layout/item_editor_field.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<EditText
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
diff --git a/src/com/android/contacts/ui/widget/GenericEditorView.java b/src/com/android/contacts/ui/widget/GenericEditorView.java
index 1a981a8..4656fe3 100644
--- a/src/com/android/contacts/ui/widget/GenericEditorView.java
+++ b/src/com/android/contacts/ui/widget/GenericEditorView.java
@@ -26,7 +26,6 @@
import com.android.contacts.model.ContactsSource.EditType;
import com.android.contacts.model.EntityDelta.ValuesDelta;
import com.android.contacts.ui.ViewIdGenerator;
-import com.android.contacts.util.ViewGroupAnimator;
import com.android.contacts.util.DialogManager;
import com.android.contacts.util.DialogManager.DialogShowingView;
@@ -67,7 +66,6 @@
*/
public class GenericEditorView extends RelativeLayout implements Editor, View.OnClickListener,
DialogShowingView {
- protected static final int RES_FIELD = R.layout.item_editor_field;
protected static final int RES_LABEL_ITEM = android.R.layout.simple_list_item_1;
private static final String DIALOG_ID_KEY = "dialog_id";
@@ -249,8 +247,9 @@
mFieldEditTexts = new EditText[kind.fieldList.size()];
for (int index = 0; index < kind.fieldList.size(); index++) {
final EditField field = kind.fieldList.get(index);
- // Inflate field from definition
- EditText fieldView = (EditText)mInflater.inflate(RES_FIELD, container, false);
+ final EditText fieldView = new EditText(mContext);
+ fieldView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.WRAP_CONTENT));
mFieldEditTexts[index] = fieldView;
fieldView.setId(vig.getId(state, kind, entry, index));
if (field.titleRes > 0) {