<?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:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="12dp"
    android:scrollbarStyle="outsideOverlay"
    tools:context=".ActivitySetup">

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

        <TextView
            android:id="@+id/tvPopSupport"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/title_pop_support"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic|bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <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/tvPopSupport" />

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

        <!-- SSL/STARTTLS -->

        <RadioGroup
            android:id="@+id/rgEncryption"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/etHost">

            <RadioButton
                android:id="@+id/radio_ssl"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title_ssl" />

            <RadioButton
                android:id="@+id/radio_starttls"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="12dp"
                android:text="@string/title_starttls" />
        </RadioGroup>

        <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/rgEncryption" />

        <TextView
            android:id="@+id/tvInsecureRemark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/title_insecure_remark"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cbInsecure" />

        <!-- 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/tvInsecureRemark" />

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

        <!-- user -->

        <TextView
            android:id="@+id/tvUser"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:labelFor="@+id/etUser"
            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>

        <!-- name -->

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

        <TextView
            android:id="@+id/tvNameRemark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/title_account_name_hint"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvName" />

        <EditText
            android:id="@+id/etName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/title_optional"
            android:inputType="textCapSentences|textAutoCorrect"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvNameRemark" />

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

        <eu.faircode.email.ViewButtonColor
            android:id="@+id/btnColor"
            style="@style/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:minWidth="0dp"
            android:minHeight="0dp"
            android:tag="disable"
            android:text="@string/title_select"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvColor" />

        <TextView
            android:id="@+id/tvColorHint"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/title_identity_color_hint"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textStyle="italic"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/btnColor" />

        <TextView
            android:id="@+id/tvColorPro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/title_pro_feature"
            android:textAppearance="@style/TextAppearance.AppCompat.Small"
            android:textColor="?android:attr/textColorLink"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tvColorHint" />

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

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

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

        <!-- keep alive -->

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

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

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

        <!-- save -->

        <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/tvIntervalRemark" />

        <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.ConstraintLayout>
</ScrollView>
