Removed now useless RelativeLayout for chat message bubble
This commit is contained in:
parent
0c085ed0b5
commit
4aeef970bb
2 changed files with 174 additions and 180 deletions
|
@ -222,6 +222,7 @@ dependencies {
|
|||
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha03"
|
||||
implementation 'androidx.core:core-splashscreen:1.0.0-beta02'
|
||||
|
||||
// https://github.com/material-components/material-components-android/blob/master/LICENSE Apache v2.0
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
// https://github.com/google/flexbox-layout/blob/main/LICENSE Apache v2.0
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View"/>
|
||||
<import type="android.view.Gravity"/>
|
||||
<import type="com.google.android.flexbox.JustifyContent"/>
|
||||
<import type="android.view.View" />
|
||||
<import type="android.view.Gravity" />
|
||||
<import type="com.google.android.flexbox.JustifyContent" />
|
||||
<variable
|
||||
name="contextMenuClickListener"
|
||||
type="android.view.View.OnLongClickListener"/>
|
||||
type="android.view.View.OnLongClickListener" />
|
||||
<variable
|
||||
name="clickListener"
|
||||
type="android.view.View.OnClickListener" />
|
||||
|
@ -18,7 +18,7 @@
|
|||
type="android.view.View.OnClickListener" />
|
||||
<variable
|
||||
name="position"
|
||||
type="Integer"/>
|
||||
type="Integer" />
|
||||
<variable
|
||||
name="data"
|
||||
type="org.linphone.activities.main.chat.data.ChatMessageData" />
|
||||
|
@ -28,195 +28,188 @@
|
|||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:onClick="@{clickListener}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{clickListener}">
|
||||
|
||||
<!-- Weirdly enough this "useless" RelativeLayout prevents the measuring issue
|
||||
in child LinearLayout (which size depends on the MultiLineWrapContentWidthTextView) -->
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<CheckBox
|
||||
android:id="@+id/select"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/background"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="5dp"
|
||||
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
||||
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
||||
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE, default=gone}" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/select"
|
||||
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
||||
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/background"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="5dp" />
|
||||
<!-- To align with security badge if visible -->
|
||||
<View
|
||||
android:id="@+id/rightMark"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
||||
<!-- To align with security badge if visible -->
|
||||
<View
|
||||
android:id="@+id/rightMark"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentRight="true" />
|
||||
<ImageView
|
||||
android:id="@+id/imdn"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_alignBottom="@id/background"
|
||||
android:layout_toLeftOf="@{selectionListViewModel.isEditionEnabled ? @id/select : @id/rightMark}"
|
||||
android:contentDescription="@string/content_description_delivery_status"
|
||||
android:src="@{data.imdnIcon, default=@drawable/chat_delivered}"
|
||||
android:visibility="@{data.chatMessage.outgoing ? (data.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imdn"
|
||||
android:visibility="@{data.chatMessage.outgoing ? (data.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}"
|
||||
android:src="@{data.imdnIcon, default=@drawable/chat_delivered}"
|
||||
android:contentDescription="@string/content_description_delivery_status"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_toLeftOf="@{selectionListViewModel.isEditionEnabled ? @id/select : @id/rightMark}"
|
||||
android:layout_alignBottom="@id/background" />
|
||||
<org.linphone.contact.ContactAvatarView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/time"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center"
|
||||
android:visibility="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (data.hideAvatar ? View.INVISIBLE : View.VISIBLE)}"
|
||||
app:data="@{data}"
|
||||
tools:layout="@layout/contact_avatar" />
|
||||
|
||||
<org.linphone.contact.ContactAvatarView
|
||||
android:id="@+id/avatar"
|
||||
android:visibility="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (data.hideAvatar ? View.INVISIBLE : View.VISIBLE)}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/time"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center"
|
||||
app:data="@{data}"
|
||||
tools:layout="@layout/contact_avatar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/background"
|
||||
android:onClick="@{clickListener}"
|
||||
android:onLongClick="@{contextMenuClickListener}"
|
||||
backgroundImage="@{data.backgroundRes, default=@drawable/chat_bubble_outgoing_full}"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_toLeftOf="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_below="@id/time"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:layout_marginRight="@{data.chatMessage.outgoing ? @dimen/outgoing_chat_message_bubble_right_margin : @dimen/incoming_chat_message_bubble_right_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">
|
||||
|
||||
<TextView
|
||||
android:visibility="@{data.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
||||
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:drawablePadding="3dp"
|
||||
android:text="@string/chat_message_forwarded"
|
||||
tools:ignore="SmallSp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
app:drawableLeftCompat="@drawable/icon_forwarded_message" />
|
||||
|
||||
<TextView
|
||||
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_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"
|
||||
android:drawablePadding="3dp"
|
||||
app:drawableLeftCompat="@drawable/icon_replied_message" />
|
||||
|
||||
<include layout="@layout/chat_message_reply_bubble"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_gravity="@{data.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
|
||||
app:data="@{data.replyData}"
|
||||
app:clickListener="@{replyClickListener}"
|
||||
android:visibility="@{data.replyData != null ? View.VISIBLE : View.GONE, default=gone}" />
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:longClickable="true"
|
||||
app:entries="@{data.contents}"
|
||||
app:layout="@{@layout/chat_message_content_cell}"
|
||||
app:onLongClick="@{contextMenuClickListener}"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="center"
|
||||
app:justifyContent="@{data.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"/>
|
||||
|
||||
<org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView
|
||||
android:onClick="@{clickListener}"
|
||||
android:onLongClick="@{contextMenuClickListener}"
|
||||
android:text="@{data.text}"
|
||||
android:visibility="@{data.text.length > 0 ? View.VISIBLE : View.GONE}"
|
||||
android:layout_gravity="@{data.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:longClickable="true"
|
||||
android:textColor="@color/dark_grey_color"
|
||||
android:textSize="15sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textStyle="normal"
|
||||
android:lineSpacingExtra="-1.7sp"/>
|
||||
|
||||
<TextView
|
||||
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_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:gravity="center_vertical|right"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:drawablePadding="3dp"
|
||||
android:textColor="@color/primary_color"
|
||||
android:textSize="12sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textStyle="normal"
|
||||
android:lineSpacingExtra="3.3sp"
|
||||
app:drawableRightCompat="@drawable/icon_ephemeral_message" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/background"
|
||||
backgroundImage="@{data.backgroundRes, default=@drawable/chat_bubble_outgoing_full}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/time"
|
||||
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_marginRight="@{data.chatMessage.outgoing ? @dimen/outgoing_chat_message_bubble_right_margin : @dimen/incoming_chat_message_bubble_right_margin}"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:layout_toLeftOf="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:onClick="@{clickListener}"
|
||||
android:onLongClick="@{contextMenuClickListener}"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:text="@{data.chatMessage.outgoing ? data.time : data.time + ` - ` + (data.contact.name ?? data.displayName)}"
|
||||
android:visibility="@{data.hideTime ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignLeft="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}"
|
||||
android:layout_alignRight="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}"
|
||||
android:layout_marginTop="7dp"
|
||||
android:textColor="@color/chat_bubble_text_color"
|
||||
android:textSize="13sp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:drawablePadding="3dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:lineSpacingExtra="3.3sp"
|
||||
android:text="@string/chat_message_forwarded"
|
||||
android:textColor="@color/chat_bubble_text_color"
|
||||
android:textSize="10sp"
|
||||
android:textStyle="normal"
|
||||
android:lineSpacingExtra="0sp" />
|
||||
android:visibility="@{data.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:drawableLeftCompat="@drawable/icon_forwarded_message"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<ProgressBar
|
||||
android:visibility="@{data.transferInProgress || data.sendInProgress ? View.VISIBLE : View.GONE}"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_toRightOf="@id/background"
|
||||
android:layout_alignBottom="@id/background"
|
||||
android:indeterminateTint="?attr/accentColor" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:drawablePadding="3dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:lineSpacingExtra="3.3sp"
|
||||
android:text="@string/chat_message_replied"
|
||||
android:textColor="@color/chat_bubble_text_color"
|
||||
android:textSize="10sp"
|
||||
android:textStyle="normal"
|
||||
android:visibility="@{data.chatMessage.reply ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:drawableLeftCompat="@drawable/icon_replied_message"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</RelativeLayout>
|
||||
<include
|
||||
layout="@layout/chat_message_reply_bubble"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="@{data.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:visibility="@{data.replyData != null ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:clickListener="@{replyClickListener}"
|
||||
app:data="@{data.replyData}" />
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:longClickable="true"
|
||||
app:alignItems="center"
|
||||
app:entries="@{data.contents}"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="@{data.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"
|
||||
app:layout="@{@layout/chat_message_content_cell}"
|
||||
app:onLongClick="@{contextMenuClickListener}" />
|
||||
|
||||
<org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="@{data.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:lineSpacingExtra="-1.7sp"
|
||||
android:longClickable="true"
|
||||
android:onClick="@{clickListener}"
|
||||
android:onLongClick="@{contextMenuClickListener}"
|
||||
android:text="@{data.text}"
|
||||
android:textColor="@color/dark_grey_color"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="normal"
|
||||
android:visibility="@{data.text.length > 0 ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:drawablePadding="3dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical|right"
|
||||
android:lineSpacingExtra="3.3sp"
|
||||
android:text="@{data.ephemeralLifetime, default=`00:00`}"
|
||||
android:textColor="@color/primary_color"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="normal"
|
||||
android:visibility="@{data.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:drawableRightCompat="@drawable/icon_ephemeral_message" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}"
|
||||
android:layout_alignRight="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="7dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:lineSpacingExtra="0sp"
|
||||
android:text="@{data.chatMessage.outgoing ? data.time : data.time + ` - ` + (data.contact.name ?? data.displayName)}"
|
||||
android:textColor="@color/chat_bubble_text_color"
|
||||
android:textSize="13sp"
|
||||
android:textStyle="normal"
|
||||
android:visibility="@{data.hideTime ? View.GONE : View.VISIBLE}" />
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_alignBottom="@id/background"
|
||||
android:layout_toRightOf="@id/background"
|
||||
android:indeterminateTint="?attr/accentColor"
|
||||
android:visibility="@{data.transferInProgress || data.sendInProgress ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue