Add shortcut support into contacts common
Add setDisplayName(CharSequence name) and setDrawableResources methods
to ContactListItemView so that we can add custom shortcuts into
PhoneNumberListAdapter
Bug: 10339630
Change-Id: I3e8a294dd9d47f034e6244929bdb61d834777974
diff --git a/src/com/android/contacts/common/list/ContactListItemView.java b/src/com/android/contacts/common/list/ContactListItemView.java
index 064c07f..1da925b 100644
--- a/src/com/android/contacts/common/list/ContactListItemView.java
+++ b/src/com/android/contacts/common/list/ContactListItemView.java
@@ -1200,6 +1200,26 @@
public void showDisplayName(Cursor cursor, int nameColumnIndex, int displayOrder) {
CharSequence name = cursor.getString(nameColumnIndex);
+ setDisplayName(name);
+
+ // Since the quick contact content description is derived from the display name and there is
+ // no guarantee that when the quick contact is initialized the display name is already set,
+ // do it here too.
+ if (mQuickContact != null) {
+ mQuickContact.setContentDescription(mContext.getString(
+ R.string.description_quick_contact_for, mNameTextView.getText()));
+ }
+ }
+
+ public void setDisplayName(CharSequence name, boolean highlight) {
+ if (!TextUtils.isEmpty(name) && highlight) {
+ clearHighlightSequences();
+ addNameHighlightSequence(0, name.length());
+ }
+ setDisplayName(name);
+ }
+
+ public void setDisplayName(CharSequence name) {
if (!TextUtils.isEmpty(name)) {
// Chooses the available highlighting method for highlighting.
if (mHighlightedPrefix != null) {
@@ -1216,14 +1236,6 @@
name = mUnknownNameText;
}
setMarqueeText(getNameTextView(), name);
-
- // Since the quick contact content description is derived from the display name and there is
- // no guarantee that when the quick contact is initialized the display name is already set,
- // do it here too.
- if (mQuickContact != null) {
- mQuickContact.setContentDescription(mContext.getString(
- R.string.description_quick_contact_for, mNameTextView.getText()));
- }
}
public void hideDisplayName() {
@@ -1504,4 +1516,18 @@
mSelectionBoundsMarginLeft = left;
mSelectionBoundsMarginRight = right;
}
+
+ /**
+ * Set drawable resources directly for both the background and the drawable resource
+ * of the photo view
+ *
+ * @param backgroundId Id of background resource
+ * @param drawableId Id of drawable resource
+ */
+ public void setDrawableResource(int backgroundId, int drawableId) {
+ final ImageView photo = getPhotoView();
+ photo.setScaleType(ImageView.ScaleType.CENTER);
+ photo.setBackgroundResource(backgroundId);
+ photo.setImageResource(drawableId);
+ }
}
diff --git a/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java b/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java
index d580653..9091fc5 100644
--- a/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java
+++ b/src/com/android/contacts/common/list/PhoneNumberPickerFragment.java
@@ -95,6 +95,10 @@
this.mListener = listener;
}
+ public OnPhoneNumberPickerActionListener getOnPhoneNumberPickerListener() {
+ return mListener;
+ }
+
@Override
protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
super.onCreateView(inflater, container);