From 7190f3c5406396bfbb8f128a07d2e74929502043 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 28 Dec 2016 14:17:58 +0100 Subject: Implement FS#239: Show number of unread messages in conversations overview --- .../ui/adapter/ConversationAdapter.java | 31 +++++----- src/main/res/layout/conversation_list_row.xml | 72 +++++++++++++--------- 2 files changed, 59 insertions(+), 44 deletions(-) diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java index 98a9a96c..97cf0739 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java @@ -112,20 +112,23 @@ public class ConversationAdapter extends ArrayAdapter { } String lastMessagePreview = ((null == msgPrefix || msgPrefix.isEmpty()) ? "" : (msgPrefix + ": ")) + msgText; mLastMessage.setText(lastMessagePreview); - if (preview.second) { - if (conversation.isRead()) { - mLastMessage.setTypeface(null, Typeface.ITALIC); - } else { - mLastMessage.setTypeface(null,Typeface.BOLD_ITALIC); - } - } else { - if (conversation.isRead()) { - mLastMessage.setTypeface(null,Typeface.NORMAL); - } else { - mLastMessage.setTypeface(null,Typeface.BOLD); - } - } - } + int lastMessageTypeface = Typeface.NORMAL; + if (conversation.isRead()) { + if (preview.second) { + lastMessageTypeface = Typeface.ITALIC; + } + } else { + TextView txtUnreadCount = (TextView) view.findViewById(R.id.conversation_unreadcount); + txtUnreadCount.setVisibility(View.VISIBLE); + txtUnreadCount.setText(String.valueOf(conversation.unreadCount())); + if (preview.second) { + lastMessageTypeface = Typeface.BOLD_ITALIC; + } else { + lastMessageTypeface = Typeface.BOLD; + } + } + mLastMessage.setTypeface(null, lastMessageTypeface); + } long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0); if (muted_till == Long.MAX_VALUE) { diff --git a/src/main/res/layout/conversation_list_row.xml b/src/main/res/layout/conversation_list_row.xml index 74e84593..41fd1b90 100644 --- a/src/main/res/layout/conversation_list_row.xml +++ b/src/main/res/layout/conversation_list_row.xml @@ -14,7 +14,7 @@ android:layout_height="match_parent" android:background="@color/red500"/> - + android:padding="4dp" + android:id="@+id/conversationListRowContent"> - + + android:paddingLeft="4dp"> + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:layout_toLeftOf="@+id/notification_status" + android:orientation="vertical" + android:id="@+id/conversation_last"> - + android:textColor="@color/primaryText" + android:textSize="?attr/TextSizeBody" + app:emojiconSize="?attr/EmojiconSizeBody" /> + android:layout_toLeftOf="@+id/conversation_unreadcount" + android:src="@drawable/ic_notifications_grey600_24dp" /> + +