<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="12dp">

        <!--- linked account -->

        <TextView
            android:id="@+id/tvAccount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_account_linked"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Spinner
            android:id="@+id/spAccount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvAccount" />

        <!-- name -->

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

        <EditText
            android:id="@+id/etName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="name"
            android:inputType="textPersonName"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvName" />

        <!-- email -->

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

        <EditText
            android:id="@+id/etEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="emailAddress"
            android:inputType="textEmailAddress"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvEmail" />

        <!-- display name -->

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

        <EditText
            android:id="@+id/etDisplay"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="name"
            android:hint="@string/title_optional"
            android:inputType="textPersonName"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvDisplay" />

        <Button
            android:id="@+id/btnColor"
            style="@style/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:minWidth="0dp"
            android:minHeight="0dp"
            android:tag="disable"
            android:text="@string/title_account_color"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etDisplay" />

        <View
            android:id="@+id/vwColor"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginStart="12dp"
            android:background="@color/colorAccent"
            app:layout_constraintBottom_toBottomOf="@id/btnColor"
            app:layout_constraintStart_toEndOf="@id/btnColor"
            app:layout_constraintTop_toTopOf="@id/btnColor" />

        <ImageView
            android:id="@+id/ibColorDefault"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="12dp"
            android:src="@drawable/baseline_delete_24"
            app:layout_constraintBottom_toBottomOf="@id/btnColor"
            app:layout_constraintStart_toEndOf="@id/vwColor"
            app:layout_constraintTop_toTopOf="@id/btnColor" />

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

        <EditText
            android:id="@+id/etSignature"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:fontFamily="monospace"
            android:hint="@string/title_optional"
            android:inputType="textCapSentences|textMultiLine"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvSignature" />

        <Button
            android:id="@+id/btnHtml"
            style="@style/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:minWidth="0dp"
            android:minHeight="0dp"
            android:tag="disable"
            android:text="@string/title_edit_html"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etSignature" />

        <Button
            android:id="@+id/btnAdvanced"
            style="@style/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:minWidth="0dp"
            android:minHeight="0dp"
            android:text="@string/title_setup_advanced"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/btnHtml" />

        <!--- provider -->

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

        <Spinner
            android:id="@+id/spProvider"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvProvider" />

        <!-- SMTP -->

        <!-- auto config -->

        <TextView
            android:id="@+id/tvDomain"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_domain"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/spProvider" />

        <TextView
            android:id="@+id/tvDomainHint"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_optional"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvDomain" />

        <EditText
            android:id="@+id/etDomain"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="domain.tld"
            android:inputType="textUri"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvDomainHint" />

        <Button
            android:id="@+id/btnAutoConfig"
            style="@style/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:minWidth="0dp"
            android:minHeight="0dp"
            android:tag="disable"
            android:text="@string/title_autoconfig"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etDomain" />

        <TextView
            android:id="@+id/tvSmtp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_smtp"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/btnAutoConfig" />

        <!-- host -->

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

        <EditText
            android:id="@+id/etHost"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="smtp.domain.tld"
            android:inputType="textUri"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvHost" />

        <!-- STARTTLS -->

        <CheckBox
            android:id="@+id/cbStartTls"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_starttls"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etHost" />

        <CheckBox
            android:id="@+id/cbInsecure"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_allow_insecure"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbStartTls" />

        <!-- port -->

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

        <EditText
            android:id="@+id/etPort"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="465"
            android:inputType="number"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvPort" />

        <!-- username -->

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

        <EditText
            android:id="@+id/etUser"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="username"
            android:inputType="text"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvUser" />

        <!-- password -->

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

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/tilPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvPassword"
            app:passwordToggleEnabled="true">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="password"
                android:inputType="textPassword"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
        </com.google.android.material.textfield.TextInputLayout>

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

        <EditText
            android:id="@+id/etRealm"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/title_optional"
            android:inputType="text"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvRealm" />

        <CheckBox
            android:id="@+id/cbUseIp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_use_ip"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etRealm" />

        <CheckBox
            android:id="@+id/cbSynchronize"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_synchronize_identity"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbUseIp" />

        <CheckBox
            android:id="@+id/cbPrimary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_primary_identity"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbSynchronize" />

        <!-- reply to -->

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

        <EditText
            android:id="@+id/etReplyTo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="emailAddress"
            android:hint="@string/title_optional"
            android:inputType="textEmailAddress"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvReplyTo" />

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

        <EditText
            android:id="@+id/etBcc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="emailAddress"
            android:hint="@string/title_optional"
            android:inputType="textEmailAddress"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvBcc" />

        <CheckBox
            android:id="@+id/cbPlainOnly"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_identity_plain_text"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etBcc" />

        <CheckBox
            android:id="@+id/cbEncrypt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_identity_encrypt"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbPlainOnly" />

        <CheckBox
            android:id="@+id/cbDeliveryReceipt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_identity_delivery_receipt"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbEncrypt" />

        <CheckBox
            android:id="@+id/cbReadReceipt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_identity_read_receipt"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbDeliveryReceipt" />

        <TextView
            android:id="@+id/tvReceipt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_identity_receipt_remark"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbReadReceipt" />

        <CheckBox
            android:id="@+id/cbStoreSent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/title_identity_store_sent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvReceipt" />

        <TextView
            android:id="@+id/tvStoreSent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_identity_store_sent_remark"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbStoreSent" />

        <Button
            android:id="@+id/btnSave"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:tag="disable"
            android:text="@string/title_save"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvStoreSent" />

        <eu.faircode.email.ContentLoadingProgressBar
            android:id="@+id/pbSave"
            style="@style/Base.Widget.AppCompat.ProgressBar"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginStart="12dp"
            android:indeterminate="true"
            app:layout_constraintBottom_toBottomOf="@id/btnSave"
            app:layout_constraintStart_toEndOf="@id/btnSave"
            app:layout_constraintTop_toTopOf="@id/btnSave" />

        <TextView
            android:id="@+id/tvError"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:autoLink="web"
            android:text="error"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            android:textColor="?attr/colorWarning"
            android:textIsSelectable="true"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/btnSave" />

        <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.Group
            android:id="@+id/grpAuthorize"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:constraint_referenced_ids="
            tvName,etName,tvEmail,etEmail,tvDisplay,etDisplay,
            btnColor,vwColor,ibColorDefault,
            tvSignature,etSignature,btnHtml,
            btnAdvanced,btnSave" />

        <androidx.constraintlayout.widget.Group
            android:id="@+id/grpAdvanced"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:constraint_referenced_ids="
            tvProvider,spProvider,
            tvDomain,tvDomainHint,etDomain,btnAutoConfig,
            tvSmtp,tvHost,etHost,cbStartTls,cbInsecure,tvPort,etPort,
            tvUser,etUser,tvPassword,tilPassword,
            tvRealm,etRealm,
            cbUseIp,
            cbSynchronize,cbPrimary,
            tvReplyTo,etReplyTo,tvBcc,etBcc,
            cbPlainOnly,cbEncrypt,cbDeliveryReceipt,cbReadReceipt,tvReceipt,
            cbStoreSent,tvStoreSent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
