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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />

    <!-- OAuth -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission
        android:name="android.permission.USE_CREDENTIALS"
        android:maxSdkVersion="22" />

    <!-- https://developer.android.com/guide/topics/manifest/uses-feature-element#features-reference -->
    <uses-feature
        android:name="android.software.app_widgets"
        android:required="false" />
    <uses-feature
        android:name="android.software.webview"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.fingerprint"
        android:required="false" />

    <application
        android:name=".ApplicationEx"
        android:allowBackup="false"
        android:appCategory="productivity"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppThemeLight">

        <!-- do not contact Google servers -->
        <meta-data
            android:name="android.webkit.WebView.MetricsOptOut"
            android:value="true" />
        <meta-data
            android:name="android.webkit.WebView.EnableSafeBrowsing"
            android:value="false" />
        <meta-data
            android:name="android.allow_multiple_resumed_activities"
            android:value="true" />

        <activity
            android:name=".ActivityMain"
            android:excludeFromRecents="true"
            android:exported="true"
            android:launchMode="singleInstance"
            android:theme="@style/Theme.AppCompat.Translucent">

            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="${applicationId}.REFRESH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivitySetup"
            android:exported="true"
            android:launchMode="singleTask"
            android:parentActivityName=".ActivityMain">

            <intent-filter>
                <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityWidgetUnified"
            android:exported="true">

            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityView"
            android:exported="false"
            android:launchMode="singleTask"
            android:parentActivityName=".ActivityMain" />

        <activity
            android:name=".ActivitySearch"
            android:enabled="false"
            android:excludeFromRecents="true"
            android:exported="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_search"
            android:launchMode="singleTask"
            android:theme="@style/Theme.AppCompat.Translucent">

            <intent-filter>
                <action android:name="android.intent.action.PROCESS_TEXT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityCompose"
            android:exported="true"
            android:launchMode="singleTask"
            android:parentActivityName=".ActivityView">

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />

                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SENDTO" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="mailto" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="mailto" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityEML"
            android:exported="true"
            android:icon="@mipmap/ic_launcher"
            android:launchMode="singleTask">

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="content" />
                <data android:mimeType="message/rfc822" />
                <data android:host="*" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="content" />
                <data android:mimeType="*/*" />
                <data android:host="*" />
                <data android:pathPattern=".*\\.eml" />
                <data android:pathPattern=".*\\..*\\.eml" />
                <data android:pathPattern=".*\\..*\\..*\\.eml" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.eml" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.eml" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityDSN"
            android:exported="true"
            android:icon="@mipmap/ic_launcher"
            android:launchMode="singleTask">

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="content" />
                <data android:mimeType="message/delivery-status" />
                <data android:mimeType="message/disposition-notification" />
                <data android:mimeType="text/rfc822-headers" />
                <data android:host="*" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ActivityBilling"
            android:icon="@mipmap/ic_launcher"
            android:launchMode="singleTask" />

        <service
            android:name=".ServiceSynchronize"
            android:foregroundServiceType="dataSync" />

        <service
            android:name=".ServiceSend"
            android:foregroundServiceType="dataSync" />

        <service android:name=".ServiceUI" />

        <service
            android:name=".ServiceExternal"
            android:foregroundServiceType="dataSync">

            <intent-filter>
                <action android:name="${applicationId}.POLL" />
                <action android:name="${applicationId}.ENABLE" />
                <action android:name="${applicationId}.DISABLE" />
            </intent-filter>
        </service>

        <service
            android:name=".ServiceTileSynchronize"
            android:icon="@drawable/baseline_sync_disabled_24"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>

        <service
            android:name=".ServiceTileUnseen"
            android:icon="@drawable/baseline_mail_outline_24"
            android:label="@string/tile_unseen"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}"
            android:exported="false"
            android:grantUriPermissions="true">

            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/fileprovider_paths" />
        </provider>

        <receiver
            android:name=".Widget"
            android:label="@string/tile_unseen">

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget" />

            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
        </receiver>

        <receiver
            android:name=".WidgetUnified"
            android:label="@string/title_folder_unified">

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_unified" />

            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
        </receiver>

        <service
            android:name="WidgetUnifiedService"
            android:permission="android.permission.BIND_REMOTEVIEWS" />

        <receiver android:name=".ReceiverAutoStart">

            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
    </application>
</manifest>