<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingHorizontal="@dimen/bubble_horizontal_padding"
        android:paddingVertical="@dimen/bubble_vertical_padding">

        <com.google.android.material.imageview.ShapeableImageView
            android:id="@+id/message_photo"
            android:layout_width="@dimen/bubble_avatar_size"
            android:layout_height="@dimen/bubble_avatar_size"
            android:scaleType="fitXY"
            app:layout_constraintBottom_toBottomOf="@id/message_box"
            app:layout_constraintEnd_toEndOf="parent"
            app:shapeAppearanceOverlay="@style/ShapeAppearance.RoundedCornersMedium"/>


        <LinearLayout
            android:id="@+id/message_box"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/bubble_avatar_distance"
            android:background="@drawable/background_message_bubble"
            android:backgroundTint="?colorSecondaryContainer"
            android:longClickable="true"
            android:minHeight="@dimen/bubble_avatar_size"
            app:layout_constrainedWidth="true"
            app:layout_constraintEnd_toStartOf="@id/message_photo"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:gravity="center_vertical"
                android:orientation="vertical">

                <include
                    android:id="@+id/message_content"
                    layout="@layout/item_message_content" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end"
                    android:layout_marginHorizontal="10dp"
                    android:layout_marginVertical="4dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/message_time"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_marginEnd="2sp"
                        android:accessibilityTraversalAfter="@id/message_photo"
                        android:accessibilityTraversalBefore="@id/message_content"
                        android:gravity="center_vertical"
                        android:text="@string/sending"
                        android:textAppearance="?textAppearanceBodySmall"
                        android:textColor="?colorOnSecondaryContainer" />

                    <ImageView
                        android:id="@+id/security_indicator"
                        android:layout_width="12sp"
                        android:layout_height="12sp"
                        android:layout_gravity="center_vertical"
                        android:layout_marginStart="4sp"
                        android:gravity="center_vertical"
                        android:src="@drawable/ic_lock_24dp"
                        app:tint="?colorOnSecondaryContainer" />

                    <ImageView
                        android:id="@+id/edit_indicator"
                        android:layout_width="12sp"
                        android:layout_height="12sp"
                        android:layout_gravity="center_vertical"
                        android:layout_marginStart="4sp"
                        android:gravity="center_vertical"
                        android:src="@drawable/ic_edit_24dp"
                        app:tint="?colorOnSecondaryContainer" />

                    <ImageView
                        android:id="@+id/indicator_received"
                        android:layout_width="16sp"
                        android:layout_height="16sp"
                        android:layout_gravity="center_vertical"
                        android:layout_marginStart="4sp"
                        android:gravity="center_vertical"
                        android:src="@drawable/ic_done_24dp"
                        app:tint="?colorOnSecondaryContainer" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <Space
            android:id="@+id/reactions_anchor"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="4dp"
            app:layout_constraintBottom_toBottomOf="@+id/message_box"
            app:layout_constraintEnd_toEndOf="@+id/message_box" />

        <com.google.android.material.chip.ChipGroup
            android:id="@+id/reactions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="10dp"
            android:orientation="horizontal"
            android:visibility="visible"
            app:chipSpacingHorizontal="4dp"
            app:chipSpacingVertical="4dp"
            app:layout_constrainedWidth="true"
            app:layout_constraintEnd_toEndOf="@+id/message_box"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/reactions_anchor" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>