Don't stretch image to sender name

Change-Id: I805e0359aedce07253cde1b84dc225f079efba1e
This commit is contained in:
SpiritCroc 2021-05-07 12:06:53 +02:00
parent 0c6e02b76d
commit 5a8f637e58
3 changed files with 41 additions and 6 deletions

View File

@ -66,6 +66,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
override fun bind(holder: H) {
super.bind(holder)
val contentInBubble = infoInBubbles(holder.memberNameView.context)
val senderInBubble = senderNameInBubble(holder.memberNameView.context)
val avatarImageView: ImageView?
var memberNameView: TextView?
@ -77,15 +78,18 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
// Select which views are visible, based on bubble style and other criteria
if (attributes.informationData.showInformation) {
if (contentInBubble) {
if (senderInBubble) {
memberNameView = holder.bubbleMemberNameView
timeView = holder.bubbleTimeView
hiddenViews.add(holder.memberNameView)
hiddenViews.add(holder.timeView)
} else {
memberNameView = holder.memberNameView
timeView = holder.timeView
hiddenViews.add(holder.bubbleMemberNameView)
}
if (contentInBubble) {
timeView = holder.bubbleTimeView
hiddenViews.add(holder.timeView)
} else {
timeView = holder.timeView
hiddenViews.add(holder.bubbleTimeView)
}
} else if (attributes.informationData.forceShowTimestamp) {
@ -125,6 +129,9 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
hiddenViews.add(holder.bubbleMemberNameView)
memberNameView = null
hiddenViews.add(holder.bubbleTimeView)
} else if (!senderInBubble) {
// We don't need to reserve space here
hiddenViews.add(holder.bubbleTimeView)
} else {
// Don't completely remove, just hide, so our relative layout rules still work
invisibleViews.add(holder.bubbleTimeView)
@ -165,7 +172,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
memberNameView?.setOnLongClickListener(attributes.itemLongClickListener)
// More extra views added by Schildi
holder.viewStubContainer.minimumWidth = getViewStubMinimumWidth(holder, contentInBubble, attributes.informationData.showInformation)
if (senderInBubble) {
holder.viewStubContainer.minimumWidth = getViewStubMinimumWidth(holder, contentInBubble, attributes.informationData.showInformation)
} else {
holder.viewStubContainer.minimumWidth = 0
}
if (contentInBubble) {
holder.bubbleFootView.visibility = View.VISIBLE
} else {
@ -301,6 +312,10 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
(messageBubbleAllowed(context) || pseudoBubbleAllowed())
}
private fun senderNameInBubble(context: Context): Boolean {
return infoInBubbles(context) && !pseudoBubbleAllowed()
}
override fun shouldReverseBubble(): Boolean {
return attributes.informationData.sentByMe
}
@ -470,6 +485,24 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
removeFooterOverlayStyle(holder, density)
}
}
if (bubbleStyle == BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN) {
// We need to align the non-bubble member name view to pseudo bubbles
if (reverseBubble) {
holder.memberNameView.setPaddingRelative(
shortPaddingDp,
0,
longPaddingDp,
0
)
} else {
holder.memberNameView.setPaddingRelative(
longPaddingDp,
0,
shortPaddingDp,
0
)
}
}
}
//BubbleThemeUtils.BUBBLE_STYLE_NONE,
else -> {
@ -482,6 +515,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
(bubbleView.layoutParams as RelativeLayout.LayoutParams).bottomMargin = 0
*/
bubbleView.setPadding(0, 0, 0, 0)
holder.memberNameView.setPadding(0, 0, 0, 0)
}
}

View File

@ -154,6 +154,7 @@
<ViewStub
android:id="@+id/messageContentMediaStub"
style="@style/TimelineContentStubBaseParams"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inflatedId="@+id/messageContentMedia"
android:layout="@layout/item_timeline_event_media_message_stub" />

View File

@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView