differentiate unread counters

differentiate unread counters for group mentions and direct mentions

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-09-22 09:58:08 +02:00
parent 74867b416d
commit a6397b0392
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
3 changed files with 44 additions and 7 deletions

View file

@ -42,6 +42,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.chip.Chip;
import com.nextcloud.talk.R;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.models.database.CapabilitiesUtil;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.chat.ChatMessage;
import com.nextcloud.talk.models.json.conversations.Conversation;
@ -136,20 +137,45 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
holder.dialogUnreadBubble.setText(R.string.tooManyUnreadMessages);
}
if (conversation.isUnreadMention() || conversation.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
ColorStateList lightBubbleFillColor = ColorStateList.valueOf(
ContextCompat.getColor(context,
R.color.conversation_unread_bubble));
int lightBubbleTextColor = ContextCompat.getColor(
context,
R.color.conversation_unread_bubble_text);
ColorStateList lightBubbleStrokeColor = ColorStateList.valueOf(
ContextCompat.getColor(context,
R.color.colorPrimary));
if (conversation.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
holder.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary);
holder.dialogUnreadBubble.setTextColor(Color.WHITE);
} else if (conversation.isUnreadMention()) {
if (CapabilitiesUtil.hasSpreedFeatureCapability(userEntity, "direct-mention-flag")){
if (conversation.getUnreadMentionDirect()) {
holder.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary);
holder.dialogUnreadBubble.setTextColor(Color.WHITE);
} else {
holder.dialogUnreadBubble.setChipBackgroundColor(
ColorStateList.valueOf(ContextCompat.getColor(context, R.color.conversation_unread_bubble)));
holder.dialogUnreadBubble.setTextColor(
ContextCompat.getColor(context, R.color.conversation_unread_bubble_text));
holder.dialogUnreadBubble.setChipBackgroundColor(ColorStateList.valueOf(
ContextCompat.getColor(context, R.color.white)));
holder.dialogUnreadBubble.setTextColor(ContextCompat.getColor(
context,
R.color.colorPrimary));
holder.dialogUnreadBubble.setChipStrokeWidth(6.0f);
holder.dialogUnreadBubble.setChipStrokeColor(lightBubbleStrokeColor);
}
} else {
holder.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary);
holder.dialogUnreadBubble.setTextColor(Color.WHITE);
}
} else {
holder.dialogUnreadBubble.setChipBackgroundColor(lightBubbleFillColor);
holder.dialogUnreadBubble.setTextColor(lightBubbleTextColor);
}
} else {
holder.dialogName.setTypeface(null, Typeface.NORMAL);
holder.dialogDate.setTypeface(null, Typeface.NORMAL);
holder.dialogLastMessage.setTypeface(null, Typeface.NORMAL);
holder.dialogUnreadBubble.setVisibility(View.GONE);
}

View file

@ -98,6 +98,9 @@ public class Conversation {
@JsonField(name = "canDeleteConversation")
public Boolean canDeleteConversation;
@JsonField(name = "unreadMentionDirect")
public Boolean unreadMentionDirect;
public boolean isPublic() {
return (ConversationType.ROOM_PUBLIC_CALL.equals(type));
}
@ -254,6 +257,10 @@ public class Conversation {
return this.callFlag;
}
public Boolean getUnreadMentionDirect() {
return unreadMentionDirect;
}
public void setRoomId(String roomId) {
this.roomId = roomId;
}
@ -359,6 +366,10 @@ public class Conversation {
this.callFlag = callFlag;
}
public void setUnreadMentionDirect(Boolean unreadMentionDirect) {
this.unreadMentionDirect = unreadMentionDirect;
}
@Override
public boolean equals(Object o) {
if (this == o) {