Alignment tweaks in contact editor

- Multi-line address edit text field should now be
aligned with the spinner beside it

- Other misc alignment fixes

Bug: 5250070

Change-Id: I92b4b0d13cd1346227b95e7326a1c37ec68b066d
diff --git a/res/layout/edit_delete_button.xml b/res/layout/edit_delete_button.xml
index 32b0580..9a9a377 100644
--- a/res/layout/edit_delete_button.xml
+++ b/res/layout/edit_delete_button.xml
@@ -21,7 +21,7 @@
     android:layout_width="wrap_content"
     android:layout_height="@dimen/editor_min_line_item_height"
     android:layout_marginRight="2dip"
-    android:layout_gravity="top">
+    android:layout_gravity="bottom">
     <ImageView
         android:id="@+id/delete_button"
         android:layout_width="wrap_content"
diff --git a/res/layout/edit_spinner.xml b/res/layout/edit_spinner.xml
index b986913..99764da 100644
--- a/res/layout/edit_spinner.xml
+++ b/res/layout/edit_spinner.xml
@@ -20,7 +20,7 @@
 <Spinner
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/spinner"
-    android:layout_gravity="top"
+    android:layout_gravity="bottom"
     android:layout_width="@dimen/editor_type_label_width"
     android:layout_height="@dimen/editor_min_line_item_height"
     android:paddingLeft="0dip"
diff --git a/res/layout/item_group_membership.xml b/res/layout/item_group_membership.xml
index 57eda71..47f99b2 100644
--- a/res/layout/item_group_membership.xml
+++ b/res/layout/item_group_membership.xml
@@ -27,12 +27,12 @@
         style="?android:attr/spinnerStyle"
         android:id="@+id/group_list"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/editor_min_line_item_height"
+        android:layout_height="wrap_content"
+        android:minHeight="@dimen/editor_min_line_item_height"
         android:layout_marginLeft="@dimen/editor_field_left_padding"
         android:layout_marginRight="@dimen/editor_field_left_padding"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:gravity="left|center_vertical"
-        android:ellipsize="end"
         android:focusable="true"
         android:paddingLeft="12dip" />
 
diff --git a/res/values-sw580dp/dimens.xml b/res/values-sw580dp/dimens.xml
index 3824248..77315fc 100644
--- a/res/values-sw580dp/dimens.xml
+++ b/res/values-sw580dp/dimens.xml
@@ -18,7 +18,7 @@
     <dimen name="editor_type_label_width">122dip</dimen>
     <dimen name="editor_round_button_padding_left">16dip</dimen>
     <dimen name="editor_round_button_padding_right">16dip</dimen>
-    <dimen name="editor_add_field_label_left_padding">24dip</dimen>
+    <dimen name="editor_add_field_label_left_padding">16dip</dimen>
     <dimen name="detail_item_side_margin">0dip</dimen>
     <dimen name="detail_item_vertical_margin">16dip</dimen>
     <dimen name="detail_item_icon_margin">8dip</dimen>
diff --git a/res/values-w470dp/dimens.xml b/res/values-w470dp/dimens.xml
index 7da25d7..c457147 100644
--- a/res/values-w470dp/dimens.xml
+++ b/res/values-w470dp/dimens.xml
@@ -16,4 +16,5 @@
 <resources>
     <!-- Center vertically -->
     <dimen name="quick_contact_top_position">-1px</dimen>
+    <dimen name="editor_type_label_width">120dip</dimen>
 </resources>
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index a4ad53a..062c25d 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -176,6 +176,13 @@
             final EditText fieldView = new EditText(mContext);
             fieldView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                     field.isMultiLine() ? LayoutParams.WRAP_CONTENT : mMinFieldHeight));
+            // Set either a minimum line requirement or a minimum height (because {@link TextView}
+            // only takes one or the other at a single time).
+            if (field.minLines != 0) {
+                fieldView.setMinLines(field.minLines);
+            } else {
+                fieldView.setMinHeight(mMinFieldHeight);
+            }
             fieldView.setTextAppearance(getContext(), kind.textAppearanceResourceId);
             fieldView.setGravity(Gravity.TOP);
             mFieldEditTexts[index] = fieldView;
@@ -188,7 +195,6 @@
             if (inputType == InputType.TYPE_CLASS_PHONE) {
                 PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(mContext, fieldView);
             }
-            fieldView.setMinLines(field.minLines);
 
             // Read current value from state
             final String column = field.column;
diff --git a/src/com/android/contacts/model/BaseAccountType.java b/src/com/android/contacts/model/BaseAccountType.java
index dae09b2..e6c0400 100644
--- a/src/com/android/contacts/model/BaseAccountType.java
+++ b/src/com/android/contacts/model/BaseAccountType.java
@@ -279,7 +279,7 @@
         kind.fieldList = Lists.newArrayList();
         kind.fieldList.add(
                 new EditField(StructuredPostal.FORMATTED_ADDRESS, R.string.postal_address,
-                        FLAGS_POSTAL).setMinLines(1));
+                        FLAGS_POSTAL));
 
         return kind;
     }