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-11 18:44:00 +01:00
committed by Victor Chang
parent e2ccf8bff5
commit c4073ff4ce
9 changed files with 52 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@@ -63,15 +63,30 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" > android:layout_gravity="center_vertical" >
<TextView
android:id="@+id/contact_name" <LinearLayout
android:layout_width="wrap_content" android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:paddingBottom="4dp" android:layout_height="wrap_content">
android:singleLine="true" <TextView
android:maxLines="1" android:id="@+id/contact_name"
android:ellipsize="end" android:layout_width="wrap_content"
style="@style/ContactListItem" /> android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="4dp"
android:singleLine="true"
android:maxLines="1"
android:ellipsize="end"
style="@style/ContactListItem" />
<ImageView android:id="@+id/work_profile_icon"
android:src="@drawable/ic_work_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_gravity="center_vertical"
android:visibility="gone" />
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"

View File

@@ -46,6 +46,9 @@ public class ContactListItemData {
// existing chip for which we show full contact detail for the selected contact). // existing chip for which we show full contact detail for the selected contact).
private boolean mSingleRecipient; private boolean mSingleRecipient;
// Is the contact in managed profile.
private boolean mIsWorkContact;
/** /**
* Bind to a contact cursor in the contact list. * Bind to a contact cursor in the contact list.
*/ */
@@ -77,6 +80,8 @@ public class ContactListItemData {
mRecipientEntry = ContactUtil.createRecipientEntry(displayName, mRecipientEntry = ContactUtil.createRecipientEntry(displayName,
DisplayNameSources.STRUCTURED_NAME, destination, destinationType, destinationLabel, DisplayNameSources.STRUCTURED_NAME, destination, destinationType, destinationLabel,
contactId, lookupKey, dataId, photoThumbnailUri, isFirstLevel); 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. * optional styled name & destination for showing bold search match.
*/ */
public void bind(final RecipientEntry entry, final CharSequence styledName, 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()); Assert.isTrue(entry.isValid());
mRecipientEntry = entry; mRecipientEntry = entry;
mStyledName = styledName; mStyledName = styledName;
mStyledDestination = styledDestination; mStyledDestination = styledDestination;
mAlphabetHeader = null; mAlphabetHeader = null;
mSingleRecipient = singleRecipient; mSingleRecipient = singleRecipient;
mIsWorkContact = isWorkContact;
} }
public CharSequence getDisplayName() { public CharSequence getDisplayName() {
@@ -157,4 +164,11 @@ public class ContactListItemData {
public RecipientEntry getRecipientEntry() { public RecipientEntry getRecipientEntry() {
return mRecipientEntry; return mRecipientEntry;
} }
/**
* @return whether the contact is in managed profile.
*/
public boolean getIsWorkContact() {
return mIsWorkContact;
}
} }

View File

@@ -34,6 +34,7 @@ import com.android.messaging.ui.ContactIconView;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.AvatarUriUtil; import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.ContactRecipientEntryUtils; import com.android.messaging.util.ContactRecipientEntryUtils;
import com.android.messaging.util.ContactUtil;
/** /**
* An implementation for {@link DropdownChipLayouter}. Layouts the dropdown * An implementation for {@link DropdownChipLayouter}. Layouts the dropdown
@@ -99,8 +100,9 @@ public class ContactDropdownLayouter extends DropdownChipLayouter {
Assert.isTrue(itemView instanceof ContactListItemView); Assert.isTrue(itemView instanceof ContactListItemView);
final ContactListItemView contactListItemView = (ContactListItemView) itemView; final ContactListItemView contactListItemView = (ContactListItemView) itemView;
contactListItemView.setImageClickHandlerDisabled(true); contactListItemView.setImageClickHandlerDisabled(true);
boolean isWorkContact = ContactUtil.isEnterpriseContactId(entry.getContactId());
contactListItemView.bind(entry, styledResults[0], styledResults[1], contactListItemView.bind(entry, styledResults[0], styledResults[1],
mClivHostInterface, (type == AdapterType.SINGLE_RECIPIENT)); mClivHostInterface, (type == AdapterType.SINGLE_RECIPIENT), isWorkContact);
return itemView; return itemView;
} }

View File

@@ -53,6 +53,7 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
private TextView mAlphabetHeaderTextView; private TextView mAlphabetHeaderTextView;
private ContactIconView mContactIconView; private ContactIconView mContactIconView;
private ImageView mContactCheckmarkView; private ImageView mContactCheckmarkView;
private ImageView mWorkProfileIcon;
private HostInterface mHostInterface; private HostInterface mHostInterface;
private boolean mShouldShowAlphabetHeader; private boolean mShouldShowAlphabetHeader;
@@ -69,6 +70,7 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
mAlphabetHeaderTextView = (TextView) findViewById(R.id.alphabet_header); mAlphabetHeaderTextView = (TextView) findViewById(R.id.alphabet_header);
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon); mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
mContactCheckmarkView = (ImageView) findViewById(R.id.contact_checkmark); 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 * @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 * 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. * 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, public void bind(final RecipientEntry recipientEntry, final CharSequence styledName,
final CharSequence styledDestination, final HostInterface hostInterface, final CharSequence styledDestination, final HostInterface hostInterface,
final boolean isSingleRecipient) { final boolean isSingleRecipient, final boolean isWorkContact) {
mData.bind(recipientEntry, styledName, styledDestination, isSingleRecipient); mData.bind(recipientEntry, styledName, styledDestination, isSingleRecipient, isWorkContact);
mHostInterface = hostInterface; mHostInterface = hostInterface;
mShouldShowAlphabetHeader = false; mShouldShowAlphabetHeader = false;
updateViewAppearance(); updateViewAppearance();
@@ -152,7 +155,11 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
mContactDetailsTextView.setVisibility(VISIBLE); mContactDetailsTextView.setVisibility(VISIBLE);
mContactDetailTypeTextView.setVisibility(VISIBLE); mContactDetailTypeTextView.setVisibility(VISIBLE);
} }
if (mData.getIsWorkContact()) {
mWorkProfileIcon.setVisibility(VISIBLE);
} else {
mWorkProfileIcon.setVisibility(GONE);
}
if (mShouldShowAlphabetHeader) { if (mShouldShowAlphabetHeader) {
mAlphabetHeaderTextView.setVisibility(VISIBLE); mAlphabetHeaderTextView.setVisibility(VISIBLE);
mAlphabetHeaderTextView.setText(mData.getAlphabetHeader()); mAlphabetHeaderTextView.setText(mData.getAlphabetHeader());