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

    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.software.leanback" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />

    <uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <!-- ACCESS_COARSE_LOCATION is required to get WiFi's SSID on 8.1 -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <!-- ACCESS_FINE_LOCATION is required to get WiFi's SSID on 10 "Q" -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- ACCESS_BACKGROUND_LOCATION is required to get WiFi's SSID since Android 10 SDK 29 -->
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <!-- FOREGROUND_SERVICE is required since Android 9 SDK 28 -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
    <!-- WRITE_SETTINGS, WRITE_SECURE_SETTINGS are required to disable DuraSpeed -->
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <!-- CAMERA is required for the "Syncthing Camera" feature and QR scanning -->
    <uses-permission android:name="android.permission.CAMERA" />
    <!-- MANAGE_EXTERNAL_STORAGE is required on Android 11 "R" -->
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
    <!-- CHANGE_WIFI_MULTICAST_STATE is required for local discovery to work on Android 11 "R" -->
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
    <!-- POST_NOTIFICATIONS is required for the foreground service since Android 13 "T" -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

    <!--
        Apps can listen to our notifications about sync progress by subscribing to ACTION_NOTIFY_FOLDER_SYNC_COMPLETE,
        see RestApi for more details. To do so, they must declare the following in their app manifest.
        <uses-permission android:name="com.github.catfriend1.syncthingandroid.permission.RECEIVE_SYNC_STATUS"/>
    -->
    <permission android:name="com.github.catfriend1.syncthingandroid.permission.RECEIVE_SYNC_STATUS" 
            android:label="RECEIVE_SYNC_STATUS" 
            android:protectionLevel="normal">
    </permission>

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/backup_rules"
        android:fullBackupContent="@xml/backup_rules_legacy"
        android:icon="@mipmap/ic_launcher"
        android:banner="@drawable/banner"
        android:label="@string/app_name"
        android:theme="@style/Theme.Syncthing"
        android:description="@string/app_description"
        android:supportsRtl="true"
        android:installLocation="internalOnly"
        android:name=".SyncthingApp"
        android:hardwareAccelerated="true"
        android:requestLegacyExternalStorage="true"
        android:preserveLegacyExternalStorage="true"
        android:hasFragileUserData="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:localeConfig="@xml/locales_config">
        <activity
                android:name=".activities.FirstStartActivity"
                android:exported="true"
                android:launchMode="singleInstance">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
                android:name=".activities.PhotoShootActivity"
                android:icon="@mipmap/ic_launcher_photoshoot"
                android:label="@string/photo_shoot_launcher_title"
                android:exported="true"
                android:launchMode="singleInstance">
        </activity>
        <activity
            android:name=".activities.MainActivity"
            android:exported="false"
            android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.github.catfriend1.syncthingandroid.MainActivity.EXIT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.RecentChangesActivity"
            android:label="@string/recent_changes_title"
            android:parentActivityName=".activities.MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <activity
            android:name=".activities.TipsAndTricksActivity"
            android:label="@string/tips_and_tricks_title"
            android:parentActivityName=".activities.MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <activity
            android:name=".activities.WebGuiActivity"
            android:label="@string/web_gui_title"
            android:parentActivityName=".activities.MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <activity
            android:name=".activities.WebViewActivity"
            android:label="@string/report_issue_title"
            android:configChanges="keyboardHidden|orientation|screenSize">
        </activity>
        <activity
            android:name=".activities.ShareActivity"
            android:label="@string/share_activity_title"
            android:exported="true"
            android:excludeFromRecents="true"
            android:taskAffinity=""
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.LogActivity"
            android:exported="true"
            android:parentActivityName=".activities.SettingsActivity">
            <intent-filter>
                <action android:name=".activities.LogActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.SettingsActivity" />
        </activity>
        <activity
            android:name=".activities.FolderPickerActivity"
            android:label="@string/folder_picker_title">
            <meta-data
                android:name="android.support.UI_OPTIONS"
                android:value="splitActionBarWhenNarrow" />
        </activity>
        <activity
            android:name=".activities.SyncConditionsActivity"
            android:label="@string/custom_sync_conditions_dialog">
            <meta-data
                android:name="android.support.UI_OPTIONS"
                android:value="splitActionBarWhenNarrow" />
        </activity>
        <activity android:name=".activities.DeviceActivity"
            android:parentActivityName=".activities.MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <activity android:name=".activities.FolderActivity"
            android:parentActivityName=".activities.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <activity android:name=".activities.SettingsActivity"
            android:label="@string/settings_title"
            android:configChanges="orientation|screenSize"
            android:parentActivityName=".activities.MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.MainActivity" />
        </activity>
        <service
            android:name=".service.SyncthingService"
            android:foregroundServiceType="specialUse">
                <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="Syncthing is a continuous file sync app. If the user explicitly enables it running permanently in the background, it needs to monitor file changes at every time and receive or send changes made on the device or connected devices."/>
        </service>
        <service
            android:name=".service.SyncTriggerJobService"
            android:label="SyncTriggerJobService"
            android:permission="android.permission.BIND_JOB_SERVICE" >
       </service>
        <receiver
            android:name=".receiver.BootReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".receiver.AppConfigReceiver"
            android:exported="true"
            tools:ignore="ExportedReceiver">
            <intent-filter>
                <action android:name="com.github.catfriend1.syncthingandroid.action.FOLLOW" />
                <action android:name="com.github.catfriend1.syncthingandroid.action.START" />
                <action android:name="com.github.catfriend1.syncthingandroid.action.STOP" />
            </intent-filter>
        </receiver>
        <activity android:name=".activities.FolderTypeDialogActivity"
            android:label="@string/folder_type"
            android:theme="@style/Theme.Syncthing.Dialog"
            android:parentActivityName=".activities.FolderActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.nutomic.syncthingandroid.activities.FolderActivity" />
        </activity>
        <activity android:name=".activities.PullOrderDialogActivity"
            android:label="@string/pull_order"
            android:theme="@style/Theme.Syncthing.Dialog"
            android:parentActivityName=".activities.FolderActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.nutomic.syncthingandroid.activities.FolderActivity" />
        </activity>
        <activity android:name=".activities.VersioningDialogActivity"
            android:label="@string/file_versioning"
            android:theme="@style/Theme.Syncthing.Dialog"
            android:parentActivityName=".activities.FolderActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.nutomic.syncthingandroid.activities.FolderActivity" />
        </activity>
        <activity android:name=".activities.QRScannerActivity"
            android:label="QR Code Scanner"
            android:parentActivityName=".activities.DeviceActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.nutomic.syncthingandroid.activities.DeviceActivity" />
        </activity>
        <activity android:name=".activities.LicenseActivity"
            android:label="@string/open_source_licenses_title"
            android:exported="false"
            android:parentActivityName=".activities.SettingsActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".activities.SettingsActivity" />
        </activity>
        <property
            android:name="android.content.MEDIA_CAPABILITIES"
            android:resource="@xml/media_capabilities" />
        <provider
             android:name="androidx.core.content.FileProvider"
             android:authorities="${applicationId}.provider"
             android:exported="false"
             android:grantUriPermissions="true">
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
                 android:resource="@xml/file_paths">
             </meta-data>
         </provider>
        <service
            android:name=".service.QuickSettingsTileForce"
            android:label="@string/qs_force_label"
            android:icon="@drawable/ic_qs_force"
            android:exported="true"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            tools:targetApi="24">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>
        <service
            android:name=".service.QuickSettingsTileSchedule"
            android:label="@string/qs_schedule_label"
            android:icon="@drawable/ic_qs_schedule"
            android:exported="true"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            tools:targetApi="24">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>
        <service
            android:name=".service.QuickSettingsTileCamera"
            android:label="@string/photo_shoot_activity_title"
            android:icon="@drawable/ic_qs_camera"
            android:exported="true"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            tools:targetApi="24">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>
    </application>

    <queries>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
    </queries>

</manifest>
