From 633aad3193cb0419cd723ef9e6c260249026a1a3 Mon Sep 17 00:00:00 2001 From: Haresh Khanna Date: Mon, 6 Mar 2017 13:32:43 +0530 Subject: [PATCH] Adds a message sender label in each conversation for text messages --- .../ui/adapter/ConversationAdapter.java | 18 +++++++++++++++++- src/main/res/layout/conversation_list_row.xml | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 030a57ddd..3456a0e15 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -59,8 +59,10 @@ public class ConversationAdapter extends ArrayAdapter { } TextView mLastMessage = (TextView) view.findViewById(R.id.conversation_lastmsg); TextView mTimestamp = (TextView) view.findViewById(R.id.conversation_lastupdate); + TextView mSenderName = (TextView) view.findViewById(R.id.sender_name); ImageView imagePreview = (ImageView) view.findViewById(R.id.conversation_lastimage); ImageView notificationStatus = (ImageView) view.findViewById(R.id.notification_status); + UnreadCountCustomView unreadCountCustomView = (UnreadCountCustomView) view.findViewById(R.id.unread_count); Message message = conversation.getLatestMessage(); int unreadCount = conversation.unreadCount(); @@ -81,7 +83,6 @@ public class ConversationAdapter extends ArrayAdapter { Pair preview = UIHelper.getMessagePreview(activity,message); mLastMessage.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.GONE); - UnreadCountCustomView unreadCountCustomView = (UnreadCountCustomView) view.findViewById(R.id.unread_count); if (unreadCount > 0) { unreadCountCustomView.setVisibility(View.VISIBLE); unreadCountCustomView.setUnreadCount(unreadCount); @@ -92,16 +93,31 @@ public class ConversationAdapter extends ArrayAdapter { if (preview.second) { if (conversation.isRead()) { mLastMessage.setTypeface(null, Typeface.ITALIC); + mSenderName.setTypeface(null, Typeface.NORMAL); } else { mLastMessage.setTypeface(null,Typeface.BOLD_ITALIC); + mSenderName.setTypeface(null,Typeface.BOLD); } } else { if (conversation.isRead()) { mLastMessage.setTypeface(null,Typeface.NORMAL); + mSenderName.setTypeface(null,Typeface.NORMAL); } else { mLastMessage.setTypeface(null,Typeface.BOLD); + mSenderName.setTypeface(null,Typeface.BOLD); } } + if (message.getStatus() == Message.STATUS_RECEIVED) { + if (conversation.getMode() == Conversation.MODE_MULTI) { + mSenderName.setVisibility(View.VISIBLE); + mSenderName.setText(UIHelper.getMessageDisplayName(message)); + } else { + mSenderName.setVisibility(View.GONE); + } + } else { + mSenderName.setVisibility(View.VISIBLE); + mSenderName.setText(activity.getString(R.string.me)); + } } long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0); diff --git a/src/main/res/layout/conversation_list_row.xml b/src/main/res/layout/conversation_list_row.xml index 157fdc72e..764cb28e2 100644 --- a/src/main/res/layout/conversation_list_row.xml +++ b/src/main/res/layout/conversation_list_row.xml @@ -57,11 +57,25 @@ android:layout_below="@id/conversation_name" android:layout_marginTop="4dp"> + +