<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <PreferenceScreen
        android:title="@string/category_run_conditions"
        android:key="category_run_conditions">

        <Preference
            android:key="static_run_conditions"
            android:persistent="false"
            android:selectable="false"
            android:title="@string/run_conditions_title"
            android:summary="@string/run_conditions_summary"
            android:singleLineTitle="false" />

        <!-- Sync on WiFi -->
        <CheckBoxPreference
            android:key="run_on_wifi"
            android:title="@string/run_on_wifi_title"
            android:summary="@string/run_on_wifi_summary"
            android:singleLineTitle="false"
            android:defaultValue="true" />

        <!-- Sync on metered WiFi -->
        <CheckBoxPreference
            android:key="run_on_metered_wifi"
            android:title="@string/run_on_metered_wifi_title"
            android:summary="@string/run_on_metered_wifi_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Use WiFi Ssid whitelist -->
        <CheckBoxPreference
            android:key="use_wifi_whitelist"
            android:title="@string/run_on_whitelisted_wifi_title"
            android:summary="@string/run_on_whitelisted_wifi_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Select whitelisted WiFi Ssid -->
        <com.nutomic.syncthingandroid.views.WifiSsidPreference
            android:key="wifi_ssid_whitelist"
            android:title="@string/specify_wifi_ssid_whitelist"
            android:summary="@null"
            android:singleLineTitle="false" />

        <!-- Sync on mobile data -->
        <CheckBoxPreference
            android:key="run_on_mobile_data"
            android:title="@string/run_on_mobile_data_title"
            android:summary="@string/run_on_mobile_data_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Sync while roaming -->
        <CheckBoxPreference
            android:key="run_on_roaming"
            android:title="@string/run_on_roaming_title"
            android:summary="@string/run_on_roaming_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <ListPreference
            android:key="power_source"
            android:title="@string/power_source_title"
            android:entryValues="@array/power_source_values"
            android:entries="@array/power_source_entries"
            android:summary="@null"
            android:singleLineTitle="false"
            android:defaultValue="ac_and_battery_power" />

        <!-- Respect Android battery optimization -->
        <CheckBoxPreference
            android:key="respect_battery_saving"
            android:title="@string/respect_battery_saving_title"
            android:summary="@string/respect_battery_saving_summary"
            android:singleLineTitle="false"
            android:defaultValue="true" />

        <CheckBoxPreference
            android:key="respect_master_sync"
            android:title="@string/respect_master_sync_title"
            android:summary="@string/respect_master_sync_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <CheckBoxPreference
            android:key="run_in_flight_mode"
            android:title="@string/run_in_flight_mode_title"
            android:summary="@string/run_in_flight_mode_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Run on time schedule -->
        <CheckBoxPreference
            android:key="run_on_time_schedule"
            android:title="@string/run_on_time_schedule_title"
            android:summary="@string/run_on_time_schedule_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <EditTextPreference
            android:key="sync_duration_minutes"
            android:title="@string/sync_duration_minutes_title"
            android:summary="@string/sync_duration_minutes_summary"
            android:singleLineTitle="false"
            android:inputType="number"
            android:maxLength="9"
            android:defaultValue="5" />

        <EditTextPreference
            android:key="sleep_interval_minutes"
            android:title="@string/sleep_interval_minutes_title"
            android:summary="@string/sync_duration_minutes_summary"
            android:singleLineTitle="false"
            android:inputType="number"
            android:maxLength="1440"
            android:defaultValue="60" />

    </PreferenceScreen>

    <PreferenceScreen
        android:key="category_user_interface"
        android:title="@string/category_user_interface">

        <!-- App Theme -->
        <ListPreference
            android:key="app_theme"
            android:title="@string/preference_app_theme_title"
            android:entries="@array/app_theme_names"
            android:entryValues="@array/app_theme_values"
            android:singleLineTitle="false"
            android:defaultValue="-1" /> <!-- -1 is Follow system -->

        <!-- Expert mode -->
        <CheckBoxPreference
            android:key="expert_mode"
            android:title="@string/expert_mode_title"
            android:summary="@string/expert_mode_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <CheckBoxPreference
             android:key="start_into_web_gui"
             android:title="@string/start_into_web_gui_title"
             android:summary="@string/start_into_web_gui_summary"
             android:defaultValue="false"/>

    </PreferenceScreen>

    <PreferenceScreen
        android:key="category_behaviour"
        android:title="@string/category_behaviour">

        <!-- Autostart on boot -->
        <CheckBoxPreference
            android:key="always_run_in_background"
            android:title="@string/behaviour_autostart_title"
            android:summary="@string/behaviour_autostart_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Use root -->
        <CheckBoxPreference
            android:key="use_root"
            android:title="@string/use_root_title"
            android:summary="@string/use_root_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <CheckBoxPreference
            android:key="broadcast_service_control"
            android:title="@string/broadcast_service_control_title"
            android:summary="@string/broadcast_service_control_summary"
            android:singleLineTitle="false" />

    </PreferenceScreen>

    <PreferenceScreen
        android:key="category_syncthing_options"
        android:summary="@string/category_syncthing_options_summary"
        android:title="@string/category_syncthing_options">

        <EditTextPreference
            android:key="deviceName"
            android:title="@string/device_name"
            android:persistent="false"
            android:inputType="textCapWords" />

        <EditTextPreference
            android:key="listenAddresses"
            android:title="@string/listen_address"
            android:singleLineTitle="false"
            android:persistent="false"
            android:inputType="textNoSuggestions" />

        <EditTextPreference
            android:key="maxRecvKbps"
            android:title="@string/max_recv_kbps"
            android:singleLineTitle="false"
            android:persistent="false"
            android:inputType="number" />

        <EditTextPreference
            android:key="maxSendKbps"
            android:title="@string/max_send_kbps"
            android:singleLineTitle="false"
            android:persistent="false"
            android:inputType="number" />

        <CheckBoxPreference
            android:key="natEnabled"
            android:title="@string/enable_nat_traversal"
            android:singleLineTitle="false"
            android:persistent="false"/>

        <CheckBoxPreference
            android:key="localAnnounceEnabled"
            android:title="@string/local_announce_enabled"
            android:singleLineTitle="false"
            android:persistent="false" />

        <CheckBoxPreference
            android:key="globalAnnounceEnabled"
            android:title="@string/global_announce_enabled"
            android:singleLineTitle="false"
            android:persistent="false" />

        <CheckBoxPreference
            android:key="relaysEnabled"
            android:title="@string/enable_relaying"
            android:singleLineTitle="false"
            android:persistent="false" />

        <EditTextPreference
            android:key="globalAnnounceServers"
            android:title="@string/global_announce_server"
            android:singleLineTitle="false"
            android:persistent="false"
            android:inputType="textNoSuggestions" />

        <EditTextPreference
            android:key="webUITcpPort"
            android:title="@string/webui_tcp_port_title"
            android:singleLineTitle="false"
            android:summary=""
            android:persistent="false"
            android:inputType="number" />

        <CheckBoxPreference
            android:key="webUIRemoteAccess"
            android:title="@string/webui_remote_access_title"
            android:summary="@string/webui_remote_access_summary"
            android:singleLineTitle="false"
            android:persistent="false" />

        <EditTextPreference
            android:key="webui_username"
            android:title="@string/webui_username_title"
            android:singleLineTitle="false"
            android:summary="@null"
            android:persistent="false"
            android:inputType="textNoSuggestions" />

        <EditTextPreference
            android:key="webui_password"
            android:title="@string/webui_password_title"
            android:singleLineTitle="false"
            android:summary="@null"
            android:persistent="true"
            android:inputType="textNoSuggestions" />

        <Preference
            android:persistent="false"
            android:selectable="true"
            android:key="syncthing_api_key"
            android:title="@string/syncthing_api_key"
            android:singleLineTitle="false" />

        <CheckBoxPreference
            android:key="urAccepted"
            android:title="@string/usage_reporting"
            android:singleLineTitle="false"
            android:persistent="false" />

        <CheckBoxPreference
            android:key="crashReportingEnabled"
            android:title="@string/crash_reporting"
            android:singleLineTitle="false"
            android:persistent="false" />

        <CheckBoxPreference
            android:key="webUIDebugging"
            android:title="@string/webui_debugging_title"
            android:summary="@string/webui_debugging_summary"
            android:singleLineTitle="false"
            android:persistent="false" />

        <Preference
            android:key="clearStVersions"
            android:title="@string/clear_stversions_title"
            android:summary="@string/clear_stversions_summary"
            android:persistent="false"
            android:singleLineTitle="false" />

        <Preference
            android:key="downloadSupportBundle"
            android:title="@string/download_support_bundle_title"
            android:persistent="false"
            android:singleLineTitle="false" />

        <Preference
            android:key="undo_ignored_devices_folders"
            android:title="@string/undo_ignored_devices_folders_title"
            android:persistent="false"
            android:singleLineTitle="false" />

    </PreferenceScreen>

    <PreferenceScreen
        android:key="category_import_export"
        android:title="@string/category_backup">

        <PreferenceCategory android:title="@string/preference_category_explanation">
            <Preference
                android:persistent="false"
                android:selectable="false"
                android:key="backup_password_summary"
                android:title="@string/backup_password_summary"
                android:summary="@null"
                android:singleLineTitle="false" />
        </PreferenceCategory>

        <PreferenceCategory android:title="@string/preference_category_prepare">
            <EditTextPreference
                android:key="backup_rel_path_to_zip"
                android:title="@string/backup_rel_path_to_zip"
                android:summary="@null"
                android:persistent="true"
                android:defaultValue="backups/syncthing/config.zip"
                android:inputType="textNoSuggestions" />

            <EditTextPreference
                android:key="backup_password"
                android:title="@string/backup_password_title"
                android:summary="@null"
                android:persistent="true"
                android:defaultValue=""
                android:inputType="textNoSuggestions" />
        </PreferenceCategory>

        <PreferenceCategory android:title="@string/preference_category_actions">
            <Preference
                android:key="export_config"
                android:persistent="false"
                android:title="@string/export_config" />

            <Preference
                android:key="import_config"
                android:persistent="false"
                android:title="@string/import_config" />
        </PreferenceCategory>

    </PreferenceScreen>

    <PreferenceScreen
        android:title="@string/category_debug">

        <!-- Report issue -->
        <Preference
            android:key="open_issue_tracker"
            android:persistent="false"
            android:title="@string/report_issue_title"
            android:singleLineTitle="false">
        </Preference>

        <!-- Verbose log -->
        <CheckBoxPreference
            android:key="verbose_log"
            android:title="@string/verbose_log_title"
            android:summary="@string/verbose_log_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

        <!-- Open Android or SyncthingNative log -->
        <Preference
            android:title="@string/open_log"
            android:summary="@string/open_log_summary"
            android:singleLineTitle="false">
            <intent
                android:action=".activities.LogActivity" />
        </Preference>

        <!-- STTRACE facility chooser dialog -->
        <com.nutomic.syncthingandroid.views.SttracePreference
            android:key="debug_facilities_enabled"
            android:title="@string/sttrace_title"
            android:singleLineTitle="false" />

        <!-- Environment variables -->
        <EditTextPreference
            android:key="environment_variables"
            android:title="@string/environment_variables"
            android:singleLineTitle="false"
            android:inputType="textNoSuggestions"/>

        <!-- Reset database -->
        <Preference
            android:key="st_reset_database"
            android:title="@string/st_reset_database_title"
            android:singleLineTitle="false" />

        <!-- Reset index database -->
        <Preference
            android:key="st_reset_deltas"
            android:title="@string/st_reset_deltas_title"
            android:singleLineTitle="false" />

    </PreferenceScreen>

    <PreferenceScreen
        android:title="@string/category_experimental"
        android:key="category_experimental">

        <CheckBoxPreference
            android:key="use_tor"
            android:title="@string/use_tor_title"
            android:summary="@string/use_tor_summary"
            android:singleLineTitle="false" />

        <EditTextPreference
            android:key="socks_proxy_address"
            android:title="@string/socks_proxy_address_title"
            android:summary=""
            android:singleLineTitle="false"
            android:hint="@string/socks_proxy_address_title"
            android:inputType="textUri|textNoSuggestions" />

        <EditTextPreference
            android:key="http_proxy_address"
            android:title="@string/http_proxy_address_title"
            android:summary=""
            android:singleLineTitle="false"
            android:hint="@string/http_proxy_address_title"
            android:inputType="textUri|textNoSuggestions" />

        <!-- Only valid for Android < 6 -->
        <CheckBoxPreference
            android:key="wakelock_while_binary_running"
            android:title="@string/keep_wakelock_while_binary_running"
            android:summary="@string/keep_wakelock_while_binary_running_summary"
            android:singleLineTitle="false"
            android:defaultValue="false" />

    </PreferenceScreen>

    <PreferenceScreen
        android:title="@string/category_about">

        <Preference
            android:persistent="false"
            android:selectable="false"
            android:key="app_version"
            android:title="@string/app_version_title"
            android:singleLineTitle="false" />

        <Preference
            android:persistent="false"
            android:selectable="false"
            android:key="syncthing_version"
            android:title="@string/syncthing_version_title"
            android:singleLineTitle="false" />

        <Preference
            android:persistent="false"
            android:selectable="false"
            android:key="syncthing_database_size"
            android:title="@string/syncthing_database_size"
            android:singleLineTitle="false" />

        <Preference
            android:persistent="false"
            android:selectable="false"
            android:key="os_open_file_limit"
            android:title="@string/os_open_file_limit"
            android:singleLineTitle="false" />

        <Preference
            android:title="@string/syncthing_forum_title"
            android:summary="@string/syncthing_forum_summary">
            <intent
                android:action="android.intent.action.VIEW"
                android:data="@string/syncthing_forum_url" />
        </Preference>

        <Preference
            android:title="@string/pizza_url_title"
            android:summary="@string/pizza_url_summary">
            <intent
                android:action="android.intent.action.VIEW"
                android:data="@string/pizza_url" />
        </Preference>

        <Preference
            android:title="@string/privacy_title"
            android:summary="@string/privacy_summary">
            <intent
                android:action="android.intent.action.VIEW"
                android:data="@string/privacy_policy_url" />
        </Preference>

        <Preference
                android:persistent="false"
                android:key="open_source_licenses"
                android:title="@string/open_source_licenses_title"
                android:summary="@string/open_source_licenses_summary" />

    </PreferenceScreen>

</PreferenceScreen>
