<?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"
    tools:context=".ActivityView">

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="12dp">

            <TextView
                android:id="@+id/tvFolder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Inbox"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tvName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_name"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvFolder" />

            <EditText
                android:id="@+id/etName"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:inputType="textCapSentences"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvName" />

            <TextView
                android:id="@+id/tvOrder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_order"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/etName" />

            <EditText
                android:id="@+id/etOrder"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="1"
                android:inputType="number"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvOrder" />

            <CheckBox
                android:id="@+id/cbEnabled"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_enabled"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/etOrder" />

            <CheckBox
                android:id="@+id/cbStop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_stop"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/cbEnabled" />

            <!-- condition -->

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

            <TextView
                android:id="@+id/tvSender"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:singleLine="true"
                android:text="@string/title_rule_sender"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintBottom_toBottomOf="@+id/cbSender"
                app:layout_constraintEnd_toStartOf="@+id/cbSender"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/cbSender" />

            <CheckBox
                android:id="@+id/cbSender"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_regex"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/vSeparatorSender" />

            <EditText
                android:id="@+id/etSender"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="@string/title_optional"
                android:inputType="textEmailAddress"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintEnd_toStartOf="@+id/ivSender"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/cbSender" />

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

            <TextView
                android:id="@+id/tvAndSubject"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_and"
                android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                android:textColor="?android:attr/textColorPrimary"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/etSender" />

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

            <TextView
                android:id="@+id/tvSubject"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:singleLine="true"
                android:text="@string/title_rule_subject"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintBottom_toBottomOf="@+id/cbSubject"
                app:layout_constraintEnd_toStartOf="@+id/cbSubject"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/cbSubject" />

            <CheckBox
                android:id="@+id/cbSubject"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_regex"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/vSeparatorSubject" />

            <EditText
                android:id="@+id/etSubject"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="@string/title_optional"
                android:inputType="text"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/cbSubject" />

            <TextView
                android:id="@+id/tvAndHeader"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_and"
                android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                android:textColor="?android:attr/textColorPrimary"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/etSubject" />

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

            <TextView
                android:id="@+id/tvHeader"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:singleLine="true"
                android:text="@string/title_rule_header"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintBottom_toBottomOf="@+id/cbHeader"
                app:layout_constraintEnd_toStartOf="@+id/cbHeader"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/cbHeader" />

            <CheckBox
                android:id="@+id/cbHeader"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_regex"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/vSeparatorHeader" />

            <EditText
                android:id="@+id/etHeader"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="@string/title_optional"
                android:inputType="text"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/cbHeader" />

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

            <TextView
                android:id="@+id/tvAction"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_action"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/vSeparatorAction" />

            <Spinner
                android:id="@+id/spAction"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvAction" />

            <TextView
                android:id="@+id/tvActionRemark"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_action_remark"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                android:textStyle="italic"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/spAction" />

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

            <TextView
                android:id="@+id/tvMoveTarget"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_folder"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/vSeparatorParameters" />

            <Spinner
                android:id="@+id/spTarget"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvMoveTarget" />

            <TextView
                android:id="@+id/tvAnswerIdentity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_rule_identity"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/spTarget" />

            <Spinner
                android:id="@+id/spIdent"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvAnswerIdentity" />

            <TextView
                android:id="@+id/tvAnswerTemplate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_answer"
                android:textAppearance="@style/TextAppearance.AppCompat.Small"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/spIdent" />

            <Spinner
                android:id="@+id/spAnswer"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvAnswerTemplate" />

            <CheckBox
                android:id="@+id/cbCc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:text="@string/title_rule_cc"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/spAnswer" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/grpReady"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:constraint_referenced_ids="
                tvName,etName,tvOrder,etOrder,cbEnabled,cbStop,
                vSeparatorSender,tvSender,cbSender,etSender,ivSender,tvAndSubject,
                vSeparatorSubject,tvSubject,cbSubject,etSubject,tvAndHeader,
                vSeparatorHeader,tvHeader,cbHeader,etHeader,
                vSeparatorAction,tvAction,spAction,tvActionRemark,
                vSeparatorParameters" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/grpMove"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:constraint_referenced_ids="
                tvMoveTarget,spTarget" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/grpAnswer"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:constraint_referenced_ids="
                tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbCc" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:attr/colorPrimary"
        app:itemIconTint="@color/bottomnav_foreground"
        app:itemTextColor="@color/bottomnav_foreground"
        app:labelVisibilityMode="labeled"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/action_rule" />

    <eu.faircode.email.ContentLoadingProgressBar
        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.ConstraintLayout>