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

  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission
    android:name="android.permission.ACCESS_FINE_LOCATION"
    android:maxSdkVersion="32" />
  <uses-permission
    android:name="android.permission.NEARBY_WIFI_DEVICES"
    android:usesPermissionFlags="neverForLocation"
    tools:targetApi="s" />
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  <uses-permission android:name="${permission}" />

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

  <application
    android:name=".KiwixApp"
    android:allowBackup="true"
    android:extractNativeLibs="false"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    tools:targetApi="m">

    <activity
      android:name=".main.KiwixMainActivity"
      android:configChanges="orientation|keyboardHidden|screenSize"
      android:exported="true"
      android:label="@string/app_name"
      android:launchMode="singleTop"
      android:theme="@style/KiwixTheme.Launcher"
      android:windowSoftInputMode="adjustPan">
      <meta-data
        android:name="android.app.shortcuts"
        android:resource="@xml/shortcuts" />

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.MONKEY" />
      </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.VIEW" />

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

        <data android:scheme="file" />
        <data android:mimeType="*/*" />
        <data android:pathPattern=".*\\.zim" />
        <data android:pathPattern=".*\\..*\\.zim" />
        <data android:pathPattern=".*\\..*\\..*\\.zim" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zim" />
        <data android:host="*" />
      </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:mimeType="*/*" />
        <data android:pathPattern=".*\\.zimaa" />
        <data android:pathPattern=".*\\..*\\.zimaa" />
        <data android:pathPattern=".*\\..*\\..*\\.zimaa" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zimaa" />
        <data android:host="*" />
      </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="http" />
        <data android:host="*" />
        <data android:pathPattern=".*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zim(aa|)" />
      </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="https" />
        <data android:host="*" />
        <data android:pathPattern=".*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zim(aa|)" />
      </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="content" />
        <data android:host="*" />
        <data android:pathPattern=".*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\.zim(aa|)" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zim(aa|)" />
      </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:host="search"
          android:scheme="kiwix" />
      </intent-filter>
      <intent-filter android:label="@string/app_search_string">
        <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="org.kiwix.kiwixmobile.core.main.CoreMainActivity" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    </activity>

    <service android:name=".webserver.wifi_hotspot.HotspotService" />

    <receiver
      android:name=".main.KiwixSearchWidget"
      android:exported="true">
      <meta-data
        android:name="android.appwidget.provider"
        android:resource="@xml/kiwix_widget_provider_info" />

      <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        <action android:name="KiwixSearchWidget.TEXT_CLICKED" />
        <action android:name="KiwixSearchWidget.ICON_CLICKED" />
        <action android:name="KiwixSearchWidget.MIC_CLICKED" />
        <action android:name="KiwixSearchWidget.STAR_CLICKED" />
      </intent-filter>
    </receiver>
  </application>
</manifest>
