<?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:background="@color/background_norm"
    android:elevation="@dimen/elevation_s"
    android:focusableInTouchMode="true"
    android:descendantFocusability="blocksDescendants"
    android:animateLayoutChanges="true">

    <View
        android:id="@+id/headerDividerView"
        android:layout_width="0dp"
        android:layout_height="@dimen/size_divider"
        android:background="@drawable/list_divider"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ch.protonmail.android.views.messageDetails.MessageDetailsAttachmentsView
        android:id="@+id/attachmentsView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/headerDividerView"
        android:visibility="gone"
        tools:visibility="visible" />

    <View
        android:id="@+id/attachmentsDividerView"
        android:layout_width="0dp"
        android:layout_height="@dimen/size_divider"
        android:background="@drawable/list_divider"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="@id/attachmentsView"
        android:visibility="gone"
        tools:visibility="visible" />

    <ch.protonmail.android.views.messageDetails.MessageDetailsExpirationInfoView
        android:id="@+id/expirationInfoView"
        android:layout_width="0dp"
        android:layout_height="@dimen/message_details_banner_height"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/attachmentsView" />

    <Button
        android:id="@+id/displayRemoteContentButton"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/message_spacing"
        android:layout_marginTop="@dimen/message_spacing_small"
        android:layout_marginRight="@dimen/message_spacing"
        android:layout_marginBottom="@dimen/message_spacing_small"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/expirationInfoView"
        android:visibility="gone"
        android:text="@string/display_images"
        app:icon="@drawable/ic_proton_image"
        app:iconGravity="textStart"
        android:drawableTint="@color/white"
        tools:visibility="visible" />

    <Button
        android:id="@+id/loadEmbeddedImagesButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/message_spacing"
        android:layout_marginTop="@dimen/message_spacing_small"
        android:layout_marginRight="@dimen/message_spacing"
        android:layout_marginBottom="@dimen/message_spacing_small"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/displayRemoteContentButton"
        android:visibility="gone"
        android:text="@string/load_embedded_images"
        app:icon="@drawable/ic_proton_image"
        app:iconGravity="textStart"
        android:drawableTint="@color/white"
        tools:visibility="visible" />

    <include
        android:id="@+id/include_open_in_proton_calendar"
        layout="@layout/layout_open_in_proton_calendar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/padding_l"
        app:layout_constraintTop_toBottomOf="@id/loadEmbeddedImagesButton"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:visibility="gone"
        tools:visibility="visible" />

    <Button
        android:id="@+id/editDraftButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/message_spacing"
        android:layout_marginTop="@dimen/message_spacing_small"
        android:layout_marginRight="@dimen/message_spacing"
        android:layout_marginBottom="@dimen/message_spacing_small"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/include_open_in_proton_calendar"
        android:visibility="gone"
        android:text="@string/edit_draft"
        android:gravity="center"
        app:icon="@drawable/ic_proton_pen"
        app:iconGravity="textStart"
        android:drawableTint="@color/white"
        tools:visibility="visible" />

    <TextView
        android:id="@+id/spamScoreView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fields_default_space_small"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/editDraftButton"
        android:background="@color/notification_warning"
        android:padding="@dimen/fields_default_space"
        android:textColor="@color/white"
        android:visibility="visible"
        tools:text="@string/spam_score_101" />

    <ch.protonmail.android.details.presentation.view.DecryptionErrorBanner
        android:id="@+id/decryptionErrorView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/padding_l"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        tools:visibility="visible"
        app:layout_constraintTop_toBottomOf="@id/spamScoreView" />

    <ch.protonmail.android.details.presentation.view.ScheduledInfoBanner
        android:id="@+id/scheduledInfoView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/padding_l"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        tools:visibility="visible"
        app:layout_constraintTop_toBottomOf="@id/decryptionErrorView" />

    <!-- add webview through code use application context to avoid memory leaks -->
    <!-- https://code.google.com/p/android/issues/detail?id=9375 -->
    <LinearLayout
        android:id="@+id/messageWebViewContainer"
        android:layout_width="match_parent"
        android:layout_height="@dimen/constrained_message_content_view_size"
        android:focusableInTouchMode="true"
        android:descendantFocusability="blocksDescendants"
        android:animateLayoutChanges="false"
        app:layout_constraintTop_toBottomOf="@id/scheduledInfoView"
        app:layout_constraintBottom_toBottomOf="parent"
        android:orientation="vertical" />

</androidx.constraintlayout.widget.ConstraintLayout>
