<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2022 Proton AG
  ~
  ~ This file is part of Proton Mail.
  ~
  ~ Proton Mail 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.
  ~
  ~ Proton Mail 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 Proton Mail. If not, see https://www.gnu.org/licenses/.
  -->

<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:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingHorizontal="@dimen/mailbox_list_item_padding_horizontal"
    android:paddingVertical="@dimen/mailbox_list_item_padding_vertical"
    android:background="@drawable/ripple_background_norm">

    <ch.protonmail.android.views.messagesList.SenderInitialView
        android:id="@+id/sender_initial_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/sender_initial_view_margin_end"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/sender_initial_barrier"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/sender_initial_barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:barrierDirection="end"
        app:layout_constraintStart_toEndOf="@id/sender_initial_view"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

    <ImageView
        android:id="@+id/reply_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/sender_initial_barrier"
        app:layout_constraintEnd_toStartOf="@id/reply_all_image_view"
        app:layout_constraintTop_toTopOf="@id/reply_all_image_view"
        app:layout_constraintBottom_toBottomOf="@id/reply_all_image_view"
        app:srcCompat="@drawable/ic_proton_arrow_up_and_left"
        android:contentDescription="@string/reply"
        app:tint="@color/icon_weak" />

    <ImageView
        android:id="@+id/reply_all_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/reply_image_view"
        app:layout_constraintEnd_toStartOf="@id/forward_image_view"
        app:layout_constraintTop_toTopOf="@id/forward_image_view"
        app:layout_constraintBottom_toBottomOf="@id/forward_image_view"
        app:srcCompat="@drawable/ic_proton_arrows_up_and_left"
        android:contentDescription="@string/reply_all"
        app:tint="@color/icon_weak" />

    <ImageView
        android:id="@+id/forward_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/reply_all_image_view"
        app:layout_constraintEnd_toStartOf="@id/draft_image_view"
        app:layout_constraintTop_toTopOf="@id/draft_image_view"
        app:layout_constraintBottom_toBottomOf="@id/draft_image_view"
        app:srcCompat="@drawable/ic_proton_arrow_right"
        android:contentDescription="@string/forward"
        app:tint="@color/icon_weak" />

    <ImageView
        android:id="@+id/draft_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/forward_image_view"
        app:layout_constraintEnd_toStartOf="@id/correspondents_wrapper_view"
        app:layout_constraintTop_toTopOf="@id/correspondents_wrapper_view"
        app:layout_constraintBottom_toBottomOf="@id/correspondents_wrapper_view"
        app:srcCompat="@drawable/ic_proton_pen" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/correspondents_wrapper_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintEnd_toStartOf="@id/time_date_text_view"
        app:layout_constraintStart_toEndOf="@id/draft_image_view"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/correspondents_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxLines="1"
            app:layout_constraintStart_toStartOf="parent"
            android:textAppearance="@style/Proton.Text.Default"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="@tools:sample/full_names" />


        <com.google.android.material.chip.Chip
            android:id="@+id/authenticity_badge_chip"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/mailbox_list_item_icon_size"
            android:layout_marginStart="@dimen/padding_xs"
            android:background="@color/background_secondary"
            android:clickable="false"
            android:contentDescription="@string/is_proton"
            android:text="@string/is_proton_official_badge"
            android:textAppearance="@style/Proton.Text.Overline"
            android:textColor="?attr/proton_text_accent"
            android:visibility="gone"
            app:chipCornerRadius="@dimen/size_corner_xxs"
            app:chipMinTouchTargetSize="0dp"
            app:layout_constraintBottom_toBottomOf="@id/correspondents_text_view"
            app:layout_constraintStart_toEndOf="@id/correspondents_text_view"
            app:layout_constraintTop_toTopOf="@id/correspondents_text_view"
            app:rippleColor="@android:color/transparent"
            app:textEndPadding="@dimen/padding_xs"
            app:textStartPadding="@dimen/padding_xs" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <TextView
        android:id="@+id/time_date_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/correspondents_wrapper_view"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/correspondents_wrapper_view"
        app:layout_constraintBottom_toBottomOf="@id/correspondents_wrapper_view"
        android:textAppearance="@style/Proton.Text.Caption.Weak"
        tools:text="@tools:sample/date/ddmmyy" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/first_row_barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintStart_toEndOf="@id/sender_initial_barrier"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/correspondents_wrapper_view" />

    <ImageView
        android:id="@+id/first_location_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/sender_initial_barrier"
        app:layout_constraintEnd_toStartOf="@id/second_location_image_view"
        app:layout_constraintTop_toTopOf="@id/second_location_image_view"
        app:layout_constraintBottom_toBottomOf="@id/second_location_image_view"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintHorizontal_bias="0.0"
        app:tint="@color/icon_weak"
        android:visibility="gone"
        tools:src="@drawable/ic_proton_trash"
        tools:visibility="visible"/>

    <ImageView
        android:id="@+id/second_location_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/first_location_image_view"
        app:layout_constraintEnd_toStartOf="@id/third_location_image_view"
        app:layout_constraintTop_toTopOf="@id/third_location_image_view"
        app:layout_constraintBottom_toBottomOf="@id/third_location_image_view"
        app:tint="@color/icon_weak"
        android:visibility="gone"
        tools:src="@drawable/ic_proton_trash"
        tools:visibility="visible" />

    <ImageView
        android:id="@+id/third_location_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:layout_marginEnd="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/second_location_image_view"
        app:layout_constraintEnd_toStartOf="@id/subject_text_view"
        app:layout_constraintTop_toTopOf="@id/subject_text_view"
        app:layout_constraintBottom_toBottomOf="@id/subject_text_view"
        app:tint="@color/icon_weak"
        android:visibility="gone"
        tools:src="@drawable/ic_proton_trash"
        tools:visibility="visible" />

    <TextView
        android:id="@+id/subject_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/third_location_image_view"
        app:layout_constraintEnd_toStartOf="@id/messages_number_text_view"
        app:layout_constraintTop_toBottomOf="@id/correspondents_wrapper_view"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constrainedWidth="true"
        android:maxLines="1"
        android:ellipsize="end"
        android:textAppearance="@style/Proton.Text.DefaultSmall.Weak"
        tools:text="@tools:sample/lorem" />

    <TextView
        android:id="@+id/messages_number_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/mailbox_list_item_views_margin"
        android:paddingHorizontal="@dimen/message_number_view_padding_horizontal"
        android:paddingVertical="@dimen/message_number_view_padding_vertical"
        app:layout_constraintStart_toEndOf="@id/subject_text_view"
        app:layout_constraintEnd_toStartOf="@id/empty_space_view"
        app:layout_constraintTop_toTopOf="@id/subject_text_view"
        app:layout_constraintBottom_toBottomOf="@id/subject_text_view"
        android:background="@drawable/background_messages_number"
        android:textAppearance="@style/Proton.Text.Caption.Weak"
        android:visibility="gone"
        tools:text="3"
        tools:visibility="visible" />

    <View
        android:id="@+id/empty_space_view"
        android:layout_width="@dimen/mailbox_list_item_views_margin"
        android:layout_height="1dp"
        app:layout_constraintStart_toEndOf="@id/messages_number_text_view"
        app:layout_constraintEnd_toStartOf="@id/sending_uploading_progress_bar"
        app:layout_constraintTop_toTopOf="@id/messages_number_text_view"
        app:layout_constraintBottom_toBottomOf="@id/messages_number_text_view" />

    <ProgressBar
        android:id="@+id/sending_uploading_progress_bar"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        app:layout_constraintEnd_toStartOf="@id/attachment_image_view"
        app:layout_constraintTop_toTopOf="@id/attachment_image_view"
        app:layout_constraintBottom_toBottomOf="@id/attachment_image_view" />

    <ImageView
        android:id="@+id/attachment_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        app:layout_constraintEnd_toStartOf="@id/star_image_view"
        app:layout_constraintTop_toTopOf="@id/star_image_view"
        app:layout_constraintBottom_toBottomOf="@id/star_image_view"
        app:srcCompat="@drawable/ic_proton_paper_clip"
        app:tint="@color/icon_weak" />

    <ImageView
        android:id="@+id/star_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/subject_text_view"
        app:layout_constraintBottom_toBottomOf="@id/subject_text_view"
        app:srcCompat="@drawable/ic_star_filled"
        android:contentDescription="@string/starred"
        app:tint="@color/notification_warning" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/second_row_barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintStart_toEndOf="@id/sender_initial_barrier"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/subject_text_view" />

    <ImageView
        android:id="@+id/expiration_image_view"
        android:layout_width="@dimen/mailbox_list_item_icon_size"
        android:layout_height="@dimen/mailbox_list_item_icon_size"
        android:padding="@dimen/mailbox_list_item_expiration_icon_padding"
        android:layout_marginTop="@dimen/mailbox_list_item_views_margin"
        app:layout_constraintStart_toEndOf="@id/sender_initial_barrier"
        app:layout_constraintTop_toBottomOf="@id/subject_text_view"
        app:srcCompat="@drawable/ic_proton_hourglass"
        android:background="@drawable/circle_background_interaction_weak" />

    <ch.protonmail.android.ui.view.SingleLineLabelChipGroupView
        android:id="@+id/mailbox_label_chip_group"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/mailbox_list_item_views_margin"
        android:layout_marginStart="@dimen/mailbox_list_item_views_margin"
        app:layout_goneMarginStart="0dp"
        app:layout_constraintStart_toEndOf="@id/expiration_image_view"
        app:layout_constraintTop_toBottomOf="@id/subject_text_view"
        app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
