<?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:fillViewport="true"
    tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="16dp">

        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/warningNotPaired"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginEnd="16dp"
            android:autoLink="web"
            android:ems="10"
            android:gravity="start|top"
            android:text="@string/warning_not_paired"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/deviceRadioGroup" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/nodeSettings"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="16dp"
        >

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/usernameView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:hint="@string/your_name"
            app:layout_constraintHorizontal_weight="2"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/regionSpinner"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/usernameEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:imeOptions="actionDone"
                android:singleLine="true" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/regionLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="@string/region"
            app:layout_constraintEnd_toEndOf="@+id/regionSpinner"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="Region" />

        <Spinner
            android:id="@+id/regionSpinner"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="16dp"
            android:entries="@array/regions"
            android:theme="@style/AppTheme.Spinner"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@id/regionLabel"
            app:layout_constraintStart_toEndOf="@+id/usernameView"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>

        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/scanStatusText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="8dp"
            android:text="@string/looking_for_meshtastic_devices"
            app:layout_constraintEnd_toStartOf="@+id/updateFirmwareButton"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/nodeSettings" />

        <ProgressBar
            android:id="@+id/scanProgressBar"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/deviceRadioGroup" />

        <RadioGroup
            android:id="@+id/deviceRadioGroup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/changeRadioButton">

            <RadioButton
                android:id="@+id/radioButton2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/test__devname1" />

            <RadioButton
                android:id="@+id/radioButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/test_devname2" />
        </RadioGroup>

        <CheckBox
            android:id="@+id/analyticsOkayCheckbox"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            android:background="@color/cardview_light_background"
            android:checked="true"
            android:text="@string/analytics_okay"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/reportBugButton"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/warningNotPaired"
            app:layout_constraintVertical_bias="1.0" />

        <Button
            android:id="@+id/reportBugButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            android:text="@string/report_bug"
            app:layout_constrainedWidth="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintWidth_percent="0.4" />

        <Button
            android:id="@+id/changeRadioButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/select_radio"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/scanStatusText" />

        <Button
            android:id="@+id/updateFirmwareButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:text="@string/update_firmware"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/scanStatusText" />

        <ProgressBar
            android:id="@+id/updateProgressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:visibility="gone"
            app:layout_constraintEnd_toEndOf="@+id/updateFirmwareButton"
            app:layout_constraintStart_toStartOf="@+id/updateFirmwareButton"
            app:layout_constraintTop_toBottomOf="@+id/updateFirmwareButton" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>