From 916ed1bc84f63efd9ed6c3a3166bc013dfe65f9d Mon Sep 17 00:00:00 2001 From: Stephen Bird Date: Tue, 9 Feb 2016 16:33:23 -0800 Subject: (2/2) T9 cleanup We can remove the changes we made to ContactListItemView since we are now using the adapter to auto-merge multiple mimetype items. This fixes ripples and let's us clean up quite a bit on the app side of things Ticket: CD-370 CD-339 CD-359 CD-385 CD-384 CD-380 CD-378 CD-372 Change-Id: I929957720cb836bfbe9bf5be187ce8d7df8a1b1c --- .../contacts/common/list/ContactListItemView.java | 73 +--------------------- .../common/list/PhoneNumberListAdapter.java | 50 +++++++-------- .../common/list/PhoneNumberPickerFragment.java | 5 -- 3 files changed, 23 insertions(+), 105 deletions(-) (limited to 'src/com') diff --git a/src/com/android/contacts/common/list/ContactListItemView.java b/src/com/android/contacts/common/list/ContactListItemView.java index d8c42ad5..7916e636 100644 --- a/src/com/android/contacts/common/list/ContactListItemView.java +++ b/src/com/android/contacts/common/list/ContactListItemView.java @@ -163,7 +163,6 @@ public class ContactListItemView extends ViewGroup private TextView mPhoneticNameTextView; private TextView mLabelView; private TextView mDataView; - private TextView mCallProviderView; private TextView mSnippetView; private TextView mStatusView; private ImageView mPresenceIcon; @@ -206,8 +205,6 @@ public class ContactListItemView extends ViewGroup private int mPhoneticNameTextViewHeight; private int mLabelViewHeight; private int mDataViewHeight; - private int mCallProviderViewHeight; - private int mCallProviderBottomPadding; private int mSnippetTextViewHeight; private int mStatusTextViewHeight; private int mCheckBoxHeight; @@ -340,8 +337,6 @@ public class ContactListItemView extends ViewGroup mStatusTextViewHeight = 0; mCheckBoxWidth = 0; mCheckBoxHeight = 0; - mCallProviderViewHeight = 0; - mCallProviderBottomPadding = 0; ensurePhotoViewSize(); @@ -420,17 +415,6 @@ public class ContactListItemView extends ViewGroup mDataViewHeight = mDataView.getMeasuredHeight(); } - if (isVisible(mCallProviderView)) { - mCallProviderView.measure(MeasureSpec.makeMeasureSpec(dataWidth, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); - - // Multiply our height by two + gap - // Why? cause padding below and above the text + text height - mCallProviderViewHeight = mCallProviderView.getMeasuredHeight(); - mCallProviderBottomPadding = getContext().getResources() - .getDimensionPixelSize(R.dimen.call_provider_bottom_padding); - } - if (isVisible(mLabelView)) { // For performance reason we don't want AT_MOST usually, but when the picture is // on right, we need to use it anyway because mDataView is next to mLabelView. @@ -482,11 +466,6 @@ public class ContactListItemView extends ViewGroup // Make sure height is at least the preferred height height = Math.max(height, preferredHeight); - if (isVisible(mCallProviderView)) { - // add callproviderviewheight; - height += mCallProviderViewHeight + mCallProviderBottomPadding; - } - // Measure the header if it is visible. if (mHeaderTextView != null && mHeaderTextView.getVisibility() == VISIBLE) { mHeaderTextView.measure( @@ -564,8 +543,7 @@ public class ContactListItemView extends ViewGroup // Photo is the left most view. All the other Views should on the right of the photo. if (photoView != null) { // Center the photo vertically - int photoTop = (topBound + (bottomBound - topBound - mPhotoViewHeight - - mCallProviderViewHeight - mCallProviderBottomPadding) / 2); + int photoTop = (topBound + (bottomBound - topBound - mPhotoViewHeight) / 2); photoView.layout( leftBound, photoTop, @@ -598,8 +576,7 @@ public class ContactListItemView extends ViewGroup // Center text vertically, then apply the top offset. final int totalTextHeight = mNameTextViewHeight + mPhoneticNameTextViewHeight + - mLabelAndDataViewMaxHeight + mSnippetTextViewHeight + mStatusTextViewHeight - + mCallProviderViewHeight + mCallProviderBottomPadding; + mLabelAndDataViewMaxHeight + mSnippetTextViewHeight + mStatusTextViewHeight; int textTopBound = (bottomBound + topBound - totalTextHeight) / 2 + mTextOffsetTop; // Layout all text view and presence icon @@ -705,13 +682,6 @@ public class ContactListItemView extends ViewGroup textTopBound += mLabelAndDataViewMaxHeight; } - if (isVisible(mCallProviderView)) { - mCallProviderView.layout(dataLeftBound, - textTopBound + mCallProviderBottomPadding, - rightBound, - textTopBound + mCallProviderViewHeight + mCallProviderBottomPadding); - } - if (isVisible(mSnippetView)) { mSnippetView.layout(leftBound, textTopBound, @@ -1078,27 +1048,6 @@ public class ContactListItemView extends ViewGroup } } - /** - * Sets phone number for a list item. - */ - public void setExtraNumber(String text) { - if (TextUtils.isEmpty(text)) { - if (mCallProviderView != null) { - mCallProviderView.setVisibility(View.GONE); - } - } else { - getCallProviderView(); - - final SpannableString textToSet = new SpannableString(text); - setMarqueeText(mCallProviderView, textToSet); - mCallProviderView.setVisibility(VISIBLE); - - // We have a phone number as "mDataView" so make it always LTR and VIEW_START - mCallProviderView.setTextDirection(View.TEXT_DIRECTION_LTR); - mCallProviderView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); - } - } - private void setMarqueeText(TextView textView, char[] text, int size) { if (getTextEllipsis() == TruncateAt.MARQUEE) { setMarqueeText(textView, new String(text, 0, size)); @@ -1151,24 +1100,6 @@ public class ContactListItemView extends ViewGroup return mDataView; } - /** - * Returns the text view for the data text, creating it if necessary. - */ - public TextView getCallProviderView() { - if (mCallProviderView == null) { - mCallProviderView = new TextView(getContext()); - mCallProviderView.setSingleLine(true); - mCallProviderView.setEllipsize(getTextEllipsis()); - mCallProviderView.setTextAppearance(getContext(), R.style.TextAppearanceSmall); - mCallProviderView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); - mCallProviderView.setActivated(isActivated()); - mCallProviderView.setId(R.id.cliv_data_view); - mCallProviderView.setElegantTextHeight(false); - addView(mCallProviderView); - } - return mCallProviderView; - } - /** * Adds or updates a text view for the search snippet. */ diff --git a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java index d7104c86..a906735d 100644 --- a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -50,6 +50,9 @@ import com.android.contacts.common.util.Constants; import com.android.contacts.common.MoreContactUtils; import com.android.contacts.common.model.account.SimAccountType; +import com.android.phone.common.incall.CallMethodInfo; +import com.android.phone.common.incall.CallMethodHelper; + import java.util.ArrayList; import java.util.List; @@ -75,6 +78,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { // exist, this will be Long.MAX_VALUE private long mFirstExtendedDirectoryId = Long.MAX_VALUE; + private CallMethodInfo mCurrentCallMethodInfo; + public static class PhoneQuery { /** @@ -452,34 +457,6 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { final DirectoryPartition directory = (DirectoryPartition) getPartition(partition); bindPhoneNumber(view, cursor, directory.isDisplayNumber()); - bindExtraCallAction(view, cursor, position); - } - - public View.OnClickListener bindExtraCallActionOnClick(TextView v, String text, int position) { - return new View.OnClickListener() { - @Override - public void onClick(View view) { - // Implement in other adapters; - } - }; - } - - protected void bindExtraCallAction(ContactListItemView view, Cursor cursor, int position) { - try { - int columnIndex = cursor.getColumnIndexOrThrow("callable_extra_number"); - final String extra = cursor.getString(columnIndex); - TextView callProviderView = view.getCallProviderView(); - - if (!TextUtils.isEmpty(extra)) { - view.setExtraNumber(extra); - callProviderView.setOnClickListener( - bindExtraCallActionOnClick(callProviderView, extra, position)); - } else { - view.setExtraNumber(null); - } - } catch (IllegalArgumentException e) { - Log.i(TAG, "Column does not exist", e); - } } protected void bindPhoneNumber(ContactListItemView view, Cursor cursor, boolean displayNumber) { @@ -488,8 +465,18 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { final int type = cursor.getInt(PhoneQuery.PHONE_TYPE); final String customLabel = cursor.getString(PhoneQuery.PHONE_LABEL); + if (type == Phone.TYPE_CUSTOM) { + final String providerLabel = cursor.getString(PhoneQuery.PHONE_MIME_TYPE); + CallMethodInfo cmi = CallMethodHelper.getMethodForMimeType(providerLabel); + if (cmi != null) { + label = cmi.mName; + } + } + // TODO cache - label = Phone.getTypeLabel(getContext().getResources(), type, customLabel); + if (label == null) { + label = Phone.getTypeLabel(getContext().getResources(), type, customLabel); + } } view.setLabel(label); final String text; @@ -664,4 +651,9 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { } return disabledSimName; } + + public void setCurrentCallMethod(CallMethodInfo cmi) { + mCurrentCallMethodInfo = cmi; + } + } diff --git a/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java b/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java index 21b52be6..97d1f2a6 100644 --- a/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java +++ b/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java @@ -229,11 +229,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment