Fix several layout issues
Bug:3135594
Bug:3158860
Change-Id: I2d592afb2cfc8aaf2f00aca38c9d123719bcb8bc
diff --git a/res/layout-xlarge/contact_detail_fragment.xml b/res/layout-xlarge/contact_detail_fragment.xml
index b01789e..8a3e003 100644
--- a/res/layout-xlarge/contact_detail_fragment.xml
+++ b/res/layout-xlarge/contact_detail_fragment.xml
@@ -68,7 +68,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
ex:layout_wideParentWidth="800dip"
- ex:layout_wideLeftMargin="124dip"
+ ex:layout_wideLeftMargin="80dip"
ex:layout_wideRightMargin="64dip"
ex:layout_narrowParentWidth="500dip"
ex:layout_narrowLeftMargin="32dip"
diff --git a/res/layout-xlarge/contact_detail_list_item.xml b/res/layout-xlarge/contact_detail_list_item.xml
index 8de118c..7729973 100644
--- a/res/layout-xlarge/contact_detail_list_item.xml
+++ b/res/layout-xlarge/contact_detail_list_item.xml
@@ -22,21 +22,16 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
- android:paddingLeft="9dip"
+ android:paddingLeft="18dip"
android:gravity="center_vertical"
>
<TextView android:id="@+id/kind"
- android:layout_width="120dip"
+ android:layout_width="150dip"
android:layout_height="wrap_content"
android:textColor="#7F7F7F"
android:textAppearance="?android:attr/textAppearanceSmall"
- />
-
- <TextView android:id="@+id/type"
- android:layout_width="100dip"
- android:layout_height="wrap_content"
- android:textColor="#999999"
- android:textAppearance="?android:attr/textAppearanceLarge"
+ android:singleLine="true"
+ android:ellipsize="marquee"
/>
<TextView android:id="@+id/data"
@@ -48,6 +43,13 @@
android:textAppearance="?android:attr/textAppearanceLarge"
/>
+ <TextView android:id="@+id/type"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:textColor="#999999"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
<ImageView android:id="@+id/primary_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-xlarge/item_contact_editor.xml b/res/layout-xlarge/item_contact_editor.xml
index 30021f8..93da517 100644
--- a/res/layout-xlarge/item_contact_editor.xml
+++ b/res/layout-xlarge/item_contact_editor.xml
@@ -95,7 +95,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
ex:layout_wideParentWidth="960dip"
- ex:layout_wideLeftMargin="128dip"
+ ex:layout_wideLeftMargin="96dip"
ex:layout_narrowParentWidth="800dip"
ex:layout_narrowLeftMargin="15dip"
>
@@ -115,11 +115,11 @@
android:layout_height="wrap_content"
android:orientation="vertical"
ex:layout_wideParentWidth="960dip"
- ex:layout_wideLeftMargin="230dip"
- ex:layout_wideRightMargin="50dip"
+ ex:layout_wideLeftMargin="96dip"
+ ex:layout_wideRightMargin="96dip"
ex:layout_narrowParentWidth="800dip"
- ex:layout_narrowLeftMargin="160dip"
- ex:layout_narrowRightMargin="50dip"
+ ex:layout_narrowLeftMargin="15dip"
+ ex:layout_narrowRightMargin="15dip"
>
<com.android.contacts.views.editor.TextFieldsEditorView
diff --git a/res/layout-xlarge/item_group_membership.xml b/res/layout-xlarge/item_group_membership.xml
index 9914508..70068d7 100644
--- a/res/layout-xlarge/item_group_membership.xml
+++ b/res/layout-xlarge/item_group_membership.xml
@@ -25,10 +25,11 @@
<TextView
android:id="@+id/kind_title"
- android:layout_width="100dip"
+ android:layout_width="150dip"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
+ android:textColor="@color/editor_label_text_color"
android:ellipsize="marquee" />
<TextView
diff --git a/res/layout-xlarge/item_kind_section.xml b/res/layout-xlarge/item_kind_section.xml
index 9ab5d97..3b0d668 100644
--- a/res/layout-xlarge/item_kind_section.xml
+++ b/res/layout-xlarge/item_kind_section.xml
@@ -24,9 +24,10 @@
<TextView
android:id="@+id/kind_title"
- android:layout_width="100dip"
+ android:layout_width="150dip"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#7F7F7F"
+ android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:ellipsize="marquee" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index cea3573..f06f107 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -35,4 +35,6 @@
<!-- Color used as a selected background for the account/group selection widget -->
<color name="filter_selector_selected_background">#66ffffff</color>
+ <!-- Color used for the label (type) in the editor -->
+ <color name="editor_label_text_color">#FF7F7F7F</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d92154c..e010713 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -45,5 +45,5 @@
<dimen name="editor_round_button_padding_bottom">10dip</dimen>
<!-- Width of the Type-Label in the Editor -->
- <dimen name="editor_type_label_width">150dip</dimen>
+ <dimen name="editor_type_label_width">180dip</dimen>
</resources>
diff --git a/src/com/android/contacts/views/detail/ContactDetailFragment.java b/src/com/android/contacts/views/detail/ContactDetailFragment.java
index fc9e78d..540af08 100644
--- a/src/com/android/contacts/views/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/views/detail/ContactDetailFragment.java
@@ -556,7 +556,8 @@
sb.append(groups.get(i));
}
entry.mimetype = GroupMembership.MIMETYPE;
- entry.kind = mContext.getString(R.string.groupsLabel);
+ entry.kind = mContext.getString(R.string.groupsLabel).toUpperCase();
+ entry.kindAndType = entry.kind;
entry.data = sb.toString();
mGroupEntries.add(entry);
}
@@ -817,7 +818,11 @@
// Set the label. This is either a combination field or separate fields for kind of type
if (views.kindAndType != null) views.kindAndType.setText(entry.kindAndType);
if (views.kind != null) views.kind.setText(isFirstOfItsKind ? entry.kind : "");
- if (views.type != null) views.type.setText(entry.typeString);
+ if (views.type != null) {
+ final String typeString = entry.typeString;
+ views.type.setText(typeString);
+ views.type.setVisibility(TextUtils.isEmpty(typeString) ? View.GONE : View.VISIBLE);
+ }
// Set the content
final TextView content = views.data;
diff --git a/src/com/android/contacts/views/editor/EventFieldEditorView.java b/src/com/android/contacts/views/editor/EventFieldEditorView.java
index 46afc62..a8c01b6 100644
--- a/src/com/android/contacts/views/editor/EventFieldEditorView.java
+++ b/src/com/android/contacts/views/editor/EventFieldEditorView.java
@@ -74,9 +74,10 @@
// Fields
// Subtract buttons left and right if necessary
- final int l2 = (getLabel() != null) ? l1 + getLabel().getMeasuredWidth() : l1;
- final int r2 = r1 - ((getDelete() != null) ? getDelete().getMeasuredWidth() : 0);
- if (mDateView != null) mDateView.layout(l2, t1, r2, b1);
+ final int labelWidth = (getLabel() != null) ? getLabel().getMeasuredWidth() : 0;
+ final int deleteWidth = (getDelete() != null) ? getDelete().getMeasuredWidth() : 0;
+ final int r2 = r1 - deleteWidth - labelWidth;
+ if (mDateView != null) mDateView.layout(l1, t1, r2, b1);
}
@Override
diff --git a/src/com/android/contacts/views/editor/GroupMembershipView.java b/src/com/android/contacts/views/editor/GroupMembershipView.java
index ec1fb51..206f7b5 100644
--- a/src/com/android/contacts/views/editor/GroupMembershipView.java
+++ b/src/com/android/contacts/views/editor/GroupMembershipView.java
@@ -100,7 +100,7 @@
public void setKind(DataKind kind) {
mKind = kind;
TextView kindTitle = (TextView) findViewById(R.id.kind_title);
- kindTitle.setText(kind.titleRes);
+ kindTitle.setText(getResources().getString(kind.titleRes).toUpperCase());
}
public void setGroupMetaData(Cursor groupMetaData) {
diff --git a/src/com/android/contacts/views/editor/KindSectionView.java b/src/com/android/contacts/views/editor/KindSectionView.java
index e292cbf..7aaefdd 100644
--- a/src/com/android/contacts/views/editor/KindSectionView.java
+++ b/src/com/android/contacts/views/editor/KindSectionView.java
@@ -97,7 +97,10 @@
setId(mViewIdGenerator.getId(state, kind, null, ViewIdGenerator.NO_VIEW_INDEX));
// TODO: handle resources from remote packages
- mTitle.setText(kind.titleRes);
+ final String title = (kind.titleRes == -1 || kind.titleRes == 0)
+ ? null
+ : getResources().getString(kind.titleRes);
+ mTitle.setText(title == null ? "" : title.toUpperCase());
// Only show the add button if this is a list
mAddPlusButton.setVisibility(mKind.isList ? View.VISIBLE : View.INVISIBLE);
diff --git a/src/com/android/contacts/views/editor/LabeledEditorView.java b/src/com/android/contacts/views/editor/LabeledEditorView.java
index 5f695a6..3b9312f 100644
--- a/src/com/android/contacts/views/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/views/editor/LabeledEditorView.java
@@ -34,6 +34,7 @@
import android.content.res.Resources;
import android.os.Bundle;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -89,27 +90,26 @@
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// Subtract padding from the borders ==> x1 variables
- int l1 = getPaddingLeft();
int t1 = getPaddingTop();
int r1 = getMeasuredWidth() - getPaddingRight();
int b1 = getMeasuredHeight() - getPaddingBottom();
- // Label Button
- final boolean hasLabel = mLabel != null;
-
- if (hasLabel) {
- mLabel.layout(
- l1, t1,
- l1 + mLabel.getMeasuredWidth(), t1 + mLabel.getMeasuredHeight());
- }
-
- // Delete Button
- final boolean hasDelete = mDelete != null;
- if (hasDelete) {
+ final int r2;
+ if (mDelete != null) {
+ r2 = r1 - mDelete.getMeasuredWidth();
mDelete.layout(
- r1 - mDelete.getMeasuredWidth(), b1 - mDelete.getMeasuredHeight(),
+ r2, b1 - mDelete.getMeasuredHeight(),
r1, b1);
+ } else {
+ r2 = r1;
}
+
+ if (mLabel != null) {
+ mLabel.layout(
+ r2 - mLabel.getMeasuredWidth(), t1,
+ r2, t1 + mLabel.getMeasuredHeight());
+ }
+
}
@Override
@@ -134,11 +134,13 @@
*/
private void setupLabelButton(boolean shouldExist) {
if (shouldExist && mLabel == null) {
- mLabel = new Button(mContext);
+ mLabel = new Button(mContext, null, android.R.attr.textAppearanceSmall);
mLabel.setBackgroundResource(R.drawable.type_selector_background);
final int width =
mContext.getResources().getDimensionPixelSize(R.dimen.editor_type_label_width);
mLabel.setLayoutParams(new LayoutParams(width, LayoutParams.WRAP_CONTENT));
+ mLabel.setGravity(Gravity.RIGHT);
+ mLabel.setTextColor(getResources().getColor(R.color.editor_label_text_color));
mLabel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/com/android/contacts/views/editor/TextFieldsEditorView.java b/src/com/android/contacts/views/editor/TextFieldsEditorView.java
index 13492ac..2dd9a4f 100644
--- a/src/com/android/contacts/views/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/views/editor/TextFieldsEditorView.java
@@ -69,29 +69,27 @@
int l1 = getPaddingLeft();
int t1 = getPaddingTop();
int r1 = getMeasuredWidth() - getPaddingRight();
- int b1 = getMeasuredHeight() - getPaddingBottom();
- // MoreOrLess Button
- final boolean hasMoreOrLess = mMoreOrLess != null;
- if (hasMoreOrLess) {
+ if ((mMoreOrLess != null)) {
mMoreOrLess.layout(
- r1 - mMoreOrLess.getMeasuredWidth(), b1 - mMoreOrLess.getMeasuredHeight(),
- r1, b1);
+ r1 - mMoreOrLess.getMeasuredWidth(), t1,
+ r1, t1 + mMoreOrLess.getMeasuredHeight());
}
- // Fields
- // Subtract buttons left and right if necessary
- final int l2 = (getLabel() != null) ? l1 + getLabel().getMeasuredWidth() : l1;
- final int r2 = r1 - Math.max(
- (getDelete() != null) ? getDelete().getMeasuredWidth() : 0,
- hasMoreOrLess ? mMoreOrLess.getMeasuredWidth() : 0);
+ // Subtract buttons if necessary
+ final int labelWidth = (getLabel() != null) ? getLabel().getMeasuredWidth() : 0;
+ final int deleteWidth = (getDelete() != null) ? getDelete().getMeasuredWidth() : 0;
+ final int moreOrLessWidth = mMoreOrLess != null ? mMoreOrLess.getMeasuredWidth() : 0;
+ final int r2 = r1 - Math.max(deleteWidth, moreOrLessWidth) - labelWidth;
+
+ // Layout text fields
int y = t1;
if (mFieldEditTexts != null) {
for (EditText editText : mFieldEditTexts) {
if (editText.getVisibility() != View.GONE) {
int height = editText.getMeasuredHeight();
editText.layout(
- l2, t1 + y,
+ l1, t1 + y,
r2, t1 + y + height);
y += height;
}
@@ -110,10 +108,10 @@
}
}
}
- // Ensure there is enough space for the minus button
- if (mMoreOrLess != null) {
- result = Math.max(mMoreOrLess.getMeasuredHeight(), result);
- }
+ // Ensure there is enough space for the minus and more/less button
+ final int deleteHeight = (getDelete() != null) ? getDelete().getMeasuredHeight() : 0;
+ final int moreOrLessHeight = mMoreOrLess != null ? mMoreOrLess.getMeasuredHeight() : 0;
+ result = Math.max(deleteHeight + moreOrLessHeight, result);
return result;
}
@@ -160,9 +158,7 @@
// find first visible child
newFocusView = TextFieldsEditorView.this;
}
- if (newFocusView != null) {
- newFocusView.requestFocus();
- }
+ newFocusView.requestFocus();
}
});
addView(mMoreOrLess);
@@ -359,6 +355,7 @@
out.writeIntArray(mVisibilities);
}
+ @SuppressWarnings({"unused", "hiding" })
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
@Override