<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-feature android:name="android.software.leanback" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="video/*" />
        </intent>
    </queries>

    <application
        android:name=".YokanApplication"
        android:allowBackup="true"
        android:banner="@drawable/tv_banner"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher"
        android:label="Yokan"
        android:largeHeap="true"
        android:theme="@style/AppTheme"
        android:resizeableActivity="true"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|keyboard|smallestScreenSize|density|uiMode"
            android:exported="true"
            android:supportsPictureInPicture="true"
            android:launchMode="singleTop">

            <intent-filter android:label="Add source repository">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="yokan" android:host="add-repo" />
            </intent-filter>
            <intent-filter android:label="Add custom button">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="yokan" android:host="add-button" />
            </intent-filter>
            <!-- Mihon/Tachiyomi (manga) and Aniyomi/Animetail (anime) repository links, as Animetail registers them. -->
            <intent-filter android:label="Add extension repository">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="tachiyomi" />
                <data android:scheme="mihon" />
                <data android:scheme="aniyomi" />
                <data android:scheme="animetail" />
                <data android:host="add-repo" />
                <data android:host="extension-store" />
            </intent-filter>
            <intent-filter android:label="Search in Yokan">
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
            <intent-filter android:label="Search in Yokan">
                <action android:name="android.intent.action.PROCESS_TEXT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <action android:name="android.intent.action.WEB_SEARCH" />
                <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- Backup files. PatternMatcher cannot skip earlier dots, so each depth is listed (https://stackoverflow.com/a/31028507). -->
            <intent-filter android:label="Restore backup">
                <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=".*\\.tachibk" />
                <data android:pathPattern=".*\\..*\\.tachibk" />
                <data android:pathPattern=".*\\..*\\..*\\.tachibk" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.tachibk" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.tachibk" />
                <data android:pathPattern=".*\\.proto\\.gz" />
                <data android:pathPattern=".*\\..*\\.proto\\.gz" />
                <data android:pathPattern=".*\\..*\\..*\\.proto\\.gz" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.proto\\.gz" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.proto\\.gz" />
                <data android:pathPattern=".*\\.backup" />
                <data android:pathPattern=".*\\..*\\.backup" />
                <data android:pathPattern=".*\\..*\\..*\\.backup" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.backup" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.backup" />
                <data android:pathPattern=".*\\.yokanbak" />
                <data android:pathPattern=".*\\..*\\.yokanbak" />
                <data android:pathPattern=".*\\..*\\..*\\.yokanbak" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.yokanbak" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.yokanbak" />
            </intent-filter>
            <intent-filter android:label="Tracker callback">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="yokan" />
            </intent-filter>
        </activity>
        <activity-alias
            android:name=".LauncherDefault"
            android:targetActivity=".MainActivity"
            android:enabled="true"
            android:exported="true"
            android:icon="@mipmap/ic_launcher"
            android:label="Yokan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
        </activity-alias>
        <activity-alias
            android:name=".LauncherToriiLight"
            android:targetActivity=".MainActivity"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_torii_light"
            android:label="Yokan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
        </activity-alias>
        <activity-alias
            android:name=".LauncherToriiDark"
            android:targetActivity=".MainActivity"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_torii_dark"
            android:label="Yokan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
        </activity-alias>
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>
        <service
            android:name=".services.download.DownloadForegroundService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />
    </application>
</manifest>
