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

<androidx.constraintlayout.widget.ConstraintLayout 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/topLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:focusable="false"
    android:paddingRight="@dimen/listitem_contacts_margin_left_right"
    android:paddingBottom="12dp">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/recently_added_background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:layout_marginLeft="8dp"
        android:clickable="true"
        android:focusable="true"
        app:cardBackgroundColor="?attr/colorSurface"
        app:cardCornerRadius="@dimen/recently_added_background_corner_size"
        app:cardElevation="2dp"
        app:cardPreventCornerOverlap="false"
        app:cardUseCompatPadding="false"
        app:strokeWidth="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:outlineProvider="none">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/card_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.google.android.material.imageview.ShapeableImageView
                android:id="@+id/shapeable_avatar_view"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:minWidth="88dp"
                android:scaleType="centerCrop"
                app:shapeAppearance="@style/Threema.ShapeAppearance.RecentlyAdded"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintDimensionRatio="H,1:1" />

            <ImageView
                android:id="@+id/gradient"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:importantForAccessibility="no"
                android:src="@drawable/shape_recently_added_contacts_overlay"
                app:layout_constraintLeft_toLeftOf="@id/shapeable_avatar_view"
                app:layout_constraintTop_toTopOf="@id/shapeable_avatar_view"
                app:layout_constraintBottom_toBottomOf="@id/shapeable_avatar_view"
                app:layout_constraintRight_toRightOf="@id/shapeable_avatar_view" />

            <!-- first line -->

            <TextView
                android:id="@+id/recently_added_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="@dimen/listitem_contacts_margin_top_bottom"
                android:layout_marginBottom="4dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/last_added_contact"
                android:textAppearance="@style/Threema.Text.Overline"
                android:textSize="13sp"
                android:textColor="?attr/colorPrimary"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toRightOf="@id/shapeable_avatar_view"
                app:layout_constraintRight_toRightOf="@+id/contact_text_bottom_left"
                app:layout_constraintBottom_toTopOf="@+id/contact_text_top_left"
                app:layout_constraintVertical_chainStyle="packed"
                app:layout_constraintHorizontal_chainStyle="packed" />

            <ch.threema.app.emojis.EmojiTextView
                android:id="@+id/contact_text_top_left"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                tools:text="Firstname Lastname"
                android:ellipsize="end"
                android:singleLine="true"
                android:textAppearance="@style/Threema.TextAppearance.List.FirstLine"
                android:textColor="@null"
                app:layout_constraintTop_toBottomOf="@id/recently_added_title"
                app:layout_constraintLeft_toRightOf="@id/shapeable_avatar_view"
                app:layout_constraintRight_toLeftOf="@+id/blocked_contact"
                app:layout_constraintBottom_toTopOf="@+id/contact_text_bottom_left"
                app:layout_constraintHorizontal_chainStyle="packed"
                app:layout_constraintHorizontal_bias="0"
                app:layout_constrainedWidth="false" />

            <ImageView
                android:id="@+id/blocked_contact"
                android:layout_width="22dp"
                android:layout_height="18dp"
                android:layout_marginRight="6dp"
                android:layout_marginBottom="2dp"
                android:baselineAlignBottom="true"
                android:contentDescription="@string/blocked"
                android:visibility="visible"
                app:srcCompat="@drawable/ic_block"
                app:layout_constraintBottom_toBottomOf="@id/contact_text_top_left"
                app:layout_constraintRight_toRightOf="parent"
                app:tint="@color/material_red" />

            <!-- second line -->

            <TextView
                android:id="@+id/contact_text_bottom_left"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="@dimen/listitem_contacts_margin_top_bottom"
                tools:text="Android Developer"
                android:ellipsize="end"
                android:singleLine="true"
                android:textAppearance="@style/Threema.TextAppearance.List.ThirdLine"
                android:textColor="@null"
                app:layout_constraintTop_toBottomOf="@id/contact_text_top_left"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toRightOf="@id/shapeable_avatar_view"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintVertical_chainStyle="packed"
                app:layout_constrainedWidth="true" />

        </androidx.constraintlayout.widget.ConstraintLayout>

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

</androidx.constraintlayout.widget.ConstraintLayout>
