diff options
author | Tingting Wang <tingtingw@google.com> | 2015-07-24 17:04:35 -0700 |
---|---|---|
committer | Tingting Wang <tingtingw@google.com> | 2015-08-07 14:24:54 -0700 |
commit | df65d168660ce7ebd4961335e3363eb7c267e0c6 (patch) | |
tree | a4f511fa9fa952263bd844770cbd1f1012ac7188 /src/com/android/contacts/widget | |
parent | 1d19a07535e427e22c71dae109587061d34ef697 (diff) | |
download | Contacts-df65d168660ce7ebd4961335e3363eb7c267e0c6.tar.gz |
Place phonetic name under display name in QuickContact.
Set phonetic name a smaller font size than display name.
BUG 22235947
Change-Id: I7d021ea8f6cc1a88c32eaccfa6ed7fe2cc2b9eb4
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r-- | src/com/android/contacts/widget/MultiShrinkScroller.java | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java index 7c46a86c9..95f277ce9 100644 --- a/src/com/android/contacts/widget/MultiShrinkScroller.java +++ b/src/com/android/contacts/widget/MultiShrinkScroller.java @@ -108,6 +108,8 @@ public class MultiShrinkScroller extends FrameLayout { private View mTransparentView; private MultiShrinkScrollerListener mListener; private TextView mLargeTextView; + private TextView mPhoneticNameView; + private View mTitleAndPhoneticNameView; private View mPhotoTouchInterceptOverlay; /** Contains desired size & vertical offset of the title, once the header is fully compressed */ private TextView mInvisiblePlaceholderTextView; @@ -289,6 +291,8 @@ public class MultiShrinkScroller extends FrameLayout { mPhotoViewContainer = findViewById(R.id.toolbar_parent); mTransparentView = findViewById(R.id.transparent_view); mLargeTextView = (TextView) findViewById(R.id.large_title); + mPhoneticNameView = (TextView) findViewById(R.id.phonetic_name); + mTitleAndPhoneticNameView = findViewById(R.id.title_and_phonetic_name); mInvisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview); mStartColumn = findViewById(R.id.empty_start_column); // Touching the empty space should close the card @@ -339,7 +343,7 @@ public class MultiShrinkScroller extends FrameLayout { mMaximumPortraitHeaderHeight = mIsTwoPanel ? getHeight() : mPhotoViewContainer.getWidth(); setHeaderHeight(getMaximumScrollableHeaderHeight()); - mMaximumHeaderTextSize = mLargeTextView.getHeight(); + mMaximumHeaderTextSize = mTitleAndPhoneticNameView.getHeight(); if (mIsTwoPanel) { mMaximumHeaderHeight = getHeight(); mMinimumHeaderHeight = mMaximumHeaderHeight; @@ -354,16 +358,19 @@ public class MultiShrinkScroller extends FrameLayout { // Permanently set title width and margin. final FrameLayout.LayoutParams largeTextLayoutParams - = (FrameLayout.LayoutParams) mLargeTextView.getLayoutParams(); + = (FrameLayout.LayoutParams) mTitleAndPhoneticNameView + .getLayoutParams(); largeTextLayoutParams.width = photoLayoutParams.width - largeTextLayoutParams.leftMargin - largeTextLayoutParams.rightMargin; largeTextLayoutParams.gravity = Gravity.BOTTOM | Gravity.START; - mLargeTextView.setLayoutParams(largeTextLayoutParams); + mTitleAndPhoneticNameView.setLayoutParams(largeTextLayoutParams); } else { // Set the width of mLargeTextView as if it was nested inside // mPhotoViewContainer. mLargeTextView.setWidth(mPhotoViewContainer.getWidth() - 2 * mMaximumTitleMargin); + mPhoneticNameView.setWidth(mPhotoViewContainer.getWidth() + - 2 * mMaximumTitleMargin); } calculateCollapsedLargeTitlePadding(); @@ -382,8 +389,8 @@ public class MultiShrinkScroller extends FrameLayout { = (FrameLayout.LayoutParams) mTitleGradientView.getLayoutParams(); final float TITLE_GRADIENT_SIZE_COEFFICIENT = 1.25f; final FrameLayout.LayoutParams largeTextLayoutParms - = (FrameLayout.LayoutParams) mLargeTextView.getLayoutParams(); - titleGradientLayoutParams.height = (int) ((mLargeTextView.getHeight() + = (FrameLayout.LayoutParams) mTitleAndPhoneticNameView.getLayoutParams(); + titleGradientLayoutParams.height = (int) ((mTitleAndPhoneticNameView.getHeight() + largeTextLayoutParms.bottomMargin) * TITLE_GRADIENT_SIZE_COEFFICIENT); mTitleGradientView.setLayoutParams(titleGradientLayoutParams); } @@ -393,6 +400,20 @@ public class MultiShrinkScroller extends FrameLayout { mPhotoTouchInterceptOverlay.setContentDescription(title); } + public void setPhoneticName(String phoneticName) { + mPhoneticNameView.setText(phoneticName); + // Every time the phonetic name is changed, set mPhoneticNameView as visible, + // in case it just changed from Visibility=GONE. + mPhoneticNameView.setVisibility(View.VISIBLE); + initialize(mListener, mIsOpenContactSquare); + } + + public void setPhoneticNameGone() { + mPhoneticNameView.setVisibility(View.GONE); + // Initialize to make Visibility work. + initialize(mListener, mIsOpenContactSquare); + } + @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (mVelocityTracker == null) { @@ -993,19 +1014,19 @@ public class MultiShrinkScroller extends FrameLayout { // The pivot point for scaling should be middle of the starting side. if (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { - mLargeTextView.setPivotX(mLargeTextView.getWidth()); + mTitleAndPhoneticNameView.setPivotX(mTitleAndPhoneticNameView.getWidth()); } else { - mLargeTextView.setPivotX(0); + mTitleAndPhoneticNameView.setPivotX(0); } - mLargeTextView.setPivotY(mLargeTextView.getHeight() / 2); + mTitleAndPhoneticNameView.setPivotY(mTitleAndPhoneticNameView.getHeight() / 2); final int toolbarHeight = mToolbar.getLayoutParams().height; mPhotoTouchInterceptOverlay.setClickable(toolbarHeight != mMaximumHeaderHeight); if (toolbarHeight >= mMaximumHeaderHeight) { // Everything is full size when the header is fully expanded. - mLargeTextView.setScaleX(1); - mLargeTextView.setScaleY(1); + mTitleAndPhoneticNameView.setScaleX(1); + mTitleAndPhoneticNameView.setScaleY(1); setInterpolatedTitleMargins(1); return; } @@ -1022,13 +1043,13 @@ public class MultiShrinkScroller extends FrameLayout { bezierOutput = (float) Math.min(bezierOutput, 1.0f); scale = (float) Math.min(scale, 1.0f); - mLargeTextView.setScaleX(scale); - mLargeTextView.setScaleY(scale); + mTitleAndPhoneticNameView.setScaleX(scale); + mTitleAndPhoneticNameView.setScaleY(scale); setInterpolatedTitleMargins(bezierOutput); } /** - * Calculate the padding around mLargeTextView so that it will look appropriate once it + * Calculate the padding around mTitleAndPhoneticNameView so that it will look appropriate once it * finishes moving into its target location/size. */ private void calculateCollapsedLargeTitlePadding() { @@ -1040,9 +1061,10 @@ public class MultiShrinkScroller extends FrameLayout { final int desiredTopToCenter = invisiblePlaceHolderLocation[1] + mInvisiblePlaceholderTextView.getHeight() / 2 - largeTextViewRectLocation[1]; - // Padding needed on the mLargeTextView so that it has the same amount of + // Padding needed on the mTitleAndPhoneticNameView so that it has the same amount of // padding as the target rectangle. - mCollapsedTitleBottomMargin = desiredTopToCenter - mLargeTextView.getHeight() / 2; + mCollapsedTitleBottomMargin = + desiredTopToCenter - mTitleAndPhoneticNameView.getHeight() / 2; } /** @@ -1051,7 +1073,7 @@ public class MultiShrinkScroller extends FrameLayout { */ private void setInterpolatedTitleMargins(float x) { final FrameLayout.LayoutParams titleLayoutParams - = (FrameLayout.LayoutParams) mLargeTextView.getLayoutParams(); + = (FrameLayout.LayoutParams) mTitleAndPhoneticNameView.getLayoutParams(); final LinearLayout.LayoutParams toolbarLayoutParams = (LinearLayout.LayoutParams) mToolbar.getLayoutParams(); @@ -1064,14 +1086,14 @@ public class MultiShrinkScroller extends FrameLayout { final int pretendBottomMargin = (int) (mCollapsedTitleBottomMargin * (1 - x) + mMaximumTitleMargin * x) ; // Calculate how offset the title should be from the top of the screen. Instead of - // calling mLargeTextView.getHeight() use the mMaximumHeaderTextSize for this calculation. - // The getHeight() value acts unexpectedly when mLargeTextView is partially clipped by - // its parent. + // calling mTitleAndPhoneticNameView.getHeight() use the mMaximumHeaderTextSize for this + // calculation. The getHeight() value acts unexpectedly when mTitleAndPhoneticNameView is + // partially clipped by its parent. titleLayoutParams.topMargin = getTransparentViewHeight() + toolbarLayoutParams.height - pretendBottomMargin - mMaximumHeaderTextSize; titleLayoutParams.bottomMargin = 0; - mLargeTextView.setLayoutParams(titleLayoutParams); + mTitleAndPhoneticNameView.setLayoutParams(titleLayoutParams); } private void updatePhotoTintAndDropShadow() { |