<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="btools.routingapp">

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

    <application
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:preserveLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/Theme.App">
        <activity
            android:name=".BRouterActivity"
            android:exported="true"
            android:screenOrientation="unspecified">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".BInstallerActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:screenOrientation="landscape" />
        <activity
            android:name=".BImportActivity"
            android:exported="true"
            android:label="Import Profile">
            <!-- some apps (bluemail) do not recognize the .brf file extension, startactivity+intent is done for attachment with text/plain -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="file" />
                <data android:scheme="content" />
                <data android:mimeType="text/plain" />
            </intent-filter>

            <!-- general intent to register .brf files -->
            <intent-filter
                android:label="@string/app_name"
                android:priority="50">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:scheme="file" />
                <data android:scheme="content" />
                <data android:host="*" />
                <data android:pathPattern=".*\\.brf" />
                <data android:pathPattern=".*\\..*\\.brf" />
                <data android:pathPattern=".*\\..*\\..*\\.brf" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.brf" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.brf" />
            </intent-filter>

            <intent-filter
                android:label="@string/app_name"
                android:priority="50">
                <action android:name="android.intent.action.VIEW" />

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

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

        <service
            android:name=".BRouterService"
            android:enabled="true"
            android:exported="true"
            android:process=":brouter_service" />

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="btools.routing.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>

    </application>
</manifest>
