<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2025 Meshtastic LLC
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->

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

    <application
        android:name="org.meshtastic.app.GoogleMeshUtilApplication"
        tools:replace="android:name">
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="${MAPS_API_KEY}" />
        <property
            android:name="android.app.appfunctions.app_metadata"
            android:resource="@xml/app_metadata" />

        <!--
          Register as an "Open in / Send to Meshtastic" target for GeoJSON/KML map files (e.g. the Meshtastic Site
          Planner's "Send to App" share). Google flavor only — it's the flavor that renders map overlays. Merged into
          the MainActivity declared in the base manifest. application/json is broad, but the map importer validates the
          file extension and ignores anything that isn't a supported layer.
        -->
        <activity
            android:name="org.meshtastic.app.MainActivity"
            tools:node="merge">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/geo+json" />
                <data android:mimeType="application/vnd.geo+json" />
                <data android:mimeType="application/json" />
                <data android:mimeType="application/vnd.google-earth.kml+xml" />
                <data android:mimeType="application/vnd.google-earth.kmz" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/geo+json" />
                <data android:mimeType="application/vnd.geo+json" />
                <data android:mimeType="application/json" />
                <data android:mimeType="application/vnd.google-earth.kml+xml" />
                <data android:mimeType="application/vnd.google-earth.kmz" />
            </intent-filter>
        </activity>

        <!--
          AppFunctions 1.0.0-alpha10 discontinued the appfunctions-service artifact whose
          manifest used to contribute these two delegate services; apps must now declare
          them (mirrors the alpha09 appfunctions-service AAR manifest, classes relocated
          to the androidx.appfunctions package).
        -->
        <service
            android:name="androidx.appfunctions.PlatformAppFunctionService"
            android:enabled="@bool/enablePlatformAppFunctionService"
            android:exported="true"
            android:permission="android.permission.BIND_APP_FUNCTION_SERVICE"
            tools:targetApi="36">
            <property
                android:name="android.app.appfunctions"
                android:value="app_functions.xml" />
            <property
                android:name="android.app.appfunctions.schema"
                android:value="app_functions_schema.xsd" />
            <property
                android:name="android.app.appfunctions.v2"
                android:value="app_functions_v2.xml" />
            <intent-filter>
                <action android:name="android.app.appfunctions.AppFunctionService" />
            </intent-filter>
        </service>
        <service
            android:name="androidx.appfunctions.ExtensionAppFunctionService"
            android:enabled="@bool/enableExtensionAppFunctionService"
            android:exported="true"
            android:permission="android.permission.BIND_APP_FUNCTION_SERVICE">
            <property
                android:name="android.app.appfunctions"
                android:value="app_functions.xml" />
            <property
                android:name="android.app.appfunctions.schema"
                android:value="app_functions_schema.xsd" />
            <property
                android:name="android.app.appfunctions.v2"
                android:value="app_functions_v2.xml" />
            <intent-filter>
                <action android:name="android.app.appfunctions.AppFunctionService" />
            </intent-filter>
        </service>
    </application>

</manifest>
