<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2019-2024 Threema GmbH
  ~ All rights reserved.
  -->

<ch.threema.app.ui.CheckableRelativeLayout
	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:id="@+id/list_item"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:background="@drawable/listitem_background_selector"
	android:paddingHorizontal="@dimen/listitem_standard_margin_left_right"
	android:paddingVertical="@dimen/listitem_standard_margin_top_bottom">

	<ch.threema.app.ui.CheckableFrameLayout
		android:id="@+id/avatar_frame"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginTop="2dp"
		android:duplicateParentState="true">

		<ch.threema.app.ui.AvatarView
			android:id="@+id/avatar_view"
			android:layout_width="@dimen/avatar_size_small"
			android:layout_height="@dimen/avatar_size_small"
			android:layout_gravity="center_vertical"
			android:stateListAnimator="@animator/selector_list_checkbox_bg"
			android:duplicateParentState="true"
			android:visibility="visible"/>

		<ch.threema.app.ui.CheckableView
			android:id="@+id/check_box"
			android:layout_width="@dimen/avatar_size_small"
			android:layout_height="@dimen/avatar_size_small"
			android:layout_gravity="center_vertical"
			android:background="@drawable/selector_list_checkbox"
			android:stateListAnimator="@animator/selector_list_checkbox_fg"
			android:duplicateParentState="true"/>

	</ch.threema.app.ui.CheckableFrameLayout>

	<RelativeLayout
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_centerVertical="true"
		android:layout_marginLeft="@dimen/messagelist_avatar_padding"
		android:layout_toRightOf="@id/avatar_frame">

		<ch.threema.app.emojis.EmojiTextView
			android:id="@+id/from"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
            android:minHeight="@dimen/listitem_min_height_first_line"
			android:layout_alignParentLeft="true"
			android:layout_alignWithParentIfMissing="true"
			android:ellipsize="end"
			android:singleLine="true"
			android:text="Title"
			android:textAppearance="@style/Threema.TextAppearance.List.FirstLine"/>

		<androidx.constraintlayout.widget.ConstraintLayout
			android:id="@+id/latest_message_container"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_below="@id/from"
			android:visibility="visible">

            <ch.threema.app.emojis.EmojiTextView
                android:id="@+id/group_member_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"
                android:fontFamily="sans-serif-light"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toLeftOf="@id/attachment"
                app:layout_constrainedWidth="true"
                tools:text="Member: "/>

            <ImageView
                android:id="@+id/attachment"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:translationY="0.5dp"
                android:importantForAccessibility="no"
                android:visibility="visible"
                app:tint="?attr/colorOnSurface"
                app:srcCompat="@drawable/ic_attachment"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toRightOf="@id/group_member_name"
                app:layout_constraintRight_toLeftOf="@id/subject"/>

            <!-- app:layout_constraintWidth_min="1dp" is a hack to ensure correct constraint when group_member_name overflows -->
			<ch.threema.app.emojis.EmojiTextView
				android:id="@+id/subject"
				android:layout_width="0dp"
				android:layout_height="wrap_content"
                android:minHeight="@dimen/listitem_min_height_second_line"
				android:ellipsize="none"
				android:singleLine="true"
				android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"
                app:layout_constraintWidth_min="1dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toRightOf="@id/attachment"
                app:layout_constraintRight_toLeftOf="@id/date"
                tools:text="Subject"/>

			<TextView
				android:id="@+id/date"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:paddingLeft="4dp"
				android:fontFamily="sans-serif-light"
				android:singleLine="true"
				android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintRight_toLeftOf="@id/delivery"
                app:layout_constraintLeft_toRightOf="@id/subject"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="3:15 PM"/>

			<ImageView
				android:id="@+id/delivery"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:paddingLeft="2dp"
				android:translationY="0.5dp"
				android:visibility="visible"
                android:importantForAccessibility="no"
				app:srcCompat="@drawable/ic_attachment"
                app:tint="?attr/colorOnSurface"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>

		</androidx.constraintlayout.widget.ConstraintLayout>

	</RelativeLayout>

</ch.threema.app.ui.CheckableRelativeLayout>
