fix attachments icon in dialogs

This commit is contained in:
2021-02-21 00:55:07 +03:00
parent 35c45fd34f
commit 34e5258241
2 changed files with 34 additions and 17 deletions
@@ -107,6 +107,7 @@ class ConversationsAdapter(
inner class ConversationHolder(v: View) : BaseHolder(v) { inner class ConversationHolder(v: View) : BaseHolder(v) {
private var attachments: ImageView = v.findViewById(R.id.conversationTextAttachment)
private var text: TextView = v.findViewById(R.id.conversationText) private var text: TextView = v.findViewById(R.id.conversationText)
private var title: TextView = v.findViewById(R.id.conversationTitle) private var title: TextView = v.findViewById(R.id.conversationTitle)
private var avatar: ImageView = v.findViewById(R.id.conversationAvatar) private var avatar: ImageView = v.findViewById(R.id.conversationAvatar)
@@ -317,10 +318,11 @@ class ConversationsAdapter(
} }
private fun prepareAttachments(lastMessage: VKMessage) { private fun prepareAttachments(lastMessage: VKMessage) {
text.apply { // text.apply {
compoundDrawablePadding = 0 // compoundDrawablePadding = 0
setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null) // setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null)
} // }
attachments.isVisible = false
if (lastMessage.action == null) { if (lastMessage.action == null) {
when { when {
@@ -345,17 +347,21 @@ class ConversationsAdapter(
val attachmentDrawable = val attachmentDrawable =
VKUtil.getAttachmentDrawable(context, lastMessage.attachments) VKUtil.getAttachmentDrawable(context, lastMessage.attachments)
text.text = span
text.apply { attachments.isVisible = true
text = span attachments.setImageDrawable(attachmentDrawable)
setCompoundDrawablesRelativeWithIntrinsicBounds(
attachmentDrawable, // text.apply {
null, // text = span
null, // setCompoundDrawablesRelativeWithIntrinsicBounds(
null // attachmentDrawable,
) // null,
compoundDrawablePadding = 8 // null,
} // null
// )
// compoundDrawablePadding = 8
// }
} }
lastMessage.fwdMessages.isNotEmpty() -> { lastMessage.fwdMessages.isNotEmpty() -> {
val fwdText = VKUtil.getFwdText(context, lastMessage.getForwardedMessages()) val fwdText = VKUtil.getFwdText(context, lastMessage.getForwardedMessages())
+14 -3
View File
@@ -106,6 +106,17 @@
tools:src="?colorAccent" tools:src="?colorAccent"
tools:visibility="visible" /> tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/conversationTextAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="1.5dp"
android:tint="?colorAccent"
android:visibility="gone"
tools:src="@drawable/ic_message_attachment_camera"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/conversationText" android:id="@+id/conversationText"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -166,10 +177,10 @@
android:background="@drawable/ic_conversations_counter_background" android:background="@drawable/ic_conversations_counter_background"
android:backgroundTint="?colorAccent" android:backgroundTint="?colorAccent"
android:backgroundTintMode="multiply" android:backgroundTintMode="multiply"
android:gravity="center"
android:minWidth="25dp"
android:fontFamily="@font/google_sans_medium" android:fontFamily="@font/google_sans_medium"
android:minHeight="20dp" android:gravity="center"
android:minWidth="28dp"
android:minHeight="28dp"
android:padding="6dp" android:padding="6dp"
android:textColor="?android:textColorPrimaryInverse" android:textColor="?android:textColorPrimaryInverse"
android:textSize="12sp" android:textSize="12sp"