<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="{{config.package}}"
          android:versionCode="{{config.numeric_version}}"
          android:versionName="{{config.version}}"
          android:installLocation="auto"
          >

  <application android:label="@string/appName"
               android:icon="@drawable/icon"
               android:allowBackup="true"
               android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
               android:hardwareAccelerated="true" >
               >

    <meta-data android:name="wakelock" android:value="1" />
    <meta-data android:name="surface.transparent" android:value="0" />
    <meta-data android:name="fullscreen" android:value="1" />

    <activity android:name="org.renpy.android.PythonSDLActivity"
              android:label="@string/iconName"
              android:launchMode="singleTop"
              android:screenOrientation="{{ config.orientation }}"
              android:configChanges="keyboardHidden|orientation|screenSize"
              >

{% if not config.expansion %}
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="tv.ouya.intent.category.GAME" />
        </intent-filter>
{% endif %}

    </activity>

{% if config.store == "amazon" or config.store == "all" %}
    <receiver android:name = "com.amazon.device.iap.ResponseReceiver" >
      <intent-filter>
        <action android:name = "com.amazon.inapp.purchasing.NOTIFY" android:permission = "com.amazon.inapp.purchasing.Permission.NOTIFY" />
      </intent-filter>
    </receiver>
{% endif %}

{% if config.expansion %}
       <activity
           android:label="@string/iconName"
           android:name="org.renpy.android.DownloaderActivity"
           android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
           <intent-filter >
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>

       <service android:name="org.renpy.android.DownloaderService" />
       <receiver android:name="org.renpy.android.DownloaderAlarmReceiver" />
{% endif %}
  </application>

  <uses-feature android:glEsVersion="0x00020000" android:required="true" />
  <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="{{ config.target_version }}"/>

  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

{% if config.expansion or config.store == "play" or config.store == "all" %}
  <uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
{% endif %}

{% if config.expansion %}
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
{% endif %}

{% if config.store == "play" or config.store == "all" %}
  <uses-permission android:name="com.android.vending.BILLING"/>
{% endif %}

  {% for perm in config.permissions %}
  <uses-permission android:name="android.permission.{{ perm }}" />
  {% endfor %}

{{ manifest_extra or '' }}
</manifest>
