<commit_before>#!/usr/bin/env python2.7
# Copyright 2013 oyatsukai.com

import sys
import os
import subprocess

############################################################

MANIFEST_1_ANDROIDLICENSE = ""

ANDROIDLICENSE_PERMISSIONS = ";com.android.vending.CHECK_LICENSE"

MANIFEST_1_ADMOB = """
        <!-- ADMOB BEGIN -->
        <activity android:name="com.google.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <!-- ADMOB END -->"""
ADMOB_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.ACCESS_NETWORK_STATE"

ZIRCONIA_PERMISSIONS = ";android.permission.READ_PHONE_STATE;" + \
    "android.permission.INTERNET"

MANIFEST_1_MOBIROO = """
        <!-- MOBIROO BEGIN -->
        <activity android:name="MobirooActivity"
                  android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- MOBIROO END -->"""

MOBIROO_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.READ_PHONE_STATE"           + \
    ";android.permission.ACCESS_WIFI_STATE"          + \
    ";android.permission.ACCESS_NETWORK_STATE"       + \
    ";android.permission.GET_TASKS"

MANIFEST_1_MMEDIA = """
        <!-- MMEDIA BEGIN -->
        <activity android:name="com.millennialmedia.android.MMActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:configChanges="keyboardHidden|orientation|keyboard" >
        </activity>
        <activity android:name="com.millennialmedia.android.VideoPlayer"
                  android:configChanges="keyboardHidden|orientation|keyboard" >
        </activity>
        <!-- MMEDIA END -->"""

MMEDIA_PERMISSIONS = ";android.permission.WRITE_EXTERNAL_STORAGE" + \
    ";android.permission.READ_PHONE_STATE"

MANIFEST_1_TAPIT = """
        <!-- TAPIT BEGIN -->
        <activity android:name="com.tapit.sdk.InAppWebView"/>
        <!-- TAPIT END -->"""

TAPIT_PERMISSIONS = ";android.permission.INTERNET" \
    ";android.permission.READ_PHONE_STATE"

MANIFEST_1_MEDIBA = """
        <!-- MEDIBA BEGIN -->
        <activity android:name="mediba.ad.sdk.android.openx.MasAdClickWebview" />
        <!-- MEDIBA END -->"""

MEDIBA_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.ACCESS_NETWORK_STATE"

MANIFEST_1_CHARTBOOST = """
        <!-- CHARTBOOST BEGIN -->
        <!-- (no longer requires an activity)
        <activity android:name="com.chartboost.sdk.CBDialogActivity"
                  android:configChanges="orientation|keyboard|keyboardHidden"
                  android:windowSoftInputMode="adjustResize"
                  android:theme="@android:style/Theme.Translucent"
                  android:launchMode="singleTop" >
        </activity>
        -->
        <!-- CHARTBOOST END -->"""

CHARTBOOST_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.WRITE_EXTERNAL_STORAGE" + \
    ";android.permission.ACCESS_NETWORK_STATE" + \
    ";android.permission.ACCESS_WIFI_STATE"

MANIFEST_1_TAPFORTAP = "defined in write_manifest"

# some of these are optional
TAPFORTAP_PERMISSIONS = ";android.permission.INTERNET" \
    + ";android.permission.WRITE_EXTERNAL_STORAGE" \
    + ";android.permission.ACCESS_NETWORK_STATE" \
    + ";android.permission.ACCESS_WIFI_STATE" \
 #   + ";android.permission.READ_PHONE_STATE"

MANIFEST_1_HEYZAP = """
        <!-- HEYZAP BEGIN -->
        <receiver android:name="com.heyzap.sdk.PackageAddedReceiver">
          <intent-filter>
            <data android:scheme="package" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
          </intent-filter>
        </receiver>
        <!-- HEYZAP END -->"""

HEYZAP_PERMISSIONS = ";android.permission.INTERNET" \
    + ";android.permission.ACCESS_NETWORK_STATE"

MANIFEST_1_OPENKIT = """
        <!-- OPENKIT BEGIN -->
        <activity
            android:name="io.openkit.OKLoginActivity"
            android:theme="@style/Theme.Transparent" />
        <activity android:name="io.openkit.leaderboards.OKLeaderboardsActivity" />
        <activity android:name="io.openkit.leaderboards.OKScoresActivity" />
        <activity android:name="io.openkit.user.OKUserProfileActivity" />
        <activity android:name="io.openkit.facebook.LoginActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <!-- OPENKIT END -->"""

OPENKIT_PERMISSIONS = ";android.permission.INTERNET"

MANIFEST_1_FACEBOOK = """
        <!-- FACEBOOK BEGIN -->
        <activity android:name="com.facebook.LoginActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <!-- FACEBOOK END -->"""

FACEBOOK_PERMISSIONS = ";android.permission.INTERNET"

MANIFEST_1_AMAZON_BILLING = """
        <!-- AMAZON BILLING BEGIN -->
        <receiver android:name = "com.amazon.inapp.purchasing.ResponseReceiver" >
         <intent-filter>
          <action
           android:name="com.amazon.inapp.purchasing.NOTIFY"
           android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
         </intent-filter>
        </receiver>
        <!-- AMAZON BILLING END -->"""

AMAZON_BILLING_PERMISSIONS = ""

MANIFEST_1_APPAYABLE = """
        <!-- APPAYABLE BEGIN -->
        <service android:name="org.OpenUDID.OpenUDID_service">
         <intent-filter>
          <action android:name="org.OpenUDID.GETUDID" />
         </intent-filter>
        </service>
        <!-- APPAYABLE END -->"""

APPAYABLE_PERMISSIONS = ""

#
#
#
def _verbose(msg):
    print "%s" % msg
def _silent(msg):
    pass
verbose = _silent
wrote = False

#
#
#
def mkdir_if_not_exists(path):
    if not os.path.exists(path):
        os.mkdir(path)

#
#
#
def replace_tags(in_string, table):
    for tag in table:
        verbose("Replacing %s with %s" % (tag, table[tag]))
        in_string = in_string.replace(tag, "%s" % table[tag])
    return in_string

#
#
#
def write_file_if_different(filename, data):
    if os.path.exists(filename):
        f = open(filename, 'rb')
        old_data = f.read()
        f.close()
        if old_data == data:
            print "File '%s' has not changed.  Not writing" \
                % os.path.basename(filename)
            return

    with open(filename, 'wb') as f:
        f.write(data)

    global wrote
    wrote = True

#
#
#
def copy_file_if_different(src, target):
    with open(src, 'rb') as in_f:
        data = in_f.read()
    write_file_if_different(target, data)

#
#
#
def write_manifest(dest, table, permissions, intent_filters, meta,
                   extras, library, resource_strings, options):

    MANIFEST_1_TAPFORTAP = """
        <!-- TAPFORTAP BEGIN -->
        <activity android:name="com.tapfortap.TapForTapActivity" """
    if options['landscape']:
        MANIFEST_1_TAPFORTAP += """
                  android:screenOrientation="landscape"
                  android:configChanges="orientation" """
    MANIFEST_1_TAPFORTAP += """/>
        <!-- TAPFORTAP END -->"""

    # Create res dir if it doesn't exist

    res_dir = os.path.join(dest, 'res')
    mkdir_if_not_exists(res_dir)

    # [ MANIFEST_FRAGMENT, <permissions>, <override main activity> ]

    extras_table = {
        'androidlicense':
        [ MANIFEST_1_ANDROIDLICENSE, ANDROIDLICENSE_PERMISSIONS, False ],
        'admob'      : [ MANIFEST_1_ADMOB, ADMOB_PERMISSIONS, False ],
        'zirconia'   : [ "", ZIRCONIA_PERMISSIONS, False ],
        'mobiroo'    : [ MANIFEST_1_MOBIROO, MOBIROO_PERMISSIONS, True ],
        'mmedia'     : [ MANIFEST_1_MMEDIA, MMEDIA_PERMISSIONS, False ],
        'tapit'      : [ MANIFEST_1_TAPIT, TAPIT_PERMISSIONS, False ],
        'mediba'     : [ MANIFEST_1_MEDIBA, MEDIBA_PERMISSIONS, False ],
        'chartboost' : [ MANIFEST_1_CHARTBOOST, CHARTBOOST_PERMISSIONS, False ],
        'tapfortap'  : [ MANIFEST_1_TAPFORTAP, TAPFORTAP_PERMISSIONS, False ],
        'heyzap'     : [ MANIFEST_1_HEYZAP, HEYZAP_PERMISSIONS, False ],
        'openkit'    : [ MANIFEST_1_OPENKIT, OPENKIT_PERMISSIONS, False ],
        'facebook'   : [ MANIFEST_1_FACEBOOK, FACEBOOK_PERMISSIONS, False ],
        'amazon-billing':
        [ MANIFEST_1_AMAZON_BILLING, AMAZON_BILLING_PERMISSIONS, False ],
        'appayable'  : [ MANIFEST_1_APPAYABLE, APPAYABLE_PERMISSIONS, False ]
        }

    # icon

    icon_attr = 'android:icon="@drawable/icon"'
    if not table['%ICON_DIR%']:
        icon_attr = ''
    table['%ICON_ATTR%'] = icon_attr

    # Start writing

    output = os.path.join(dest, 'AndroidManifest.xml')

    data = ""

    # Header

    ########################################
    # LIBRARY
    ########################################

    if library:
        MANIFEST_LIBRARY_0 = """<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="%PACKAGE_NAME%"
      android:versionCode="%VERSION_INT%"
      android:versionName="%VERSION_DOT_4%">
    <application android:label="API">
    </application>
    <uses-sdk android:minSdkVersion="%ANDROID_SDK_VERSION%" />
</manifest>"""

        data += replace_tags(MANIFEST_LIBRARY_0, table)
        write_file_if_different(output, data)
        return

    ########################################
    # APPLICATION
    ########################################

    # Write res/values

    res_values_dir = os.path.join(res_dir, 'values')

    mkdir_if_not_exists(res_values_dir)
    for x in [ 'ldpi', 'mdpi', 'hdpi' ]:
        mkdir_if_not_exists(os.path.join(res_dir, 'drawable-%s' % x))
    res_values_strings = os.path.join(res_values_dir, 'strings.xml')

    res_values_strings_data = \
        replace_tags("""<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">%APP_TITLE%</string>""", table)
    for k, v in resource_strings.iteritems():
        res_values_strings_data += '\n    <string name="%s">%s</string>' \
            % (k, v)
    res_values_strings_data += """
</resources>
"""

    write_file_if_different(res_values_strings, res_values_strings_data)

    # Override main activity?

    override_main_activity = False
    for e in extras:
        override_main_activity = override_main_activity or extras_table[e][2]

    # Write manifest

    MANIFEST_0 = """<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="%PACKAGE_NAME%"
      android:versionCode="%VERSION_INT%"
      android:versionName="%VERSION_DOT_4%"
      android:installLocation="auto">
    <application android:label="@string/app_name" %ICON_ATTR%"""

    if options['backup_agent']:
        class_key = options['backup_agent'].split(',')
        MANIFEST_0 += """
                 android:backupAgent=""" + '"%s"' % class_key[0]
        MANIFEST_0 += """>
        <meta-data android:name="com.google.android.backup.api_key"
                   android:value=""" + '"%s" />' % class_key[1]
    else:
        MANIFEST_0 += ">"

    MANIFEST_0 += """
        <activity android:name="%ACTIVITY_NAME%"
                  android:label="%APP_TITLE%"
                  android:launchMode="singleTask" """

    if options['landscape']:
        MANIFEST_0 += """
                  android:screenOrientation="landscape"
                  android:configChanges="orientation" """<commit_msg>Send screenSize config changes to android activity, rather than letting the OS handle them<commit_after>#!/usr/bin/env python2.7
# Copyright 2013 <EMAIL>

import sys
import os
import subprocess

############################################################

MANIFEST_1_ANDROIDLICENSE = ""

ANDROIDLICENSE_PERMISSIONS = ";com.android.vending.CHECK_LICENSE"

MANIFEST_1_ADMOB = """
        <!-- ADMOB BEGIN -->
        <activity android:name="com.google.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <!-- ADMOB END -->"""
ADMOB_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.ACCESS_NETWORK_STATE"

ZIRCONIA_PERMISSIONS = ";android.permission.READ_PHONE_STATE;" + \
    "android.permission.INTERNET"

MANIFEST_1_MOBIROO = """
        <!-- MOBIROO BEGIN -->
        <activity android:name="MobirooActivity"
                  android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- MOBIROO END -->"""

MOBIROO_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.READ_PHONE_STATE"           + \
    ";android.permission.ACCESS_WIFI_STATE"          + \
    ";android.permission.ACCESS_NETWORK_STATE"       + \
    ";android.permission.GET_TASKS"

MANIFEST_1_MMEDIA = """
        <!-- MMEDIA BEGIN -->
        <activity android:name="com.millennialmedia.android.MMActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:configChanges="keyboardHidden|orientation|keyboard" >
        </activity>
        <activity android:name="com.millennialmedia.android.VideoPlayer"
                  android:configChanges="keyboardHidden|orientation|keyboard" >
        </activity>
        <!-- MMEDIA END -->"""

MMEDIA_PERMISSIONS = ";android.permission.WRITE_EXTERNAL_STORAGE" + \
    ";android.permission.READ_PHONE_STATE"

MANIFEST_1_TAPIT = """
        <!-- TAPIT BEGIN -->
        <activity android:name="com.tapit.sdk.InAppWebView"/>
        <!-- TAPIT END -->"""

TAPIT_PERMISSIONS = ";android.permission.INTERNET" \
    ";android.permission.READ_PHONE_STATE"

MANIFEST_1_MEDIBA = """
        <!-- MEDIBA BEGIN -->
        <activity android:name="mediba.ad.sdk.android.openx.MasAdClickWebview" />
        <!-- MEDIBA END -->"""

MEDIBA_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.ACCESS_NETWORK_STATE"

MANIFEST_1_CHARTBOOST = """
        <!-- CHARTBOOST BEGIN -->
        <!-- (no longer requires an activity)
        <activity android:name="com.chartboost.sdk.CBDialogActivity"
                  android:configChanges="orientation|keyboard|keyboardHidden"
                  android:windowSoftInputMode="adjustResize"
                  android:theme="@android:style/Theme.Translucent"
                  android:launchMode="singleTop" >
        </activity>
        -->
        <!-- CHARTBOOST END -->"""

CHARTBOOST_PERMISSIONS = ";android.permission.INTERNET" + \
    ";android.permission.WRITE_EXTERNAL_STORAGE" + \
    ";android.permission.ACCESS_NETWORK_STATE" + \
    ";android.permission.ACCESS_WIFI_STATE"

MANIFEST_1_TAPFORTAP = "defined in write_manifest"

# some of these are optional
TAPFORTAP_PERMISSIONS = ";android.permission.INTERNET" \
    + ";android.permission.WRITE_EXTERNAL_STORAGE" \
    + ";android.permission.ACCESS_NETWORK_STATE" \
    + ";android.permission.ACCESS_WIFI_STATE" \
 #   + ";android.permission.READ_PHONE_STATE"

MANIFEST_1_HEYZAP = """
        <!-- HEYZAP BEGIN -->
        <receiver android:name="com.heyzap.sdk.PackageAddedReceiver">
          <intent-filter>
            <data android:scheme="package" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
          </intent-filter>
        </receiver>
        <!-- HEYZAP END -->"""

HEYZAP_PERMISSIONS = ";android.permission.INTERNET" \
    + ";android.permission.ACCESS_NETWORK_STATE"

MANIFEST_1_OPENKIT = """
        <!-- OPENKIT BEGIN -->
        <activity
            android:name="io.openkit.OKLoginActivity"
            android:theme="@style/Theme.Transparent" />
        <activity android:name="io.openkit.leaderboards.OKLeaderboardsActivity" />
        <activity android:name="io.openkit.leaderboards.OKScoresActivity" />
        <activity android:name="io.openkit.user.OKUserProfileActivity" />
        <activity android:name="io.openkit.facebook.LoginActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <!-- OPENKIT END -->"""

OPENKIT_PERMISSIONS = ";android.permission.INTERNET"

MANIFEST_1_FACEBOOK = """
        <!-- FACEBOOK BEGIN -->
        <activity android:name="com.facebook.LoginActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <!-- FACEBOOK END -->"""

FACEBOOK_PERMISSIONS = ";android.permission.INTERNET"

MANIFEST_1_AMAZON_BILLING = """
        <!-- AMAZON BILLING BEGIN -->
        <receiver android:name = "com.amazon.inapp.purchasing.ResponseReceiver" >
         <intent-filter>
          <action
           android:name="com.amazon.inapp.purchasing.NOTIFY"
           android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
         </intent-filter>
        </receiver>
        <!-- AMAZON BILLING END -->"""

AMAZON_BILLING_PERMISSIONS = ""

MANIFEST_1_APPAYABLE = """
        <!-- APPAYABLE BEGIN -->
        <service android:name="org.OpenUDID.OpenUDID_service">
         <intent-filter>
          <action android:name="org.OpenUDID.GETUDID" />
         </intent-filter>
        </service>
        <!-- APPAYABLE END -->"""

APPAYABLE_PERMISSIONS = ""

#
#
#
def _verbose(msg):
    print "%s" % msg
def _silent(msg):
    pass
verbose = _silent
wrote = False

#
#
#
def mkdir_if_not_exists(path):
    if not os.path.exists(path):
        os.mkdir(path)

#
#
#
def replace_tags(in_string, table):
    for tag in table:
        verbose("Replacing %s with %s" % (tag, table[tag]))
        in_string = in_string.replace(tag, "%s" % table[tag])
    return in_string

#
#
#
def write_file_if_different(filename, data):
    if os.path.exists(filename):
        f = open(filename, 'rb')
        old_data = f.read()
        f.close()
        if old_data == data:
            print "File '%s' has not changed.  Not writing" \
                % os.path.basename(filename)
            return

    with open(filename, 'wb') as f:
        f.write(data)

    global wrote
    wrote = True

#
#
#
def copy_file_if_different(src, target):
    with open(src, 'rb') as in_f:
        data = in_f.read()
    write_file_if_different(target, data)

#
#
#
def write_manifest(dest, table, permissions, intent_filters, meta,
                   extras, library, resource_strings, options):

    MANIFEST_1_TAPFORTAP = """
        <!-- TAPFORTAP BEGIN -->
        <activity android:name="com.tapfortap.TapForTapActivity" """
    if options['landscape']:
        MANIFEST_1_TAPFORTAP += """
                  android:screenOrientation="landscape"
                  android:configChanges="orientation" """
    MANIFEST_1_TAPFORTAP += """/>
        <!-- TAPFORTAP END -->"""

    # Create res dir if it doesn't exist

    res_dir = os.path.join(dest, 'res')
    mkdir_if_not_exists(res_dir)

    # [ MANIFEST_FRAGMENT, <permissions>, <override main activity> ]

    extras_table = {
        'androidlicense':
        [ MANIFEST_1_ANDROIDLICENSE, ANDROIDLICENSE_PERMISSIONS, False ],
        'admob'      : [ MANIFEST_1_ADMOB, ADMOB_PERMISSIONS, False ],
        'zirconia'   : [ "", ZIRCONIA_PERMISSIONS, False ],
        'mobiroo'    : [ MANIFEST_1_MOBIROO, MOBIROO_PERMISSIONS, True ],
        'mmedia'     : [ MANIFEST_1_MMEDIA, MMEDIA_PERMISSIONS, False ],
        'tapit'      : [ MANIFEST_1_TAPIT, TAPIT_PERMISSIONS, False ],
        'mediba'     : [ MANIFEST_1_MEDIBA, MEDIBA_PERMISSIONS, False ],
        'chartboost' : [ MANIFEST_1_CHARTBOOST, CHARTBOOST_PERMISSIONS, False ],
        'tapfortap'  : [ MANIFEST_1_TAPFORTAP, TAPFORTAP_PERMISSIONS, False ],
        'heyzap'     : [ MANIFEST_1_HEYZAP, HEYZAP_PERMISSIONS, False ],
        'openkit'    : [ MANIFEST_1_OPENKIT, OPENKIT_PERMISSIONS, False ],
        'facebook'   : [ MANIFEST_1_FACEBOOK, FACEBOOK_PERMISSIONS, False ],
        'amazon-billing':
        [ MANIFEST_1_AMAZON_BILLING, AMAZON_BILLING_PERMISSIONS, False ],
        'appayable'  : [ MANIFEST_1_APPAYABLE, APPAYABLE_PERMISSIONS, False ]
        }

    # icon

    icon_attr = 'android:icon="@drawable/icon"'
    if not table['%ICON_DIR%']:
        icon_attr = ''
    table['%ICON_ATTR%'] = icon_attr

    # Start writing

    output = os.path.join(dest, 'AndroidManifest.xml')

    data = ""

    # Header

    ########################################
    # LIBRARY
    ########################################

    if library:
        MANIFEST_LIBRARY_0 = """<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="%PACKAGE_NAME%"
      android:versionCode="%VERSION_INT%"
      android:versionName="%VERSION_DOT_4%">
    <application android:label="API">
    </application>
    <uses-sdk android:minSdkVersion="%ANDROID_SDK_VERSION%" />
</manifest>"""

        data += replace_tags(MANIFEST_LIBRARY_0, table)
        write_file_if_different(output, data)
        return

    ########################################
    # APPLICATION
    ########################################

    # Write res/values

    res_values_dir = os.path.join(res_dir, 'values')

    mkdir_if_not_exists(res_values_dir)
    for x in [ 'ldpi', 'mdpi', 'hdpi' ]:
        mkdir_if_not_exists(os.path.join(res_dir, 'drawable-%s' % x))
    res_values_strings = os.path.join(res_values_dir, 'strings.xml')

    res_values_strings_data = \
        replace_tags("""<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">%APP_TITLE%</string>""", table)
    for k, v in resource_strings.iteritems():
        res_values_strings_data += '\n    <string name="%s">%s</string>' \
            % (k, v)
    res_values_strings_data += """
</resources>
"""

    write_file_if_different(res_values_strings, res_values_strings_data)

    # Override main activity?

    override_main_activity = False
    for e in extras:
        override_main_activity = override_main_activity or extras_table[e][2]

    # Write manifest

    MANIFEST_0 = """<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="%PACKAGE_NAME%"
      android:versionCode="%VERSION_INT%"
      android:versionName="%VERSION_DOT_4%"
      android:installLocation="auto">
    <application android:label="@string/app_name" %ICON_ATTR%"""

    if options['backup_agent']:
        class_key = options['backup_agent'].split(',')
        MANIFEST_0 += """
                 android:backupAgent=""" + '"%s"' % class_key[0]
        MANIFEST_0 += """>
        <meta-data android:name="com.google.android.backup.api_key"
                   android:value=""" + '"%s" />' % class_key[1]
    else:
        MANIFEST_0 += ">"

    MANIFEST_0 += """
        <activity android:name="%ACTIVITY_NAME%"
                  android:label="%APP_TITLE%"
                  android:launchMode="singleTask" """

    if options['landscape']:
        MANIFEST_0 += """
                  android:screenOrientation="landscape"
                  android:configChanges="orientation|screenSize" """
{'fraction_non_alphanumeric': 0.15558886509635975, 'fraction_numerical': 0.004882226980728052, 'mean_word_length': 2.9081171548117153, 'pattern_counts': {'":': 0, '<': 174, '<?xml version=': 6, '>': 174, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6865472', 'n_tokens_mistral': 7856, 'n_tokens_neox': 7439, 'n_words': 1047}