<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <include layout="@layout/toolbar"/>

    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:padding="6dip"
            android:fadingEdge="none"
            android:scrollbarStyle="outsideInset">

        <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

            <!-- The hint text may be changed in code if the server is IMAP, etc. -->
            <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/account_server_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">

                <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_server"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textUri"
                        android:hint="@string/account_setup_incoming_pop_server_label"
                        android:singleLine="true" />
            </com.google.android.material.textfield.TextInputLayout>

            <TextView
                    android:text="@string/account_setup_incoming_security_label"
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    style="@style/InputLabel"
                    android:layout_marginTop="6dp"/>

            <Spinner
                    android:id="@+id/account_security_type"
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:contentDescription="@string/account_setup_incoming_security_label"/>

            <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">

                <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_port"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:hint="@string/account_setup_incoming_port_label"
                        android:singleLine="true" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">

                <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_username"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textEmailAddress"
                        android:hint="@string/account_setup_incoming_username_label"
                        android:singleLine="true" />
            </com.google.android.material.textfield.TextInputLayout>

            <TextView
                    android:id="@+id/account_auth_type_label"
                    android:text="@string/account_setup_incoming_auth_type_label"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:layout_marginTop="6dp"
                    style="@style/InputLabel"/>

            <Spinner
                    android:id="@+id/account_auth_type"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:contentDescription="@string/account_setup_incoming_auth_type_label"/>

            <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/account_password_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing"
                    app:passwordToggleEnabled="true">

                <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/account_password"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/account_setup_incoming_password_label"
                        android:singleLine="true"
                        android:inputType="textPassword"
                        android:nextFocusDown="@+id/next"/>
            </com.google.android.material.textfield.TextInputLayout>
        <LinearLayout
            android:id="@+id/account_allow_client_certificate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="gone"
            tools:visibility="visible">
            <TextView
                    android:text="@string/account_setup_incoming_client_certificate_label"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:layout_marginTop="6dp"
                    style="@style/InputLabel"/>

            <com.fsck.k9.view.ClientCertificateSpinner
                    android:id="@+id/account_client_certificate_spinner"
                    android:paddingLeft="6dp"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"/>
        </LinearLayout>


            <LinearLayout
                    android:id="@+id/imap_path_prefix_section"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="6dp"
                    android:orientation="vertical">

                <CheckBox
                        android:id="@+id/imap_autodetect_namespace"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/account_setup_incoming_autodetect_namespace_label"/>

                <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/imap_path_prefix"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/account_setup_incoming_imap_path_prefix_label"
                            android:singleLine="true" />
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/imap_folder_setup_section"
                    android:orientation="vertical">

                <CheckBox
                        android:id="@+id/subscribed_folders_only"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/account_setup_incoming_subscribed_folders_only_label"
                        />
            </LinearLayout>

            <LinearLayout
                    android:id="@+id/webdav_advanced_header"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                <TextView
                        android:text="@string/advanced"
                        android:layout_height="wrap_content"
                        android:layout_width="match_parent"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:textStyle="bold"
                        android:layout_marginTop="4dp"/>
            </LinearLayout>

            <LinearLayout
                    android:id="@+id/webdav_mailbox_alias_section"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/webdav_mailbox_path"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/account_setup_incoming_webdav_mailbox_path_label"
                            android:singleLine="true" />
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                    android:id="@+id/webdav_owa_path_section"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/webdav_path_prefix"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/account_setup_incoming_webdav_path_prefix_label"
                        android:singleLine="true" />
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                    android:id="@+id/webdav_auth_path_section"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/webdav_auth_path"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/account_setup_incoming_webdav_auth_path_label"
                        android:singleLine="true" />
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <TextView
                    android:id="@+id/compression_label"
                    android:text="@string/account_setup_incoming_compression_label"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:layout_marginTop="6dp"
                    style="@style/InputLabel"/>

            <LinearLayout
                    android:id="@+id/compression_section"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                <CheckBox
                        android:id="@+id/compression_mobile"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/account_setup_incoming_mobile_label"
                        />

                <CheckBox
                        android:id="@+id/compression_wifi"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/account_setup_incoming_wifi_label"
                        android:contentDescription="@string/account_setup_incoming_compression_label"
                        />

                <CheckBox
                        android:id="@+id/compression_other"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/account_setup_incoming_other_label"
                        android:contentDescription="@string/account_setup_incoming_compression_label"
                        />
            </LinearLayout>

            <View
                    android:layout_width="match_parent"
                    android:layout_height="0dip"
                    android:layout_weight="1"/>
        </LinearLayout>
    </ScrollView>

    <include layout="@layout/wizard_next"/>
</LinearLayout>
