Implemented FacePile if no group icon is present
Bug: 150905003
Test: add group without largeicon
Change-Id: I28444df41394a205622d1fb4fede2768b8aa3353
diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java
index 5e94b71..ce40504 100644
--- a/core/java/com/android/internal/widget/ConversationLayout.java
+++ b/core/java/com/android/internal/widget/ConversationLayout.java
@@ -117,6 +117,8 @@
private CachingIconView mIcon;
private int mExpandedGroupTopMargin;
private int mExpandButtonExpandedSize;
+ private View mConversationFacePile;
+ private int mNotificationBackgroundColor;
public ConversationLayout(@NonNull Context context) {
super(context);
@@ -175,6 +177,7 @@
R.dimen.conversation_icon_size_centered);
mExpandedGroupTopMargin = getResources().getDimensionPixelSize(
R.dimen.conversation_icon_margin_top_centered);
+ mConversationFacePile = findViewById(R.id.conversation_face_pile);
}
@RemotableViewMethod
@@ -297,6 +300,7 @@
// Let's resolve the icon / text from the last sender
mConversationIcon.setVisibility(VISIBLE);
mHeaderText.setVisibility(VISIBLE);
+ mConversationFacePile.setVisibility(GONE);
CharSequence userKey = getKey(mUser);
for (int i = mGroups.size() - 1; i >= 0; i--) {
MessagingGroup messagingGroup = mGroups.get(i);
@@ -314,13 +318,19 @@
} else {
mHeaderText.setVisibility(GONE);
if (mIsCollapsed) {
- mConversationIcon.setVisibility(VISIBLE);
if (mLargeIcon != null) {
+ mConversationIcon.setVisibility(VISIBLE);
+ mConversationFacePile.setVisibility(GONE);
mConversationIcon.setImageIcon(mLargeIcon);
} else {
- // TODO: generate LargeIcon from Conversation
+ mConversationIcon.setVisibility(GONE);
+ // This will also inflate it!
+ mConversationFacePile.setVisibility(VISIBLE);
+ mConversationFacePile = findViewById(R.id.conversation_face_pile);
+ bindFacePile();
}
} else {
+ mConversationFacePile.setVisibility(GONE);
mConversationIcon.setVisibility(GONE);
}
}
@@ -336,6 +346,48 @@
updateIconPositionAndSize();
}
+ private void bindFacePile() {
+ // Let's bind the face pile
+ View bottomBackground = mConversationFacePile.findViewById(
+ R.id.conversation_face_pile_bottom_background);
+ applyNotificationBackgroundColor(bottomBackground);
+ ImageView bottomView = mConversationFacePile.findViewById(
+ R.id.conversation_face_pile_bottom);
+ ImageView topView = mConversationFacePile.findViewById(
+ R.id.conversation_face_pile_top);
+ // Let's find the two last conversations:
+ Icon secondLastIcon = null;
+ CharSequence lastKey = null;
+ Icon lastIcon = null;
+ CharSequence userKey = getKey(mUser);
+ for (int i = mGroups.size() - 1; i >= 0; i--) {
+ MessagingGroup messagingGroup = mGroups.get(i);
+ Person messageSender = messagingGroup.getSender();
+ boolean notUser = messageSender != null
+ && !TextUtils.equals(userKey, getKey(messageSender));
+ boolean notIncluded = messageSender != null
+ && !TextUtils.equals(lastKey, getKey(messageSender));
+ if ((notUser && notIncluded)
+ || (i == 0 && lastKey == null)) {
+ if (lastIcon == null) {
+ lastIcon = messagingGroup.getAvatarIcon();
+ lastKey = getKey(messageSender);
+ } else {
+ secondLastIcon = messagingGroup.getAvatarIcon();
+ break;
+ }
+ }
+ }
+ if (lastIcon == null) {
+ lastIcon = createAvatarSymbol(" ", "", mLayoutColor);
+ }
+ bottomView.setImageIcon(lastIcon);
+ if (secondLastIcon == null) {
+ secondLastIcon = createAvatarSymbol("", "", mLayoutColor);
+ }
+ topView.setImageIcon(secondLastIcon);
+ }
+
/**
* update the icon position and sizing
*/
@@ -532,7 +584,12 @@
*/
@RemotableViewMethod
public void setNotificationBackgroundColor(int color) {
- mConversationIconBadge.setBackgroundTintList(ColorStateList.valueOf(color));
+ mNotificationBackgroundColor = color;
+ applyNotificationBackgroundColor(mConversationIconBadge);
+ }
+
+ private void applyNotificationBackgroundColor(View view) {
+ view.setBackgroundTintList(ColorStateList.valueOf(mNotificationBackgroundColor));
}
@RemotableViewMethod