<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Nextcloud Talk application
  ~
  ~ @author Mario Danic
  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  ~
  ~
  ~
  ~ 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:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp">

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

            <ImageView
                android:id="@id/dialogAvatar"
                android:contentDescription="@null"
                android:layout_width="@dimen/avatar_size"
                android:layout_height="@dimen/avatar_size"
                tools:src="@drawable/ic_call_black_24dp"/>

            <ImageView
                android:id="@+id/passwordProtectedRoomImageView"
                android:layout_width="12dp"
                android:layout_height="12dp"
                android:layout_gravity="bottom|end"
                android:background="@drawable/shape_lock_bubble"/>

            <ImageView
                android:id="@+id/favoriteConversationImageView"
                android:layout_width="12dp"
                android:layout_height="12dp"
                android:layout_gravity="top|end"
                android:background="@drawable/shape_favorite_bubble"/>
        </FrameLayout>

        <TextView
            android:id="@id/dialogName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/dialogAvatarFrameLayout"
            android:layout_marginStart="8dp"
            android:layout_toEndOf="@id/dialogAvatarFrameLayout"
            android:layout_toStartOf="@id/dialogDate"
            android:ellipsize="end"
            android:includeFontPadding="false"
            android:maxLines="1"
            android:textColor="@color/nc_incoming_text_default"
            android:textSize="16sp"
            tools:text="Best conversation"/>

        <TextView
            android:id="@id/dialogDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:ellipsize="end"
            android:maxLines="1"
            android:textColor="@color/warm_grey_two"/>

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

            <ImageView
                android:id="@id/dialogLastMessageUserAvatar"
                android:contentDescription="@null"
                android:layout_width="@dimen/small_item_height"
                android:layout_height="@dimen/small_item_height"
                android:layout_marginEnd="8dp"
                tools:src="@drawable/ic_call_black_24dp"/>

            <TextView
                android:id="@id/dialogLastMessage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toEndOf="@id/dialogLastMessageUserAvatar"
                android:layout_toStartOf="@id/dialogUnreadBubble"
                android:ellipsize="end"
                android:gravity="top"
                android:lines="2"
                android:singleLine="false"
                android:textColor="@color/warm_grey_four"
                tools:text="This is the last message\nof an incredibly long two line  conversation text"/>

            <TextView
                android:id="@id/dialogUnreadBubble"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginStart="8dp"
                android:background="@drawable/bubble_circle_unread"
                android:gravity="center"
                android:lines="1"
                android:textAlignment="center"
                android:textColor="@color/white"
                tools:text="1"/>

        </RelativeLayout>

    </RelativeLayout>
</RelativeLayout>
