Fixed chat message display in IMDN view + improved chat bubble layout
This commit is contained in:
parent
8f291145d2
commit
905049f7c7
5 changed files with 62 additions and 89 deletions
|
@ -48,22 +48,15 @@ class MultiLineWrapContentWidthTextView : AppCompatTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
||||||
var wSpec = widthSpec
|
super.onMeasure(widthSpec, heightSpec)
|
||||||
val widthMode = MeasureSpec.getMode(wSpec)
|
|
||||||
|
|
||||||
if (widthMode == MeasureSpec.AT_MOST) {
|
if (layout != null && layout.lineCount >= 2) {
|
||||||
val layout = layout
|
val maxLineWidth = ceil(getMaxLineWidth(layout)).toInt()
|
||||||
if (layout != null) {
|
val uselessPaddingWidth = layout.width - maxLineWidth
|
||||||
val maxWidth = (
|
val width = measuredWidth - uselessPaddingWidth
|
||||||
ceil(getMaxLineWidth(layout).toDouble()).toInt() +
|
val height = measuredHeight
|
||||||
totalPaddingLeft +
|
setMeasuredDimension(width, height)
|
||||||
totalPaddingRight
|
|
||||||
)
|
|
||||||
wSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onMeasure(wSpec, heightSpec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMaxLineWidth(layout: Layout): Float {
|
private fun getMaxLineWidth(layout: Layout): Float {
|
||||||
|
|
7
app/src/main/res/drawable/icon_ephemeral_message.xml
Normal file
7
app/src/main/res/drawable/icon_ephemeral_message.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/ephemeral_messages"
|
||||||
|
android:width="11.6dp"
|
||||||
|
android:height="13dp" />
|
||||||
|
</layer-list >
|
7
app/src/main/res/drawable/icon_forwarded_message.xml
Normal file
7
app/src/main/res/drawable/icon_forwarded_message.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/forwarded_message_default"
|
||||||
|
android:width="15dp"
|
||||||
|
android:height="12dp" />
|
||||||
|
</layer-list >
|
7
app/src/main/res/drawable/icon_replied_message.xml
Normal file
7
app/src/main/res/drawable/icon_replied_message.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item
|
||||||
|
android:drawable="@drawable/replied_message_default"
|
||||||
|
android:width="15dp"
|
||||||
|
android:height="12dp" />
|
||||||
|
</layer-list >
|
|
@ -95,67 +95,39 @@
|
||||||
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !data.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
|
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !data.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
|
||||||
android:paddingBottom="5dp">
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:visibility="@{data.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{data.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:textColor="@color/chat_bubble_text_color"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:textStyle="normal"
|
||||||
|
android:lineSpacingExtra="3.3sp"
|
||||||
|
android:drawablePadding="3dp"
|
||||||
|
android:text="@string/chat_message_forwarded"
|
||||||
|
tools:ignore="SmallSp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginLeft="5dp">
|
app:drawableLeftCompat="@drawable/icon_forwarded_message" />
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:layout_width="15dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:src="@drawable/forwarded_message_default"
|
|
||||||
android:contentDescription="@string/content_description_forwarded_message"
|
|
||||||
android:layout_marginRight="3dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/chat_bubble_text_color"
|
|
||||||
android:textSize="10sp"
|
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:textStyle="normal"
|
|
||||||
android:lineSpacingExtra="3.3sp"
|
|
||||||
android:text="@string/chat_message_forwarded"
|
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:visibility="@{data.chatMessage.reply ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{data.chatMessage.reply ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:textColor="@color/chat_bubble_text_color"
|
||||||
android:gravity="center_vertical"
|
android:textSize="10sp"
|
||||||
android:layout_marginTop="5dp"
|
android:fontFamily="sans-serif"
|
||||||
android:layout_marginRight="5dp"
|
android:textStyle="normal"
|
||||||
android:layout_marginLeft="5dp">
|
android:lineSpacingExtra="3.3sp"
|
||||||
|
android:text="@string/chat_message_replied"
|
||||||
<ImageView
|
tools:ignore="SmallSp"
|
||||||
android:layout_width="15dp"
|
android:drawablePadding="3dp"
|
||||||
android:layout_height="wrap_content"
|
app:drawableLeftCompat="@drawable/icon_replied_message" />
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:src="@drawable/replied_message_default"
|
|
||||||
android:contentDescription="@string/content_description_replied_message"
|
|
||||||
android:layout_marginRight="3dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/chat_bubble_text_color"
|
|
||||||
android:textSize="10sp"
|
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:textStyle="normal"
|
|
||||||
android:lineSpacingExtra="3.3sp"
|
|
||||||
android:text="@string/chat_message_replied"
|
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/chat_message_reply_bubble"
|
<include layout="@layout/chat_message_reply_bubble"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -201,35 +173,22 @@
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
android:lineSpacingExtra="-1.7sp"/>
|
android:lineSpacingExtra="-1.7sp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:visibility="@{data.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{data.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
|
android:text="@{data.ephemeralLifetime, default=`00:00`}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:gravity="center_vertical|right"
|
android:gravity="center_vertical|right"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_marginLeft="5dp">
|
android:layout_marginLeft="5dp"
|
||||||
|
android:drawablePadding="3dp"
|
||||||
<TextView
|
android:textColor="@color/primary_color"
|
||||||
android:text="@{data.ephemeralLifetime}"
|
android:textSize="12sp"
|
||||||
android:layout_width="wrap_content"
|
android:fontFamily="sans-serif"
|
||||||
android:layout_height="wrap_content"
|
android:textStyle="normal"
|
||||||
android:layout_marginRight="5dp"
|
android:lineSpacingExtra="3.3sp"
|
||||||
android:textColor="@color/primary_color"
|
app:drawableRightCompat="@drawable/icon_ephemeral_message" />
|
||||||
android:textSize="12sp"
|
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:textStyle="normal"
|
|
||||||
android:lineSpacingExtra="3.3sp" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="13dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_ephemeral_message"
|
|
||||||
android:src="@drawable/ephemeral_messages"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue