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

  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

  <application
      android:name=".KiwixApplication"
      android:allowBackup="true"
      android:hardwareAccelerated="true"
      android:icon="@mipmap/kiwix_icon"
      android:label="@string/app_name"
      android:networkSecurityConfig="@xml/network_security_config"
      android:roundIcon="@mipmap/kiwix_icon_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">

    <activity
        android:name=".splash.SplashActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.Launcher">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
        <category android:name="android.intent.category.MONKEY"/>
      </intent-filter>

      <meta-data
          android:name="android.app.shortcuts"
          android:resource="@xml/shortcuts"/>
    </activity>
    <activity
        android:name=".main.MainActivity"
        android:configChanges="orientation|keyboardHidden|screenSize|locale"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustPan">
      <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>
    </activity>
    <activity
        android:name=".zim_manager.ZimManageActivity"
        android:label="@string/choose_file"
        android:launchMode="singleTop">
      <!-- TODO -->
      <intent-filter>
        <action android:name="android.intent.action.GET_CONTENT"/>

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

        <data android:mimeType="*/*"/>
      </intent-filter>
      <intent-filter>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.TEXT_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.ICON_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.MIC_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.STAR_CLICKED"/>
      </intent-filter>
    </activity>
    <activity android:name=".settings.KiwixSettingsActivity"/>
    <activity android:name=".search.SearchActivity"/>
    <activity android:name=".bookmark.BookmarksActivity"/>

    <provider
        android:name=".data.ZimContentProvider"
        android:authorities="${applicationId}.zim.base"
        android:exported="true"/>

    <receiver android:name=".main.KiwixSearchWidget">
      <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.TEXT_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.ICON_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.MIC_CLICKED"/>
        <action android:name="org.kiwix.kiwixmobile.utils.KiwixSearchWidget.STAR_CLICKED"/>
      </intent-filter>

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

    <activity
        android:name=".error.ErrorActivity"
        android:process=":error_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/provider_paths"/>
    </provider>


    <activity android:name=".intro.IntroActivity"/>
    <activity android:name=".language.LanguageActivity"/>
    <activity android:name=".history.HistoryActivity"/>
    <activity android:name=".help.HelpActivity">
      <meta-data
          android:name="android.support.PARENT_ACTIVITY"
          android:value="main.MainActivity"/>
    </activity>
    <activity android:name=".zim_manager.local_file_transfer.LocalFileTransferActivity"
        android:label="Send to nearby device"
        android:screenOrientation="portrait">
      <intent-filter>
        <action android:name="android.intent.action.SEND_MULTIPLE"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="application/octet-stream"/>
        <data android:pathPattern=".*\\.zim"/>
        <data android:pathPattern=".*\\..*\\.zim"/>
        <data android:pathPattern=".*\\..*\\..*\\.zim"/>
        <data android:pathPattern=".*\\..*\\..*\\..*\\.zim"/>
        <data android:host="*"/>
      </intent-filter>
    </activity>

    <receiver android:name=".zim_manager.DownloadNotificationClickedReceiver">
      <intent-filter>
        <action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"/>
      </intent-filter>
    </receiver>
  </application>
</manifest>
