<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ F7cloud Talk - Android Client
  ~
  ~ SPDX-FileCopyrightText: 2021, 2025 Andy Scherzinger <info@andy-scherzinger.de>
  ~ SPDX-FileCopyrightText: 2021 Marcel Hibbe <dev@mhibbe.de>
  ~ SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com>
  ~ SPDX-License-Identifier: GPL-3.0-or-later
-->
<RelativeLayout 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_marginStart="@dimen/standard_margin"
    android:layout_marginTop="2dp"
    android:layout_marginEnd="@dimen/standard_margin"
    android:layout_marginBottom="2dp">

    <ImageView
        android:id="@id/messageUserAvatar"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="6dp"
        android:contentDescription="@string/avatar" />

    <androidx.emoji2.widget.EmojiTextView
        android:id="@+id/messageAuthor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:layout_toEndOf="@id/messageUserAvatar"
        android:alpha="0.6"
        android:textAlignment="viewStart"
        android:textColor="@color/no_emphasis_text"
        android:textIsSelectable="false"
        android:textSize="12sp"
        tools:ignore="TextContrastCheck"
        tools:text="Jane Doe" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/messageAuthor"
        android:layout_toEndOf="@id/messageUserAvatar"
        android:orientation="vertical">

        <com.google.android.flexbox.FlexboxLayout
            android:id="@+id/bubble"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:orientation="vertical"
            app:alignContent="stretch"
            app:alignItems="stretch"
            app:flexWrap="wrap"
            app:justifyContent="flex_end">

            <LinearLayout
                android:id="@+id/threadTitleWrapperContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:paddingStart="@dimen/standard_padding"
                android:paddingTop="@dimen/standard_padding"
                android:paddingEnd="@dimen/standard_padding"
                android:paddingBottom="@dimen/standard_half_padding"
                app:layout_alignSelf="flex_start"
                app:layout_flexGrow="1">

                <include
                    android:id="@+id/threadTitleWrapper"
                    layout="@layout/item_thread_title"
                    android:visibility="gone"
                    tools:visibility="visible" />
            </LinearLayout>

            <FrameLayout
                android:id="@+id/preview_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                app:layout_alignSelf="flex_start"
                app:layout_flexGrow="1"
                app:layout_wrapBefore="true"
                tools:visibility="gone">

                <ImageView
                    android:id="@id/image"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="fitStart"
                    tools:ignore="ContentDescription"
                    tools:src="@drawable/ic_call_black_24dp" />

                <ProgressBar
                    android:id="@+id/progress_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:visibility="gone" />
            </FrameLayout>

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/contact_container"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:layout_marginBottom="1dp"
                app:cardCornerRadius="@dimen/dialogBorderRadius"
                app:cardElevation="2dp"
                app:layout_alignSelf="flex_start"
                app:layout_flexGrow="1"
                app:layout_wrapBefore="true"
                app:strokeWidth="0dp">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="@dimen/standard_padding">

                    <FrameLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:adjustViewBounds="true">

                        <ImageView
                            android:id="@+id/contact_photo"
                            android:layout_width="@dimen/small_item_height"
                            android:layout_height="@dimen/small_item_height"
                            android:scaleType="fitStart"
                            tools:ignore="ContentDescription"
                            tools:src="@drawable/ic_call_black_24dp" />

                        <ProgressBar
                            android:id="@+id/contact_progress_bar"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:visibility="gone"
                            tools:visibility="visible" />
                    </FrameLayout>

                    <androidx.emoji2.widget.EmojiTextView
                        android:id="@+id/contact_name"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:autoLink="none"
                        android:ellipsize="middle"
                        android:gravity="start|center_vertical"
                        android:maxLines="3"
                        android:paddingStart="@dimen/standard_padding"
                        android:paddingEnd="0dp"
                        android:textAlignment="viewStart"
                        android:textColor="@color/high_emphasis_text"
                        android:textColorLink="@color/high_emphasis_text"
                        android:textIsSelectable="false"
                        android:textSize="16sp"
                        app:layout_alignSelf="flex_start"
                        app:layout_flexGrow="1"
                        app:layout_wrapBefore="true"
                        tools:text="Charlotte D. Meyerheimers" />

                </LinearLayout>

            </com.google.android.material.card.MaterialCardView>

            <androidx.emoji2.widget.EmojiTextView
                android:id="@id/messageText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="2dp"
                android:alpha="0.6"
                android:autoLink="none"
                android:paddingHorizontal="@dimen/standard_half_padding"
                android:paddingBottom="@dimen/standard_half_padding"
                android:textAlignment="viewStart"
                android:textColor="@color/no_emphasis_text"
                android:textColorLink="@color/no_emphasis_text"
                android:textIsSelectable="true"
                android:textSize="12sp"
                app:layout_alignSelf="flex_start"
                app:layout_flexGrow="1"
                app:layout_wrapBefore="true"
                tools:ignore="TextContrastCheck"
                tools:text="A simple message" />

            <androidx.emoji2.widget.EmojiTextView
                android:id="@+id/messageCaption"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|center"
                android:layout_marginStart="2dp"
                android:layout_marginBottom="4dp"
                android:paddingStart="@dimen/standard_half_padding"
                android:paddingEnd="@dimen/standard_half_padding"
                android:paddingBottom="@dimen/standard_half_padding"
                android:textColor="@color/high_emphasis_text"
                android:textIsSelectable="false"
                android:textSize="@dimen/chat_text_size"
                android:visibility="gone"
                tools:ignore="TextContrastCheck"
                tools:text="This is my caption"
                tools:visibility="visible" />

            <TextView
                android:id="@id/messageTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginBottom="8dp"
                android:alpha="0.6"
                android:gravity="end"
                android:layout_below="@id/messageCaption"
                android:textColor="@color/no_emphasis_text"
                app:layout_alignSelf="flex_end"
                tools:ignore="TextContrastCheck"
                tools:text="12:38" />

            <TextView
                android:id="@+id/messageEditIndicator"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="12dp"
                android:layout_marginBottom="8dp"
                android:alpha="0.6"
                android:text="@string/hint_edited_message"
                android:textColor="@color/no_emphasis_text"
                android:layout_below="@id/messageCaption"
                android:textIsSelectable="false"
                android:textSize="12sp"
                app:layout_alignSelf="flex_end" />


        </com.google.android.flexbox.FlexboxLayout>

        <include
            android:id="@+id/reactions"
            layout="@layout/reactions_inside_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/bubble"
            android:layout_marginStart="@dimen/message_bubble_corners_horizontal_padding"
            android:layout_marginTop="-4dp" />

    </RelativeLayout>

</RelativeLayout>