use chip view for pill-style unread messages counter

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-03-18 09:23:08 +01:00
parent 12154fffdd
commit aee794142e
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 47 additions and 52 deletions

View File

@ -81,11 +81,9 @@ open class ConversationPresenter(context: Context, onElementClick: ((Page, Holde
}
if (conversation.unreadMention || conversation.type == Conversation.ConversationType.ONE_TO_ONE_CONVERSATION) {
holder.itemView.dialogUnreadBubble!!.background =
context.getDrawable(R.drawable.bubble_circle_unread_mention)
holder.itemView.dialogUnreadBubble!!.setChipBackgroundColorResource(R.color.colorPrimary)
} else {
holder.itemView.dialogUnreadBubble!!.background =
context.getDrawable(R.drawable.bubble_circle_unread)
holder.itemView.dialogUnreadBubble!!.setChipBackgroundColorResource(R.color.grey_600)
}
} else {
holder.itemView.dialogUnreadBubble!!.visibility = View.GONE

View File

@ -3,6 +3,8 @@
~ Nextcloud Talk application
~
~ @author Mario Danic
~ @author Andy Scherzinger
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
~
~ This program is free software: you can redistribute it and/or modify
@ -17,27 +19,27 @@
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
~
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/rv_item_view_height"
android:layout_margin="@dimen/double_margin_between_elements"
android:layout_height="@dimen/item_height"
android:padding="@dimen/double_margin_between_elements"
android:animateLayoutChanges="true">
<FrameLayout
android:id="@+id/dialogAvatarFrameLayout"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/margin_between_elements">
android:layout_marginEnd="@dimen/double_margin_between_elements">
<ImageView
android:id="@id/dialogAvatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
tools:src="@tools:sample/avatars[0]"/>
@ -59,54 +61,50 @@
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/dialogName"
android:layout_marginTop="8dp"
android:layout_toEndOf="@id/dialogAvatarFrameLayout">
<androidx.emoji.widget.EmojiTextView
android:id="@id/dialogLastMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/dialogUnreadBubble"
android:layout_toEndOf="@id/dialogAvatarFrameLayout"
android:ellipsize="end"
android:gravity="top"
android:lines="1"
android:singleLine="true"
android:textColor="@color/conversation_last_message"
tools:text="This is the last message\nof an incredibly long two line conversation text" />
<androidx.emoji.widget.EmojiTextView
android:id="@id/dialogLastMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/dialogUnreadBubble"
android:ellipsize="end"
android:gravity="top"
android:lines="1"
android:singleLine="true"
android:textColor="@color/conversation_last_message"
tools:text="This is the last message\nof an incredibly long two line conversation text" />
<TextView
android:id="@id/dialogUnreadBubble"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:background="@drawable/bubble_circle_unread"
android:gravity="center_vertical"
android:layout_centerInParent="true"
android:lines="1"
android:textAlignment="center"
android:textColor="@color/conversation_unread_bubble"
android:textSize="10sp"
tools:background="@drawable/bubble_circle_unread"
tools:text="99+"
/>
</RelativeLayout>
<com.google.android.material.chip.Chip
android:id="@+id/dialogUnreadBubble"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="8dp"
android:gravity="top"
android:lines="1"
android:textColor="@color/conversation_unread_bubble"
app:chipEndPadding="-1dp"
app:chipMinTouchTargetSize="0dp"
app:chipStartPadding="-3dp"
app:ensureMinTouchTargetSize="false"
tools:text="99+" />
<TextView
android:id="@id/dialogDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/dialogAvatarFrameLayout"
android:layout_alignParentEnd="true"
android:layout_marginStart="@dimen/margin_between_elements"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/conversation_date" />
android:textColor="@color/conversation_date"
tools:text="@string/nc_date_header_yesterday" />
<ProgressBar
android:layout_width="16sp"
@ -116,8 +114,7 @@
android:layout_marginEnd="8dp"
android:layout_toEndOf="@+id/dialogAvatarFrameLayout"
android:indeterminateTint="@color/colorPrimary"
android:visibility="gone"
/>
android:visibility="gone" />
<androidx.emoji.widget.EmojiTextView
android:id="@id/dialogName"