<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ActivityView">

    <View
        android:id="@+id/vwAnswerAnchor"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/ivFlagged"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginStart="6dp"
        android:src="@drawable/baseline_star_24"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="@id/tvFrom"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/tvFrom" />

    <ImageView
        android:id="@+id/ivAvatar"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginStart="6dp"
        android:maxHeight="60dp"
        android:scrollbars="vertical"
        android:src="@drawable/baseline_person_24"
        app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
        app:layout_constraintStart_toEndOf="@id/ivFlagged"
        app:layout_constraintTop_toTopOf="@+id/tvFrom" />

    <TextView
        android:id="@+id/tvFrom"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:freezesText="true"
        android:text="From"
        android:textAppearance="@style/TextAppearance.AppCompat.Medium"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toStartOf="@+id/ivContactAdd"
        app:layout_constraintStart_toEndOf="@id/ivAvatar"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/ivContactAdd"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:src="@drawable/baseline_import_contacts_24"
        app:layout_constraintBottom_toBottomOf="@id/tvFrom"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/tvFrom" />

    <TextView
        android:id="@+id/tvTime"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:freezesText="true"
        android:maxLines="1"
        android:text="12:34:56"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toStartOf="@+id/tvCount"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvFrom" />

    <TextView
        android:id="@+id/tvCount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="3dp"
        android:maxLines="1"
        android:text="3"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        app:layout_constraintEnd_toStartOf="@+id/ivThread"
        app:layout_constraintTop_toTopOf="@id/tvTime" />

    <ImageView
        android:id="@+id/ivThread"
        android:layout_width="15dp"
        android:layout_height="15dp"
        android:layout_marginEnd="6dp"
        android:src="@drawable/baseline_message_24"
        app:layout_constraintBottom_toBottomOf="@id/tvTime"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/tvTime" />

    <TextView
        android:id="@+id/tvToTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:text="@string/title_to"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvTime" />

    <TextView
        android:id="@+id/tvTo"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:freezesText="true"
        android:maxHeight="60dp"
        android:scrollbars="vertical"
        android:text="To"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/tvToTitle"
        app:layout_constraintTop_toBottomOf="@id/tvTime" />

    <TextView
        android:id="@+id/tvSubject"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:freezesText="true"
        android:text="Subject"
        android:textAppearance="@style/TextAppearance.AppCompat.Medium"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvTo" />

    <View
        android:id="@+id/vSeparatorAddress"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="3dp"
        android:background="?attr/colorSeparator"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvSubject" />

    <TextView
        android:id="@+id/tvReplyToTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:text="@string/title_reply_to"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />

    <TextView
        android:id="@+id/tvReplyTo"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:freezesText="true"
        android:maxHeight="60dp"
        android:scrollbars="vertical"
        android:text="Reply to"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/tvReplyToTitle"
        app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />

    <TextView
        android:id="@+id/tvCcTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:text="@string/title_cc"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvReplyTo" />

    <TextView
        android:id="@+id/tvCc"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:freezesText="true"
        android:maxHeight="60dp"
        android:scrollbars="vertical"
        android:text="Cc"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/tvCcTitle"
        app:layout_constraintTop_toBottomOf="@id/tvReplyTo" />

    <TextView
        android:id="@+id/tvBccTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:text="@string/title_bcc"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvCc" />

    <TextView
        android:id="@+id/tvBcc"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:freezesText="true"
        android:maxHeight="60dp"
        android:scrollbars="vertical"
        android:text="Bcc"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/tvBccTitle"
        app:layout_constraintTop_toBottomOf="@id/tvCc" />


    <View
        android:id="@+id/vSeparatorRawHeaders"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="3dp"
        android:background="?attr/colorSeparator"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvBcc" />

    <TextView
        android:id="@+id/tvRawHeaders"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:fontFamily="monospace"

        android:freezesText="true"
        android:maxHeight="120sp"
        android:text="H1\nH2\nH3\nH4\nH5\nH6\nH7\nH8\nH9\n"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textIsSelectable="true"
        android:textSize="12sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/vSeparatorRawHeaders" />

    <ProgressBar
        android:id="@+id/pbRawHeaders"
        style="@style/Base.Widget.AppCompat.ProgressBar"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:indeterminate="true"
        app:layout_constraintBottom_toBottomOf="@id/tvRawHeaders"
        app:layout_constraintEnd_toEndOf="@id/tvRawHeaders"
        app:layout_constraintStart_toStartOf="@id/tvRawHeaders"
        app:layout_constraintTop_toTopOf="@id/tvRawHeaders" />

    <View
        android:id="@+id/vSeparatorAttachments"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="3dp"
        android:background="?attr/colorSeparator"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvRawHeaders" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvAttachment"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:scrollbarStyle="outsideOverlay"
        android:scrollbars="vertical"
        app:layout_constrainedHeight="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_max="90dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />

    <View
        android:id="@+id/vSeparatorError"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="3dp"
        android:background="?attr/colorSeparator"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/rvAttachment" />

    <TextView
        android:id="@+id/tvError"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:freezesText="true"
        android:text="error"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:textColor="?attr/colorWarning"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/vSeparatorError" />

    <View
        android:id="@+id/vSeparatorBody"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="3dp"
        android:background="?attr/colorSeparator"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tvError" />

    <Button
        android:id="@+id/btnImages"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:minHeight="0dp"
        android:minWidth="0dp"
        android:text="@string/title_show_images"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginEnd="6dp"
        android:layout_marginStart="6dp"
        android:layout_marginTop="3dp"
        android:fillViewport="true"
        android:orientation="vertical"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/btnImages">

        <TextView
            android:id="@+id/tvBody"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fontFamily="monospace"
            android:text="Body"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textIsSelectable="true" />
    </ScrollView>

    <ProgressBar
        android:id="@+id/pbBody"
        style="@style/Base.Widget.AppCompat.ProgressBar"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:indeterminate="true"
        app:layout_constraintBottom_toBottomOf="@id/scroll"
        app:layout_constraintEnd_toEndOf="@id/scroll"
        app:layout_constraintStart_toStartOf="@id/scroll"
        app:layout_constraintTop_toTopOf="@id/scroll" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="16dp"
        android:src="@drawable/baseline_fullscreen_24"
        android:tint="@color/colorActionForeground"
        app:backgroundTint="?attr/colorAccent"
        app:layout_constraintBottom_toBottomOf="@+id/scroll"
        app:layout_constraintEnd_toEndOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:background="@color/colorPrimary"
        app:itemIconTint="@color/bottomnav_background"
        app:itemTextColor="@color/bottomnav_background"
        app:labelVisibilityMode="labeled"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/action_view" />

    <ProgressBar
        android:id="@+id/pbWait"
        style="@style/Base.Widget.AppCompat.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpHeader"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="ivFlagged,ivAvatar,tvFrom,ivContactAdd,tvToTitle,tvTo,tvSize,tvTime,tvSubject" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpThread"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="tvCount,ivThread" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpAddresses"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="vSeparatorAddress,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpRawHeaders"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="vSeparatorRawHeaders,tvRawHeaders" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpAttachments"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="vSeparatorAttachments,rvAttachment" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpError"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="vSeparatorError,tvError" />

    <androidx.constraintlayout.widget.Group
        android:id="@+id/grpMessage"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:constraint_referenced_ids="scroll" />
</androidx.constraintlayout.widget.ConstraintLayout>
