Add badge icon for work contact in search result

BUG=26021888
BUG=28016344
(cherry picked from commit 6e00763823cd1b27ff88d25d0eb11f8addc3b2e6)

Change-Id: If0e2f7b1c58cd064ebfdae8a9b735b391c5009fc
This commit is contained in:
Tony Mak
2016-05-16 16:35:06 +01:00
committed by Victor Chang
parent e2ccf8bff5
commit c4073ff4ce
9 changed files with 52 additions and 14 deletions
@@ -46,6 +46,9 @@ public class ContactListItemData {
// existing chip for which we show full contact detail for the selected contact).
private boolean mSingleRecipient;
// Is the contact in managed profile.
private boolean mIsWorkContact;
/**
* Bind to a contact cursor in the contact list.
*/
@@ -77,6 +80,8 @@ public class ContactListItemData {
mRecipientEntry = ContactUtil.createRecipientEntry(displayName,
DisplayNameSources.STRUCTURED_NAME, destination, destinationType, destinationLabel,
contactId, lookupKey, dataId, photoThumbnailUri, isFirstLevel);
mIsWorkContact = ContactUtil.isEnterpriseContactId(contactId);
}
/**
@@ -84,13 +89,15 @@ public class ContactListItemData {
* optional styled name & destination for showing bold search match.
*/
public void bind(final RecipientEntry entry, final CharSequence styledName,
final CharSequence styledDestination, final boolean singleRecipient) {
final CharSequence styledDestination, final boolean singleRecipient,
final boolean isWorkContact) {
Assert.isTrue(entry.isValid());
mRecipientEntry = entry;
mStyledName = styledName;
mStyledDestination = styledDestination;
mAlphabetHeader = null;
mSingleRecipient = singleRecipient;
mIsWorkContact = isWorkContact;
}
public CharSequence getDisplayName() {
@@ -157,4 +164,11 @@ public class ContactListItemData {
public RecipientEntry getRecipientEntry() {
return mRecipientEntry;
}
/**
* @return whether the contact is in managed profile.
*/
public boolean getIsWorkContact() {
return mIsWorkContact;
}
}
@@ -34,6 +34,7 @@ import com.android.messaging.ui.ContactIconView;
import com.android.messaging.util.Assert;
import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.ContactRecipientEntryUtils;
import com.android.messaging.util.ContactUtil;
/**
* An implementation for {@link DropdownChipLayouter}. Layouts the dropdown
@@ -99,8 +100,9 @@ public class ContactDropdownLayouter extends DropdownChipLayouter {
Assert.isTrue(itemView instanceof ContactListItemView);
final ContactListItemView contactListItemView = (ContactListItemView) itemView;
contactListItemView.setImageClickHandlerDisabled(true);
boolean isWorkContact = ContactUtil.isEnterpriseContactId(entry.getContactId());
contactListItemView.bind(entry, styledResults[0], styledResults[1],
mClivHostInterface, (type == AdapterType.SINGLE_RECIPIENT));
mClivHostInterface, (type == AdapterType.SINGLE_RECIPIENT), isWorkContact);
return itemView;
}
@@ -53,6 +53,7 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
private TextView mAlphabetHeaderTextView;
private ContactIconView mContactIconView;
private ImageView mContactCheckmarkView;
private ImageView mWorkProfileIcon;
private HostInterface mHostInterface;
private boolean mShouldShowAlphabetHeader;
@@ -69,6 +70,7 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
mAlphabetHeaderTextView = (TextView) findViewById(R.id.alphabet_header);
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
mContactCheckmarkView = (ImageView) findViewById(R.id.contact_checkmark);
mWorkProfileIcon = (ImageView) findViewById(R.id.work_profile_icon);
}
/**
@@ -100,11 +102,12 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
* @param isSingleRecipient whether this item is shown as the only line item in the single
* recipient drop down from the chips view. If this is the case, we always show the
* contact avatar even if it's not a first-level entry.
* @param isWorkContact whether the contact is in managed profile.
*/
public void bind(final RecipientEntry recipientEntry, final CharSequence styledName,
final CharSequence styledDestination, final HostInterface hostInterface,
final boolean isSingleRecipient) {
mData.bind(recipientEntry, styledName, styledDestination, isSingleRecipient);
final boolean isSingleRecipient, final boolean isWorkContact) {
mData.bind(recipientEntry, styledName, styledDestination, isSingleRecipient, isWorkContact);
mHostInterface = hostInterface;
mShouldShowAlphabetHeader = false;
updateViewAppearance();
@@ -152,7 +155,11 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
mContactDetailsTextView.setVisibility(VISIBLE);
mContactDetailTypeTextView.setVisibility(VISIBLE);
}
if (mData.getIsWorkContact()) {
mWorkProfileIcon.setVisibility(VISIBLE);
} else {
mWorkProfileIcon.setVisibility(GONE);
}
if (mShouldShowAlphabetHeader) {
mAlphabetHeaderTextView.setVisibility(VISIBLE);
mAlphabetHeaderTextView.setText(mData.getAlphabetHeader());