Weird workaround for multi line chat bubble displayed with wrong width
This commit is contained in:
parent
cacf1f4472
commit
5ef5564b6d
1 changed files with 160 additions and 152 deletions
|
@ -29,181 +29,189 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<CheckBox
|
<!-- Weirdly enough this "useless" RelativeLayout prevents the measuring issue
|
||||||
android:id="@+id/select"
|
in child LinearLayout (which size depends on the MultiLineWrapContentWidthTextView) -->
|
||||||
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
<RelativeLayout
|
||||||
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
android:layout_width="match_parent"
|
||||||
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
android:layout_height="wrap_content">
|
||||||
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 -->
|
<CheckBox
|
||||||
<View
|
android:id="@+id/select"
|
||||||
android:id="@+id/rightMark"
|
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
||||||
android:layout_width="8dp"
|
android:visibility="@{selectionListViewModel.isEditionEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_height="1dp"
|
android:checked="@{selectionListViewModel.selectedItems.contains(position)}"
|
||||||
android:layout_alignParentRight="true" />
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignTop="@id/background"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginRight="5dp" />
|
||||||
|
|
||||||
<ImageView
|
<!-- To align with security badge if visible -->
|
||||||
android:id="@+id/imdn"
|
<View
|
||||||
android:visibility="@{viewModel.chatMessage.outgoing ? (viewModel.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}"
|
android:id="@+id/rightMark"
|
||||||
android:src="@{viewModel.imdnIcon, default=@drawable/chat_delivered}"
|
android:layout_width="8dp"
|
||||||
android:contentDescription="@string/content_description_delivery_status"
|
android:layout_height="1dp"
|
||||||
android:layout_width="10dp"
|
android:layout_alignParentRight="true" />
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_toLeftOf="@{selectionListViewModel.isEditionEnabled ? @id/select : @id/rightMark}"
|
|
||||||
android:layout_alignBottom="@id/background" />
|
|
||||||
|
|
||||||
<org.linphone.contact.ContactAvatarView
|
<ImageView
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/imdn"
|
||||||
android:visibility="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (viewModel.hideAvatar ? View.INVISIBLE : View.VISIBLE)}"
|
android:visibility="@{viewModel.chatMessage.outgoing ? (viewModel.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}"
|
||||||
android:layout_width="wrap_content"
|
android:src="@{viewModel.imdnIcon, default=@drawable/chat_delivered}"
|
||||||
android:layout_height="wrap_content"
|
android:contentDescription="@string/content_description_delivery_status"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_width="10dp"
|
||||||
android:layout_below="@id/time"
|
android:layout_height="10dp"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_toLeftOf="@{selectionListViewModel.isEditionEnabled ? @id/select : @id/rightMark}"
|
||||||
android:gravity="center"
|
android:layout_alignBottom="@id/background" />
|
||||||
app:viewModel="@{viewModel}"
|
|
||||||
tools:layout="@layout/contact_avatar" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<org.linphone.contact.ContactAvatarView
|
||||||
android:id="@+id/background"
|
android:id="@+id/avatar"
|
||||||
android:onClick="@{clickListener}"
|
android:visibility="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (viewModel.hideAvatar ? View.INVISIBLE : View.VISIBLE)}"
|
||||||
android:onLongClick="@{contextMenuClickListener}"
|
android:layout_width="wrap_content"
|
||||||
android:background="@{viewModel.backgroundRes, default=@drawable/chat_bubble_outgoing_full}"
|
android:layout_height="wrap_content"
|
||||||
android:descendantFocusability="blocksDescendants"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_below="@id/time"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginLeft="5dp"
|
||||||
android:orientation="vertical"
|
android:gravity="center"
|
||||||
android:layout_toLeftOf="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}"
|
app:viewModel="@{viewModel}"
|
||||||
android:layout_toRightOf="@id/avatar"
|
tools:layout="@layout/contact_avatar" />
|
||||||
android:layout_below="@id/time"
|
|
||||||
android:layout_marginBottom="1dp"
|
|
||||||
android:layout_marginRight="3dp"
|
|
||||||
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !viewModel.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:paddingBottom="5dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:visibility="@{viewModel.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
android:id="@+id/background"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical|right"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:layout_marginLeft="5dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
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>
|
|
||||||
|
|
||||||
<com.google.android.flexbox.FlexboxLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:longClickable="true"
|
|
||||||
app:entries="@{viewModel.contents}"
|
|
||||||
app:layout="@{@layout/chat_message_content_cell}"
|
|
||||||
app:onLongClick="@{contextMenuClickListener}"
|
|
||||||
app:flexWrap="wrap"
|
|
||||||
app:justifyContent="@{viewModel.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"/>
|
|
||||||
|
|
||||||
<org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView
|
|
||||||
android:onClick="@{clickListener}"
|
android:onClick="@{clickListener}"
|
||||||
android:onLongClick="@{contextMenuClickListener}"
|
android:onLongClick="@{contextMenuClickListener}"
|
||||||
android:text="@{viewModel.text}"
|
android:background="@{viewModel.backgroundRes, default=@drawable/chat_bubble_outgoing_full}"
|
||||||
android:visibility="@{viewModel.text.length > 0 ? View.VISIBLE : View.GONE}"
|
android:descendantFocusability="blocksDescendants"
|
||||||
android:autoLink="web"
|
|
||||||
android:layout_gravity="@{viewModel.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:orientation="vertical"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_toLeftOf="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_toRightOf="@id/avatar"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_below="@id/time"
|
||||||
android:longClickable="true"
|
android:layout_marginBottom="1dp"
|
||||||
android:textColor="@color/dark_grey_color"
|
android:layout_marginRight="3dp"
|
||||||
android:textSize="15sp"
|
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !viewModel.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
|
||||||
android:fontFamily="sans-serif"
|
android:paddingTop="5dp"
|
||||||
android:textStyle="normal"
|
android:paddingBottom="5dp">
|
||||||
android:lineSpacingExtra="-1.7sp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:visibility="@{viewModel.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{viewModel.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:gravity="center_vertical|right"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:layout_marginLeft="5dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="@{viewModel.ephemeralLifetime}"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical|right"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:textColor="@color/primary_color"
|
android:layout_marginLeft="5dp">
|
||||||
android:textSize="12sp"
|
|
||||||
|
<ImageView
|
||||||
|
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>
|
||||||
|
|
||||||
|
<com.google.android.flexbox.FlexboxLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:longClickable="true"
|
||||||
|
app:entries="@{viewModel.contents}"
|
||||||
|
app:layout="@{@layout/chat_message_content_cell}"
|
||||||
|
app:onLongClick="@{contextMenuClickListener}"
|
||||||
|
app:flexWrap="wrap"
|
||||||
|
app:justifyContent="@{viewModel.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"/>
|
||||||
|
|
||||||
|
<org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView
|
||||||
|
android:onClick="@{clickListener}"
|
||||||
|
android:onLongClick="@{contextMenuClickListener}"
|
||||||
|
android:text="@{viewModel.text}"
|
||||||
|
android:visibility="@{viewModel.text.length > 0 ? View.VISIBLE : View.GONE}"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:layout_gravity="@{viewModel.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:fontFamily="sans-serif"
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
android:lineSpacingExtra="3.3sp" />
|
android:lineSpacingExtra="-1.7sp"/>
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
|
android:visibility="@{viewModel.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="13dp"
|
android:layout_height="wrap_content"
|
||||||
android:adjustViewBounds="true"
|
android:orientation="horizontal"
|
||||||
android:contentDescription="@string/content_description_ephemeral_message"
|
android:layout_gravity="right"
|
||||||
android:src="@drawable/ephemeral_messages"/>
|
android:gravity="center_vertical|right"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_marginLeft="5dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@{viewModel.ephemeralLifetime}"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:textColor="@color/primary_color"
|
||||||
|
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>
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:text="@{viewModel.chatMessage.outgoing ? viewModel.time : viewModel.time + ` - ` + (viewModel.contact.fullName ?? viewModel.displayName)}"
|
||||||
|
android:visibility="@{viewModel.hideTime ? View.GONE : View.VISIBLE}"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignLeft="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}"
|
||||||
|
android:layout_alignRight="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:textColor="@color/chat_bubble_text_color"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:textStyle="normal"
|
||||||
|
android:lineSpacingExtra="0sp" />
|
||||||
|
|
||||||
<TextView
|
<ProgressBar
|
||||||
android:id="@+id/time"
|
android:visibility="@{viewModel.transferInProgress || viewModel.sendInProgress ? View.VISIBLE : View.GONE}"
|
||||||
android:text="@{viewModel.chatMessage.outgoing ? viewModel.time : viewModel.time + ` - ` + (viewModel.contact.fullName ?? viewModel.displayName)}"
|
android:layout_width="10dp"
|
||||||
android:visibility="@{viewModel.hideTime ? View.GONE : View.VISIBLE}"
|
android:layout_height="10dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_toRightOf="@id/background"
|
||||||
android:layout_height="wrap_content"
|
android:layout_alignBottom="@id/background"
|
||||||
android:layout_alignParentTop="true"
|
android:indeterminateTint="?attr/accentColor" />
|
||||||
android:layout_alignLeft="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}"
|
|
||||||
android:layout_alignRight="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}"
|
|
||||||
android:layout_marginTop="7dp"
|
|
||||||
android:textColor="@color/chat_bubble_text_color"
|
|
||||||
android:textSize="13sp"
|
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
android:textStyle="normal"
|
|
||||||
android:lineSpacingExtra="0sp" />
|
|
||||||
|
|
||||||
<ProgressBar
|
</RelativeLayout>
|
||||||
android:visibility="@{viewModel.transferInProgress || viewModel.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" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue