<?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:background="@color/primary_dark"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activities.DeviceActivity">

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:windowBackground">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="?android:listDivider"
            android:orientation="vertical"
            android:paddingBottom="8dp"
            android:paddingTop="8dp"
            android:showDividers="middle">

            <!-- Option 1: Input or edit device ID -->
            <LinearLayout
                android:id="@+id/editDeviceIdContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?selectableItemBackground"
                android:orientation="horizontal">

                <com.nutomic.syncthingandroid.views.EnhancedEditText
                    android:id="@+id/editDeviceId"
                    style="@style/Widget.Syncthing.TextView.Label.Details.Field"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    app:drawableLeftCompat="@drawable/ic_id"
                    app:drawableStartCompat="@drawable/ic_id"
                    android:contentDescription="@string/device_id"
                    android:imeOptions="actionNext"
                    android:inputType="textNoSuggestions|textMultiLine"
                    android:focusable="true"
                    android:nextFocusDown="@+id/name" />

                <ImageView
                    android:id="@+id/qrButton"
                    style="?actionButtonStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material"
                    android:contentDescription="@string/scan_qr_code_description"
                    app:srcCompat="@drawable/outline_qr_code_2_24" />

            </LinearLayout>

            <TextView
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:id="@+id/discoveredDevicesTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material"
                android:clickable="true"
                app:drawableLeftCompat="@drawable/ic_device_hub_black_24dp_active"
                app:drawableStartCompat="@drawable/ic_device_hub_black_24dp_active"
                app:drawableEndCompat="@drawable/baseline_refresh_24"
                android:focusable="true"
                android:text="@string/discovered_devices_title"
                android:visibility="gone" />

            <LinearLayout
                android:id="@+id/discoveredDevicesContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:focusable="false"
                android:visibility="gone">
            </LinearLayout>

            <!-- Option 2: Show or copy device ID -->
            <LinearLayout
                android:id="@+id/showDeviceIdContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?selectableItemBackground"
                android:orientation="horizontal"
                android:focusable="true"
                android:nextFocusDown="@+id/name" >

                <com.nutomic.syncthingandroid.views.EnhancedEditText
                    android:id="@+id/showDeviceId"
                    style="@style/Widget.Syncthing.TextView.Label.Details.Field"
                    android:enabled="false"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    app:drawableLeftCompat="@drawable/ic_id"
                    app:drawableStartCompat="@drawable/ic_id"
                    android:hint="@string/device_id"
                    android:imeOptions="actionNext"
                    android:inputType="textNoSuggestions|textMultiLine" />

                <ImageView
                    style="?actionButtonStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material"
                    android:contentDescription="@string/scan_qr_code_description"
                    app:srcCompat="@drawable/baseline_content_copy_24" />

            </LinearLayout>

            <!-- Device Name -->
            <EditText
                android:id="@+id/name"
                style="@style/Widget.Syncthing.TextView.Label.Details.Field"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:drawableLeftCompat="@drawable/baseline_sort_by_alpha_24"
                app:drawableStartCompat="@drawable/baseline_sort_by_alpha_24"
                android:hint="@string/name"
                android:imeOptions="actionNext"
                android:inputType="textCapWords"
                android:importantForAutofill="no" />

            <!-- Device Addresses-->
            <EditText
                android:id="@+id/addresses"
                style="@style/Widget.Syncthing.TextView.Label.Details.Field"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:drawableLeftCompat="@drawable/baseline_link_24"
                app:drawableStartCompat="@drawable/baseline_link_24"
                android:hint="@string/addresses"
                android:imeOptions="actionDone"
                android:inputType="textNoSuggestions"
                android:importantForAutofill="no" />

            <TextView
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:drawableLeftCompat="@drawable/ic_device_hub_black_24dp_active"
                app:drawableStartCompat="@drawable/ic_device_hub_black_24dp_active"
                android:focusable="false"
                android:text="@string/folders" />

            <LinearLayout
                android:id="@+id/foldersContainer"
                android:background="?selectableItemBackground"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:focusable="true">
            </LinearLayout>

            <LinearLayout
                android:id="@+id/compressionContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?selectableItemBackground"
                android:orientation="horizontal"
                android:focusable="true">

                <TextView
                    style="@style/Widget.Syncthing.TextView.Label.Details"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@null"
                    android:checked="false"
                    app:drawableLeftCompat="@drawable/ic_zip_box_black_24dp_active"
                    app:drawableStartCompat="@drawable/ic_zip_box_black_24dp_active"
                    android:text="@string/compression" />

                <TextView
                    android:id="@+id/compressionValue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material"
                    android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
            </LinearLayout>

            <androidx.appcompat.widget.SwitchCompat
                android:id="@+id/introducer"
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="false"
                app:drawableLeftCompat="@drawable/ic_phonelink_black_24dp_active"
                app:drawableStartCompat="@drawable/ic_phonelink_black_24dp_active"
                android:text="@string/introducer" />

            <androidx.appcompat.widget.SwitchCompat
                android:id="@+id/autoAcceptFolders"
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="false"
                app:drawableLeftCompat="@drawable/baseline_auto_fix_high_24"
                app:drawableStartCompat="@drawable/baseline_auto_fix_high_24"
                android:text="@string/autoAcceptFolders" />

            <androidx.appcompat.widget.SwitchCompat
                android:id="@+id/devicePause"
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="false"
                app:drawableLeftCompat="@drawable/baseline_pause_circle_outline_24"
                app:drawableStartCompat="@drawable/baseline_pause_circle_outline_24"
                android:text="@string/pause_device" />

            <LinearLayout
                android:id="@+id/deviceUntrustedContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?selectableItemBackground"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/deviceUntrusted"
                    style="@style/Widget.Syncthing.TextView.Label.Details"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:checked="false"
                    app:drawableLeftCompat="@drawable/filled_lock_24"
                    app:drawableStartCompat="@drawable/filled_lock_24"
                    android:text="@string/untrusted_device" />

                    <TextView
                        android:id="@+id/deviceUntrustedExplanation"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="75dp"
                        android:layout_marginTop="-20dp"
                        android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                        android:text="@string/untrusted_device_explanation"
                        android:focusable="false"/>

            </LinearLayout>

            <!-- Custom sync conditions -->
            <LinearLayout
                android:id="@+id/customSyncConditionsContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?selectableItemBackground"
                android:orientation="vertical"
                android:gravity="center_vertical">

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/customSyncConditionsSwitch"
                    style="@style/Widget.Syncthing.TextView.Label.Details"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:checked="false"
                    app:drawableLeftCompat="@drawable/outline_autorenew_24"
                    app:drawableStartCompat="@drawable/outline_autorenew_24"
                    android:text="@string/custom_sync_conditions_title" />

                <TextView
                    android:id="@+id/customSyncConditionsDescription"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="75dp"
                    android:layout_marginTop="-20dp"
                    android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                    android:text="@string/custom_sync_conditions_description"
                    android:focusable="false"/>

                <TextView
                    android:id="@+id/customSyncConditionsDialog"
                    style="@style/Widget.Syncthing.TextView.Label.Details"
                    android:layout_marginStart="56dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/custom_sync_conditions_dialog"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="75dp"
                    android:layout_marginTop="-20dp"
                    android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                    android:text="@null"
                    android:focusable="false"/>

            </LinearLayout>

            <TextView
                android:id="@+id/currentAddress"
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:drawableLeftCompat="@drawable/ic_info_black_24dp_inactive"
                app:drawableStartCompat="@drawable/ic_info_black_24dp_inactive"
                android:enabled="false"
                android:hint="@string/current_address"
                android:visibility="gone"
                tools:visibility="visible" />

            <TextView
                android:id="@+id/syncthingVersion"
                style="@style/Widget.Syncthing.TextView.Label.Details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingStart="72dp"
                android:enabled="false"
                android:hint="@string/syncthing_version_title"
                android:visibility="gone"
                tools:visibility="visible"
                tools:ignore="RtlSymmetry"/>
        </LinearLayout>
    </ScrollView>

</LinearLayout>
