<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Nextcloud Talk - Android Client
  ~
  ~ SPDX-FileCopyrightText: 2022 Tim Krüger <t@timkrueger.me>
  ~ SPDX-FileCopyrightText: 2021 Andy Scherzinger <info@andy-scherzinger.de>
  ~ SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com>
  ~ SPDX-License-Identifier: GPL-3.0-or-later
  ~
  ~ Adapted from https://github.com/stfalcon-studio/ChatKit/blob/master/chatkit/src/main/res/layout/item_dialog.xml
-->
<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_margin="@dimen/double_margin_between_elements">

    <FrameLayout
        android:id="@+id/dialogAvatarFrameLayout"
        android:layout_width="@dimen/small_item_height"
        android:layout_height="@dimen/small_item_height"
        android:layout_centerVertical="true"
        android:layout_marginEnd="@dimen/double_margin_between_elements">

        <ImageView
            android:id="@id/dialogAvatar"
            android:layout_width="@dimen/small_item_height"
            android:layout_height="@dimen/small_item_height"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/favoriteConversationImageView"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:layout_gravity="top|end"
            android:contentDescription="@string/starred"
            android:src="@drawable/ic_star_black_24dp"
            app:tint="@color/favorite_icon_tint"
            app:tintMode="src_in" />

        <ImageView
            android:id="@+id/user_status_image"
            android:layout_width="18dp"
            android:layout_height="18dp"
            android:layout_gravity="bottom|end"
            android:contentDescription="@string/nc_account_chooser_active_user"
            tools:src="@drawable/emoji_one_category_smileysandpeople"/>
    </FrameLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/dialogName"
        android:layout_marginTop="6dp"
        android:layout_toEndOf="@id/dialogAvatarFrameLayout">

        <androidx.emoji2.widget.EmojiTextView
            android:id="@id/dialogLastMessage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toStartOf="@id/dialogUnreadBubble"
            android:ellipsize="end"
            android:gravity="start|top"
            android:lines="1"
            android:singleLine="true"
            android:textAlignment="viewStart"
            android:textColor="@color/textColorMaxContrast"
            android:textSize="14sp"
            tools:text="This is the last message\nof an incredibly long two line  conversation text" />

        <com.google.android.material.chip.Chip
            android:id="@+id/dialogUnreadBubble"
            style="@style/Widget.MaterialComponents.Chip.Choice"
            android:layout_width="wrap_content"
            android:layout_height="18dp"
            android:layout_alignParentEnd="true"
            android:layout_marginStart="8dp"
            android:clickable="false"
            android:gravity="top"
            android:lines="1"
            android:textAppearance="@style/ChipUnreadMessagesTextAppearance"
            android:textColor="@color/conversation_unread_bubble_text"
            app:chipBackgroundColor="@color/conversation_unread_bubble"
            app:chipEndPadding="-1dp"
            app:chipMinTouchTargetSize="0dp"
            app:chipStartPadding="-3dp"
            app:ensureMinTouchTargetSize="false"
            tools:text="999+" />

    </RelativeLayout>

    <TextView
        android:id="@id/dialogDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="2dp"
        android:ellipsize="end"
        android:maxLines="1"
        android:textAlignment="viewEnd"
        android:textColor="@color/textColorMaxContrast"
        android:textSize="14sp"
        tools:text="yesterday" />

    <androidx.emoji2.widget.EmojiTextView
        android:id="@id/dialogName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@id/dialogAvatarFrameLayout"
        android:layout_marginTop="2dp"
        android:layout_toStartOf="@id/dialogDate"
        android:layout_toEndOf="@id/dialogAvatarFrameLayout"
        android:ellipsize="end"
        android:includeFontPadding="false"
        android:maxLines="1"
        android:textAlignment="viewStart"
        android:textColor="@color/conversation_item_header"
        android:textSize="@dimen/two_line_primary_text_size"
        tools:text="Best conversation" />

</RelativeLayout>
