diff options
author | Andrew Lee <anwlee@google.com> | 2014-05-30 12:28:17 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-05-30 12:38:51 -0700 |
commit | 6fdf16941587a222f554482fb72531783a924b6e (patch) | |
tree | 55fba5f1949f7943752ccbbea06e78039be883ab /src/com/android | |
parent | 7a3f3a77dac05ed4135ab817e3ee7057aba1f182 (diff) | |
download | android_packages_apps_ContactsCommon-6fdf16941587a222f554482fb72531783a924b6e.tar.gz android_packages_apps_ContactsCommon-6fdf16941587a222f554482fb72531783a924b6e.tar.bz2 android_packages_apps_ContactsCommon-6fdf16941587a222f554482fb72531783a924b6e.zip |
Match contact list items to redlines for Dialer.
- Add text offset top functionality in the pinned header and
headers. In the pinned header this was done with padding, because
the pinned header is a (assumeedly vertically centered) child and
then the parent doesn't need to be privy to these details.
- Update width and font size. I imagine we want these changes to
be consistent between Dialer and Contacts, which is why this was
done here instead of in Dialer.
Bug: 15332945
Change-Id: If2ebf8117f528316b256a86ed9922f917e9c75ae
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/contacts/common/list/ContactListItemView.java | 15 | ||||
-rw-r--r-- | src/com/android/contacts/common/list/ContactListPinnedHeaderView.java | 10 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/contacts/common/list/ContactListItemView.java b/src/com/android/contacts/common/list/ContactListItemView.java index af094ebc..da452cf3 100644 --- a/src/com/android/contacts/common/list/ContactListItemView.java +++ b/src/com/android/contacts/common/list/ContactListItemView.java @@ -141,7 +141,6 @@ public class ContactListItemView extends ViewGroup private PhotoPosition mPhotoPosition = getDefaultPhotoPosition(false /* normal/non opposite */); // Header layout data - private int mHeaderBackgroundHeight; private TextView mHeaderTextView; private boolean mIsSectionHeaderEnabled; @@ -440,8 +439,7 @@ public class ContactListItemView extends ViewGroup if (mHeaderTextView != null && mHeaderTextView.getVisibility() == VISIBLE) { mHeaderTextView.measure( MeasureSpec.makeMeasureSpec(mHeaderWidth, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - mHeaderBackgroundHeight = Math.min(height, mHeaderTextView.getMeasuredHeight()); + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); } setMeasuredDimension(specWidth, height); @@ -463,11 +461,14 @@ public class ContactListItemView extends ViewGroup // Put the section header on the left side of the contact view. if (mIsSectionHeaderEnabled) { if (mHeaderTextView != null) { + int headerHeight = mHeaderTextView.getMeasuredHeight(); + int headerTopBound = (bottomBound + topBound - headerHeight) / 2 + mTextOffsetTop; + mHeaderTextView.layout( isLayoutRtl ? rightBound - mHeaderWidth : leftBound, - topBound, + headerTopBound, isLayoutRtl ? rightBound : leftBound + mHeaderWidth, - mHeaderBackgroundHeight); + headerTopBound + headerHeight); } if (isLayoutRtl) { rightBound -= mHeaderWidth; @@ -717,8 +718,8 @@ public class ContactListItemView extends ViewGroup if (mHeaderTextView == null) { mHeaderTextView = new TextView(getContext()); mHeaderTextView.setTextAppearance(getContext(), R.style.SectionHeaderStyle); - mHeaderTextView.setGravity(Gravity.CENTER_VERTICAL | - (ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT)); + mHeaderTextView.setGravity( + ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT); addView(mHeaderTextView); } setMarqueeText(mHeaderTextView, title); diff --git a/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java b/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java index e0c3e1a4..30bd1e11 100644 --- a/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java +++ b/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java @@ -40,6 +40,8 @@ public class ContactListPinnedHeaderView extends TextView { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView); int backgroundColor = a.getColor( R.styleable.ContactListItemView_list_item_background_color, Color.WHITE); + int textOffsetTop = a.getDimensionPixelSize( + R.styleable.ContactListItemView_list_item_text_offset_top, 0); a.recycle(); setBackgroundColor(backgroundColor); @@ -49,6 +51,14 @@ public class ContactListPinnedHeaderView extends TextView { LayoutParams.WRAP_CONTENT)); setGravity(Gravity.CENTER_VERTICAL | (ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT)); + + // Apply text top offset. Multiply by two, because we are implementing this by padding for a + // vertically centered view, rather than adjusting the position directly via a layout. + setPaddingRelative( + getPaddingStart(), + getPaddingTop() + (textOffsetTop * 2), + getPaddingEnd(), + getPaddingBottom()); } /** |