<?xml version="1.0" encoding="utf-8"?>
<!--

IMPORTANT NOTE!

There's an alternative XML file in layout!

-->
<com.google.android.material.card.MaterialCardView
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
	android:id="@+id/list_item"
	android:layout_width="match_parent"
	android:layout_height="@dimen/messagelist_item_height"
	android:clickable="true"
	android:focusable="true"
	android:foreground="@drawable/listitem_background_selector"
	app:cardBackgroundColor="?attr/background_secondary"
	app:cardCornerRadius="@dimen/messagelist_card_corner_radius"
	app:cardElevation="0dp"
	app:cardPreventCornerOverlap="false"
	app:cardUseCompatPadding="false">

	<RelativeLayout
		android:id="@+id/list_item_fg"
		android:layout_width="match_parent"
		android:layout_height="@dimen/messagelist_item_height"
		android:background="?android:attr/windowBackground"
		android:paddingLeft="@dimen/listitem_message_margin_left_right"
		android:paddingRight="@dimen/listitem_message_margin_left_right">

		<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_centerVertical="true"
			android:clickable="true"
			android:contentDescription="@string/show_contact"
			android:foreground="@drawable/selector_avatar"
			/>

		<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_view">

			<ImageView
				android:id="@+id/mute_status"
				android:layout_width="18dp"
				android:layout_height="18dp"
				android:layout_alignParentLeft="true"
				android:layout_alignWithParentIfMissing="true"
				android:layout_marginLeft="-1dp"
				android:layout_marginRight="3dp"
				android:layout_marginTop="2dp"
				android:visibility="gone"
				app:srcCompat="@drawable/ic_notifications_active_outline"/>

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

			<ImageView
				android:id="@+id/pin_icon"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignBottom="@id/from"
				android:layout_alignWithParentIfMissing="true"
				android:layout_marginBottom="1dp"
				android:layout_marginLeft="3dp"
				android:layout_toLeftOf="@+id/unread_count"
				app:srcCompat="@drawable/ic_pin_circle"
				/>

			<ch.threema.app.ui.CountBoxView
				android:id="@+id/unread_count"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignBottom="@id/from"
				android:layout_alignParentRight="true"
				android:layout_alignWithParentIfMissing="true"
				android:layout_marginBottom="2dp"
				android:layout_marginLeft="3dp"
				android:visibility="visible"/>

			<FrameLayout
				android:id="@+id/typing_container"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@id/from"
				android:visibility="gone">

				<TextView
					android:id="@+id/is_typing"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:fontFamily="sans-serif-light"
					android:singleLine="true"
					android:text="@string/is_typing"
					android:textColor="@null"
					android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"/>
			</FrameLayout>

			<RelativeLayout
				android:id="@+id/latest_message_container"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@id/from"
				android:visibility="visible">

				<ImageView
					android:id="@+id/delivery"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignBottom="@+id/date"
					android:layout_alignParentRight="true"
					android:layout_marginRight="-2dp"
					android:layout_marginBottom="-1dp"
					android:visibility="visible"
					app:srcCompat="@drawable/ic_attachment"
					app:tint="?attr/textColorSecondary" />

				<TextView
					android:id="@+id/date"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignWithParentIfMissing="true"
					android:layout_marginLeft="4dp"
					android:layout_marginRight="2dp"
					android:layout_marginTop="2sp"
					android:layout_toLeftOf="@id/delivery"
					android:singleLine="true"
					android:text="Date"
					android:textAppearance="@style/Threema.TextAppearance.List.ThirdLine"/>

				<ch.threema.app.emojis.EmojiTextView
					android:id="@+id/group_member_name"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignBaseline="@id/date"
					android:layout_alignWithParentIfMissing="true"
					android:singleLine="true"
					android:text="Member: "
					android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"/>

				<ImageView
					android:id="@+id/attachment"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignBottom="@id/date"
					android:layout_alignWithParentIfMissing="true"
					android:layout_marginLeft="-5dp"
					android:layout_marginRight="-3dp"
					android:layout_toRightOf="@id/group_member_name"
					android:tint="?attr/textColorSecondary"
					android:visibility="visible"
					app:srcCompat="@drawable/ic_attachment"/>

				<ch.threema.app.emojis.EmojiTextView
					android:id="@+id/subject"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignBaseline="@id/date"
					android:layout_alignWithParentIfMissing="true"
					android:layout_marginRight="2dp"
					android:layout_toLeftOf="@id/date"
					android:layout_toRightOf="@id/attachment"
					android:ellipsize="none"
					android:singleLine="true"
					android:text="Subject"
					android:textAppearance="@style/Threema.TextAppearance.List.SecondLine"/>

			</RelativeLayout>

		</RelativeLayout>

	</RelativeLayout>

	<LinearLayout
		android:layout_width="wrap_content"
		android:layout_height="match_parent">

		<View
			android:id="@+id/unread_view"
			android:layout_width="5dp"
			android:layout_height="match_parent"
			android:background="@color/messagelist_highlight_color"
			android:visibility="visible"/>

		<View
			android:id="@+id/tag_star_on"
			android:layout_width="5dp"
			android:layout_height="match_parent"
			android:background="@color/messagelist_pinned_color"
			android:visibility="visible"/>
	</LinearLayout>

	<ImageView
		android:id="@+id/hidden_status"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		app:srcCompat="@drawable/ic_incognito"
		android:layout_gravity="right|top"
		android:contentDescription="@string/private_chat_subject"/>

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