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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <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.FOREGROUND_SERVICE_DATA_SYNC"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>

<!--    <permission android:name="ac.mdiq.podcini.BIND_PROVIDER" android:protectionLevel="normal" />-->

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"/>

    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="false"/>
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false"/>

<!--    this is now taken out from application -->
<!--    android:usesCleartextTraffic="true"-->

    <application
        android:name="ac.mdiq.podcini.PodciniApp"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:backupAgent=".config.OpmlBackupAgent"
        android:restoreAnyVersion="true"
        android:theme="@style/Theme.Podcini.Splash"
        android:supportsRtl="true"
        android:logo="@mipmap/ic_launcher"
        android:resizeableActivity="true"
        android:allowAudioPlaybackCapture="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:enableOnBackInvokedCallback="true"
        tools:targetApi="33">

        <service android:name=".playback.service.PlaybackService"
                 android:foregroundServiceType="mediaPlayback"
                 android:label="@string/app_name"
                 android:enabled="true"
                 android:exported="true"
                 tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="androidx.media3.session.MediaLibraryService"/>
                <action android:name="android.media.browse.MediaBrowserService"/>
                <action android:name="ac.mdiq.podcini.intents.PLAYBACK_SERVICE" />
            </intent-filter>
        </service>

        <service
            android:name="androidx.work.impl.foreground.SystemForegroundService"
            android:exported="false"
            android:foregroundServiceType="dataSync"
            android:enabled="true"
            tools:replace="android:enabled,android:foregroundServiceType" />

        <receiver
            android:name=".receiver.MediaButtonReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
            <intent-filter>
                <action android:name="ac.mdiq.podcini.NOTIFY_BUTTON_RECEIVER" />
            </intent-filter>
        </receiver>

        <receiver
            android:name=".receiver.AlarmReceiver"
            android:enabled="true"
            android:exported="false">
        </receiver>

        <service
            android:name=".playback.service.QuickSettingsTileService"
            android:enabled="true"
            android:exported="true"
            android:label="@string/app_name"
            android:icon="@drawable/ic_notification"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
            <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" android:value="true" />
            <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE" android:value="true" />
        </service>

        <meta-data android:name="android.webkit.WebView.MetricsOptOut"
            android:value="true"/>
        <meta-data android:name="com.google.android.gms.car.notification.SmallIcon"
            android:resource="@drawable/ic_notification"/>
        <meta-data
            android:name="com.google.android.gms.car.application"
            android:resource="@xml/automotive_app_desc"/>
        <meta-data
            android:name="com.google.android.backup.api_key"
            android:value="AEdPqrEAAAAI3a05VToCTlqBymJrbFGaKQMvF-bBAuLsOdavBA"/>
        <meta-data
            android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="ac.mdiq.podcini.playback.cast.CastOptionsProvider" />

        <!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
        <meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
        <!-- Version >= 3.0. DeX Dual Mode support -->
        <meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>

        <activity
            android:name=".activity.MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|density|uiMode|keyboard|navigation"
            android:windowSoftInputMode="stateAlwaysHidden"
            android:launchMode="singleTop"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
                <action android:name="android.intent.action.MUSIC_PLAYER" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.APP_MUSIC" />
                <category android:name="com.android.launcher3.DEEP_SHORTCUT" />

                <action android:name="ac.mdiq.podcini.intents.MAIN_ACTIVITY" />
                <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
            </intent-filter>
            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity>

        <activity
            android:name=".activity.ShareReceiverActivity"
            android:configChanges="orientation|screenSize"
            android:theme="@style/Theme.Podcini"
            android:label="@string/add_feed_label"
            android:exported="true"
            android:parentActivityName="ac.mdiq.podcini.activity.MainActivity">

            <!-- Files with mimeType rss/xml/atom -->
            <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="http"/>
                <data android:host="*"/>
                <data android:scheme="https"/>
                <data android:mimeType="text/xml"/>
                <data android:mimeType="application/rss+xml"/>
                <data android:mimeType="application/atom+xml"/>
                <data android:mimeType="application/xml"/>
            </intent-filter>

            <!-- Podcast protocols -->
            <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="itpc"/>
                <data android:scheme="pcast"/>
                <data android:scheme="feed"/>
                <data android:scheme="podcini-subscribe"/>
            </intent-filter>

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

        <activity
            android:name=".activity.BugReportActivity"
            android:theme="@style/Theme.Podcini">
        </activity>

        <activity
            android:name=".activity.QueuePickerActivity"
            android:theme="@style/Theme.Podcini.Dialog"
            android:taskAffinity=""
            android:excludeFromRecents="true"
            android:exported="false" />

        <activity
            android:name=".activity.EpisodeInfoActivity"
            android:theme="@style/Theme.Podcini.Dialog"
            android:launchMode="singleInstance"
            android:taskAffinity=".episode_info"
            android:excludeFromRecents="true"
            android:exported="false" />

        <activity
            android:name=".activity.PlayerUIActivity"
            android:theme="@style/Theme.Podcini.Dialog"
            android:launchMode="singleInstance"
            android:taskAffinity=".player_ui"
            android:excludeFromRecents="true"
            android:exported="false" />

        <activity
            android:name=".activity.ShortcutsActivity"
            android:exported="false"
            android:theme="@style/Theme.Podcini">
        </activity>

        <activity-alias
            android:name=".FeedAlias"
            android:targetActivity=".activity.ShortcutsActivity"
            android:label="@string/podcast"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_SHORTCUT" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".QueueAlias"
            android:targetActivity=".activity.ShortcutsActivity"
            android:label="@string/queue"
            android:exported="true"
            android:parentActivityName="ac.mdiq.podcini.activity.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_SHORTCUT" />
            </intent-filter>
        </activity-alias>

        <activity-alias
            android:name=".FacetAlias"
            android:targetActivity=".activity.ShortcutsActivity"
            android:label="@string/facet"
            android:exported="true"
            android:parentActivityName="ac.mdiq.podcini.activity.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_SHORTCUT" />
            </intent-filter>
        </activity-alias>

        <receiver
            android:name=".receiver.WidgetReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>

        <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/provider_paths" />
        </provider>

        <meta-data
            tools:ignore="Deprecated"
            android:name="com.google.android.actions"
            android:resource="@xml/actions" />
    </application>

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
    </queries>

    <queries>
        <intent>
            <action android:name="ac.mdiq.podcini.action.PODCINI_GATEWAY" />
        </intent>
    </queries>

</manifest>
