<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (c) 2025 Element Creations Ltd.
  ~ Copyright 2022 New Vector Ltd.
  ~
  ~ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
  ~ Please see LICENSE files in the repository root for full details.
  -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <!-- To be able to install APK from the application -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

    <application
        android:name=".ElementXApplication"
        android:allowBackup="false"
        android:appCategory="social"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:enableOnBackInvokedCallback="true"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:localeConfig="@xml/locales_config"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.ElementX"
        tools:targetApi="33">

        <meta-data
            android:name="com.google.android.gms.car.application"
            android:resource="@xml/automotive_app_desc" />

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <meta-data
                android:name='androidx.lifecycle.ProcessLifecycleInitializer'
                android:value='androidx.startup' />

            <!-- Remove to use Application workManagerConfiguration -->
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup"
                tools:node="remove" />
        </provider>

        <!--
        Using launchMode singleTask to avoid multiple instances of the Activity
        when the app is already open. This is important for incoming share (see
        https://github.com/element-hq/element-x-android/issues/4074) and for opening
        the application from a mobile.element.io link.
        -->
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|uiMode"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/Theme.ElementX.Splash"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <!-- Handle deep-link for notification ./tools/adb/deeplink.sh -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:host="open"
                    android:scheme="elementx" />
            </intent-filter>
            <!--
              Oidc redirection
            -->
            <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="@string/login_redirect_scheme" />
            </intent-filter>
            <!--
              Element web links
            -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:scheme="https" />
                <!-- Note: we can't use "*.element.io" here because it'll intercept the "mas.element.io" domain too. -->
                <!-- Matching asset file: https://app.element.io/.well-known/assetlinks.json -->
                <data android:host="app.element.io" />
                <!-- Matching asset file: https://develop.element.io/.well-known/assetlinks.json -->
                <data android:host="develop.element.io" />
                <!-- Matching asset file: https://staging.element.io/.well-known/assetlinks.json -->
                <data android:host="staging.element.io" />
            </intent-filter>
            <!--
              Element mobile links
              Example: https://mobile.element.io/element/?account_provider=example.org&login_hint=mxid:@alice:example.org
            -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:scheme="https" />
                <!-- Matching asset file: https://mobile.element.io/.well-known/assetlinks.json -->
                <data android:host="mobile.element.io" />
                <data android:path="/element/" />
            </intent-filter>
            <!--
              matrix.to links
              Note: On Android 12 and higher clicking a web link (that is not an Android App Link) always shows content in a web browser
              https://developer.android.com/training/app-links#web-links
            -->
            <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="https" />
                <data android:host="matrix.to" />
            </intent-filter>
            <!--
              matrix: links
            -->
            <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="matrix" />
            </intent-filter>
            <!--
              links from matrix.to website
            -->
            <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="element" />
                <data android:host="user" />
                <data android:host="room" />
            </intent-filter>
            <!-- Incoming share simple -->
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <data android:mimeType="*/*" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.OPENABLE" />
            </intent-filter>
            <!-- Incoming share multiple -->
            <intent-filter>
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <data android:mimeType="*/*" />

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

        <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_providers" />
        </provider>
    </application>

</manifest>
