<?xml version="1.0" encoding="utf-8"?>
<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_height="wrap_content"
    android:layout_marginHorizontal="8dp"
    android:background="@drawable/selectable_list_item_background"
    android:clipToPadding="false"
    android:paddingHorizontal="8dp"
    android:paddingTop="6dp"
    android:paddingBottom="6dp">

    <org.thoughtcrime.securesms.components.AvatarImageView
        android:id="@+id/avatar"
        android:layout_width="28dp"
        android:layout_height="28dp"
        app:fallbackImageSize="small"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/bubble_start_barrier"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:barrierDirection="end"
        app:barrierMargin="8dp"
        app:constraint_referenced_ids="avatar" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/bubble_end_barrier"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:barrierDirection="end"
        app:barrierMargin="12dp"
        app:constraint_referenced_ids="viewed_at,viewed_at_below,delivery_status,name,body" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/message_content_end_barrier"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:barrierDirection="start"
        app:barrierMargin="-8dp"
        app:constraint_referenced_ids="alert_view,spacer" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/viewed_at_end_barrier"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:barrierDirection="end"
        app:barrierMargin="0dp"
        app:constraint_referenced_ids="viewed_at,viewed_at_below" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/viewed_at_bottom_barrier"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:barrierDirection="bottom"
        app:barrierMargin="0dp"
        app:constraint_referenced_ids="viewed_at,viewed_at_below" />

    <View
        android:id="@+id/bubble"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@drawable/rounded_rectangle_secondary_18"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/bubble_end_barrier"
        app:layout_constraintStart_toStartOf="@+id/bubble_start_barrier"
        app:layout_constraintTop_toTopOf="parent" />

    <org.thoughtcrime.securesms.components.FromTextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginTop="7dp"
        android:layout_marginEnd="12dp"
        android:textAppearance="@style/TextAppearance.Signal.Subtitle.Bold"
        app:layout_constrainedWidth="true"
        app:layout_constraintEnd_toEndOf="@+id/message_content_end_barrier"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toStartOf="@+id/bubble_start_barrier"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="Miles Morales" />

    <org.thoughtcrime.securesms.components.emoji.EmojiTextView
        android:id="@+id/body"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginTop="1dp"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="1dp"
        android:textAppearance="@style/Signal.Text.Body"
        app:layout_constrainedWidth="true"
        app:layout_constraintBottom_toTopOf="@id/viewed_at_below"
        app:layout_constraintEnd_toEndOf="@+id/message_content_end_barrier"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toStartOf="@+id/bubble_start_barrier"
        app:layout_constraintTop_toBottomOf="@id/name"
        app:layout_goneMarginBottom="7dp"
        app:measureLastLine="true"
        tools:text="This is a very long message that is supposed to properly wrap when it hits the end." />

    <TextView
        android:id="@+id/viewed_at"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:layout_marginBottom="5dp"
        android:textAppearance="@style/Signal.Text.Caption"
        android:textColor="@color/transparent_white_60"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="1"
        app:layout_constraintStart_toEndOf="@id/body"
        tools:text="15m"
        tools:textColor="@color/signal_text_secondary"
        tools:visibility="visible" />

    <TextView
        android:id="@+id/viewed_at_below"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginBottom="5dp"
        android:textAppearance="@style/Signal.Text.Caption"
        android:textColor="@color/transparent_white_60"
        android:visibility="gone"
        app:layout_constrainedWidth="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/message_content_end_barrier"
        app:layout_constraintHorizontal_bias="1"
        app:layout_constraintStart_toStartOf="@+id/bubble_start_barrier"
        tools:text="Not sent, tap for details"
        tools:textColor="@color/signal_text_secondary" />

    <org.thoughtcrime.securesms.components.DeliveryStatusView
        android:id="@+id/delivery_status"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_marginStart="6dp"
        android:layout_marginBottom="5dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/viewed_at_bottom_barrier"
        app:layout_constraintStart_toEndOf="@+id/viewed_at_end_barrier" />

    <org.thoughtcrime.securesms.components.AlertView
        android:id="@+id/alert_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:visibility="gone"
        app:layout_goneMarginEnd="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/reaction"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toEndOf="@+id/bubble_end_barrier"
        tools:visibility="gone" />

    <Space
        android:id="@+id/spacer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_goneMarginEnd="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/reaction"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toEndOf="@+id/bubble_end_barrier" />

    <org.thoughtcrime.securesms.components.emoji.EmojiImageView
        android:id="@+id/reaction"
        android:layout_width="28dp"
        android:layout_height="28dp"
        android:layout_marginStart="8dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>