<?xml version="1.0"?>
<manifest package="ch.opengis.@APP_PACKAGE_NAME@" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:versionName="@APP_VERSION_STR@" android:versionCode="@APK_VERSION_CODE@" android:installLocation="auto">

  <!-- The permissions are specified manually. This way we do not request the microphone permissions which would be pulled in
       as dependent permissions because of qt multimedia. -->
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />
  <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.FLASHLIGHT" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.NFC" />
  <uses-permission android:name="android.permission.BLUETOOTH"
      android:maxSdkVersion="30"
      />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
      android:maxSdkVersion="30"
      />
  <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
      android:maxSdkVersion="29"
      />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
      android:maxSdkVersion="28"
      />
  @QFIELD_EXTRA_PERMISSIONS@

  <uses-feature android:required="false" android:name="android.hardware.camera" />
  <uses-feature android:required="false" android:name="android.hardware.camera.autofocus" />
  <uses-feature android:required="false" android:name="android.hardware.location.gps" />
  <uses-feature android:required="false" android:name="android.hardware.microphone" />
  <uses-feature android:required="false" android:name="android.hardware.bluetooth" />

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

  <application
    android:hardwareAccelerated="true"
    android:name="org.qtproject.qt.android.bindings.QtApplication"
    android:label="@APP_NAME@"
    android:icon="@AT@drawable/@APP_ICON@"
    android:usesCleartextTraffic="true"
    android:requestLegacyExternalStorage="true"
    android:theme="@style/AppTheme">
    <activity
      android:name="ch.opengis.@APP_PACKAGE_NAME@.QFieldActivity"
      android:label="@APP_NAME@"
      android:icon="@AT@drawable/@APP_ICON@"
      android:launchMode="singleTask"
      android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
      android:theme="@style/AppTheme"
      android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>

      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="content" />
        <data android:mimeType="application/octet-stream" />
      </intent-filter>

      <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:host="*" />
        <data android:mimeType="application/pdf" />
        <data android:mimeType="application/vnd.sqlite3" />
        <data android:mimeType="application/x-sqlite3" />
        <data android:mimeType="application/geopackage+sqlite3" />
        <data android:mimeType="application/vnd.geo+json" />
        <data android:mimeType="application/geo+json" />
        <data android:mimeType="application/gpx+xml" />
        <data android:mimeType="application/vnd.google-earth.kml+xml" />
        <data android:mimeType="application/vnd.google-earth.kmz" />
        <data android:mimeType="application/zip" />
        <data android:mimeType="image/tiff" />
        <data android:mimeType="image/jp2" />
        <data android:mimeType="image/x-jp2" />
      </intent-filter>

      <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="file" />
        <data android:scheme="content" />
        <data android:host="*" />
        <data android:mimeType="application/pdf" />
        <data android:mimeType="application/vnd.sqlite3" />
        <data android:mimeType="application/x-sqlite3" />
        <data android:mimeType="application/geopackage+sqlite3" />
        <data android:mimeType="application/vnd.geo+json" />
        <data android:mimeType="application/geo+json" />
        <data android:mimeType="application/gpx+xml" />
        <data android:mimeType="application/vnd.google-earth.kml+xml" />
        <data android:mimeType="application/vnd.google-earth.kmz" />
        <data android:mimeType="application/zip" />
        <data android:mimeType="image/tiff" />
        <data android:mimeType="image/jp2" />
        <data android:mimeType="image/x-jp2" />
      </intent-filter>

      <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="file" />
        <data android:scheme="content" />
        <data android:host="*" />
        <data android:mimeType="*/*" />
        <data android:pathPattern=".*\\.qgs" />
        <data android:pathPattern=".*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.qgs" />
        <data android:pathPattern=".*\\.qgz" />
        <data android:pathPattern=".*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.qgz" />
        <data android:pathPattern=".*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpkg" />
        <data android:pathPattern=".*\\.kml" />
        <data android:pathPattern=".*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kml" />
        <data android:pathPattern=".*\\.kmz" />
        <data android:pathPattern=".*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kmz" />
        <data android:pathPattern=".*\\.geojson" />
        <data android:pathPattern=".*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.geojson" />
        <data android:pathPattern=".*\\.json" />
        <data android:pathPattern=".*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.json" />
        <data android:pathPattern=".*\\.pdf" />
        <data android:pathPattern=".*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\.tif" />
        <data android:pathPattern=".*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.tif" />
        <data android:pathPattern=".*\\.tiff" />
        <data android:pathPattern=".*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.tiff" />
        <data android:pathPattern=".*\\.jp2" />
        <data android:pathPattern=".*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.jp2" />
        <data android:pathPattern=".*\\.gpx" />
        <data android:pathPattern=".*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpx" />
        <data android:pathPattern=".*\\.zip" />
        <data android:pathPattern=".*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.zip" />
        <data android:pathPattern=".*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.mbtiles" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.mbtiles" />
      </intent-filter>

      <!-- Git Revision -->
      <meta-data android:name="android.app.git_rev" android:value="@string/git_rev"/>
      <!-- Git Revision -->

      <meta-data android:name="android.app.lib_name" android:value="@string/lib_name"/>
      <meta-data android:name="android.app.repository" android:value="default"/>
      <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
      <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
      <!-- Deploy Qt libs as part of package -->
      <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
      <!-- Run with local libs -->
      <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
      <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
      <meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
      <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
      <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
      <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
      <!--  Messages maps -->
      <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
      <!--  Messages maps -->

      <!-- Background running -->
      <!-- Warning: changing this value to true may cause unexpected crashes if the
                    application still try to draw after
                    "applicationStateChanged(Qt::ApplicationSuspended)"
                    signal is sent! -->
      <meta-data android:name="android.app.background_running" android:value="false"/>
      <!-- Background running -->
    </activity>

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

    <meta-data android:name="io.sentry.dsn" android:value="@SENTRY_DSN@" />
    <meta-data android:name="io.sentry.environment" android:value="@SENTRY_ENV@" />
    <meta-data android:name="io.sentry.auto-init" android:value="false" />

    <service android:process=":qt" android:name="ch.opengis.@APP_PACKAGE_NAME@.QFieldCloudService">
      <meta-data android:name="android.app.arguments" android:value="--cloudservice"/>
      <meta-data android:name="android.app.lib_name" android:value="@string/lib_name"/>
      <meta-data android:name="android.app.repository" android:value="default"/>
      <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
      <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
      <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
      <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
      <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
      <meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
      <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
      <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
      <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>

      <meta-data android:name="android.app.background_running" android:value="true"/>
    </service>

    <service android:process=":qt" android:name="ch.opengis.@APP_PACKAGE_NAME@.QFieldPositioningService" android:foregroundServiceType="location">
      <meta-data android:name="android.app.arguments" android:value="--positioningservice"/>
      <meta-data android:name="android.app.lib_name" android:value="@string/lib_name"/>
      <meta-data android:name="android.app.repository" android:value="default"/>
      <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
      <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
      <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
      <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
      <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
      <meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
      <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
      <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
      <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>

      <meta-data android:name="android.app.background_running" android:value="true"/>
    </service>
  </application>
  <queries>
    <!-- Camera -->
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>

    <!-- Gallery -->
    <intent>
        <action android:name="android.intent.action.GET_CONTENT" />
    </intent>
  </queries>
</manifest>
