<?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.sufficientlysecure.keychain"
    android:installLocation="auto">

    <!--
        General remarks
        ===============
        - Last APG 1 version was 10900 (1.0.9 beta 00)
        - Keychain starting with versionCode 20000!
        
        Association of file types to Keychain
        =====================================
        General remarks about file ending conventions:
        - *.gpg,*.pgp for binary files
        - *.asc for ascii armored files The actual content can be anything.
        
        The file ending only shows if it is binary or ascii encoded.
        
        Remarks about the ugly android:pathPattern:
        - We are matching all files with a specific file ending.
        This is done in an ugly way because of Android limitations.
        Read http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension
        and http://stackoverflow.com/questions/3400072/pathpattern-to-match-file-extension-does-not-work-if-a-period-exists-elsewhere-i/8599921
        for more information.
        - Do _not_ set mimeType for gpg!
        Cyanogenmod's file manager will only show Keychain for gpg files if no mimeType is set!
        For OI Filemanager it makes no difference, gpg files can't be associated
    -->

    <!-- SDK levels are specified in build.gradle -->

    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <!-- SafeSlinger uses orientation=portrait, but we do not want to make it a requirement -->
    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="false" />

    <permission android:name="${applicationId}.WRITE_TEMPORARY_STORAGE" />

    <uses-permission android:name="${applicationId}.WRITE_TEMPORARY_STORAGE" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.WRITE_PROFILE" />

    <!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
    <application
        android:name=".KeychainApplication"
        android:allowBackup="false"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/KeychainTheme">
        <activity
            android:name=".ui.MainActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/app_name"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.CreateKeyActivity"
            android:allowTaskReparenting="true"
            android:label="@string/title_manage_my_keys"
            android:launchMode="singleTop"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="adjustResize">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".ui.EditKeyActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_edit_key" />
        <!-- NOTE: Dont use configChanges for QR Code view! We use a different layout for landscape -->
        <activity
            android:name=".ui.QrCodeViewActivity"
            android:label="@string/share_qr_code_dialog_title" />
        <activity
            android:name=".ui.ViewKeyActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_key_details"
            android:parentActivityName=".ui.MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.ViewCertActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_view_cert"
            android:parentActivityName=".ui.ViewKeyActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.ViewKeyActivity" />
        </activity>
        <activity
            android:name=".ui.SafeSlingerActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_exchange_keys"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".ui.EncryptFilesActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_encrypt_files"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />

            <!-- ENCRYPT_DATA with data Uri -->
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.action.ENCRYPT_DATA" />

                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
            <!-- Android's Send Action -->
            <intent-filter android:label="@string/intent_send_encrypt">
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />

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

                <!-- everything except text/* and message/* -->
                <data android:mimeType="image/*" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="video/*" />
                <data android:mimeType="application/*" />
                <data android:mimeType="multipart/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.EncryptTextActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_encrypt_text"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />

            <!-- ENCRYPT_TEXT with text as extra -->
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.action.ENCRYPT_TEXT" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- Android's Send Action -->
            <intent-filter android:label="@string/intent_send_encrypt">
                <action android:name="android.intent.action.SEND" />

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

                <data android:mimeType="text/*" />
                <data android:mimeType="message/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.DecryptTextActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_decrypt"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />

            <!-- DECRYPT_TEXT with text as extra -->
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.action.DECRYPT_TEXT" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- Android's Send Action -->
            <intent-filter android:label="@string/intent_send_decrypt">
                <action android:name="android.intent.action.SEND" />

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

                <data android:mimeType="text/*" />
                <data android:mimeType="message/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.DecryptFilesActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_decrypt"
            android:parentActivityName=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />

            <!-- VIEW with mimeTypes  -->
            <intent-filter android:label="@string/intent_send_decrypt">
                <action android:name="android.intent.action.VIEW" />

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

                <!-- preferred MIME type for encrypted data (non-standard right now) -->
                <data android:mimeType="application/pgp-message" />

                <!--
                  MIME type as defined in http://tools.ietf.org/html/rfc3156, but too generic
                  NOTE: application/pgp-encrypted is not registered here, because it does not contain the actual data
                        application/pgp-signature is not registered here, it only contains a detached signature, which is useless without the message
                -->
                <data android:mimeType="application/octet-stream" />

                <!-- non-standard MIME types found in the wild -->
                <data android:mimeType="application/pgp" />
                <data android:mimeType="text/pgp" />

                <!--
                  This links to attached asc files in AOSP mail. It is deactivated because of
                  https://github.com/open-keychain/open-keychain/issues/290
                -->
                <!--<data android:mimeType="text/plain" />-->
            </intent-filter>
            <!-- DECRYPT_DATA with data Uri -->
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.action.DECRYPT_DATA" />

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

                <data android:scheme="file" />
                <data android:scheme="content" />
            </intent-filter>
            <!-- Android's Send Action -->
            <intent-filter android:label="@string/intent_send_decrypt">
                <action android:name="android.intent.action.SEND" />

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

                <!-- everything except text/* and message/* -->
                <data android:mimeType="image/*" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="video/*" />
                <data android:mimeType="application/*" />
                <data android:mimeType="multipart/*" />
            </intent-filter>
            <!-- Linking "Decrypt" to file types -->
            <intent-filter android:label="@string/intent_decrypt_file">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:host="*" />
                <data android:scheme="file" />
                <data android:scheme="content" />

                <!-- ASCII data, mostly keys, but sometimes signatures and encrypted data -->
                <data android:pathPattern=".*\\.asc" />
                <data android:pathPattern=".*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <!-- GnuPG binary encrypted/signed data, binary format -->
                <data android:pathPattern=".*\\.gpg" />
                <data android:pathPattern=".*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <!-- PGP encrypted data, binary format -->
                <data android:pathPattern=".*\\.pgp" />
                <data android:pathPattern=".*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <!-- on some mail clients, PGP attachments show up as *.bin -->
                <data android:pathPattern=".*\\.bin" />
                <data android:pathPattern=".*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
            </intent-filter>
            <!--
                Some apps will only respect these file associations
                if the mimeType is not set, and other apps will only respect them if mimeType is set
                to */*. Therefore we have two whole copies of the same thing, besides setting the mimeType.
            -->
            <intent-filter android:label="@string/intent_decrypt_file">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:host="*" />
                <data android:scheme="file" />
                <data android:scheme="content" />

                <data android:mimeType="*/*" />

                <!-- ASCII data, mostly keys, but sometimes signatures and encrypted data -->
                <data android:pathPattern=".*\\.asc" />
                <data android:pathPattern=".*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <!-- GnuPG binary encrypted/signed data, binary format -->
                <data android:pathPattern=".*\\.gpg" />
                <data android:pathPattern=".*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <!-- PGP encrypted data, binary format -->
                <data android:pathPattern=".*\\.pgp" />
                <data android:pathPattern=".*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <!-- on some mail clients, PGP attachments show up as *.bin -->
                <data android:pathPattern=".*\\.bin" />
                <data android:pathPattern=".*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.UploadKeyActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_send_key"
            android:parentActivityName=".ui.ViewKeyActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.ViewKeyActivity" />
        </activity>
        <activity
            android:name=".ui.ViewKeyAdvActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_advanced_key_info" />
        <activity
            android:name=".ui.SettingsActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_preferences">
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.ui.PREFS_GEN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.ui.PREFS_ADV" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.SettingsKeyServerActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_key_server_preference"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ui.CertifyKeyActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_certify_key">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".ui.CertifyFingerprintActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_certify_key">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".ui.ImportKeysProxyActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoDisplay"
            android:windowSoftInputMode="stateHidden">

            <!-- VIEW with fingerprint scheme:
                      Handle URIs with fingerprints when scanning directly from Barcode Scanner -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="android.intent.action.VIEW" />

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

                <!-- Android's scheme matcher is case-sensitive, so include most likely variations -->
                <data android:scheme="openpgp4fpr" />
                <data android:scheme="OPENPGP4FPR" />
                <data android:scheme="OpenPGP4FPR" />
                <data android:scheme="OpenPGP4Fpr" />
                <data android:scheme="OpenPGP4fpr" />
            </intent-filter>
            <!-- IMPORT_KEY without mimeType to allow import with extras Bundle -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_QR_CODE" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- NFC: Handle NFC tags detected from outside our application -->
            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED" />

                <category android:name="android.intent.category.DEFAULT" />
                <!-- MIME type as defined in http://tools.ietf.org/html/rfc3156 -->
                <data android:mimeType="application/pgp-keys" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.ImportKeysActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_import_keys"
            android:launchMode="singleTop">

            <!-- VIEW with mimeType: Allows to import keys (attached to emails) from email apps  -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="android.intent.action.VIEW" />

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

                <!-- preferred MIME type as defined in http://tools.ietf.org/html/rfc3156 -->
                <data android:mimeType="application/pgp-keys" />

                <!--
                  also link to text/plain, AOSP mail and K-9 mail only give mimeType text/plain
                  when the key file has been manually attached
                -->
                <data android:mimeType="text/plain" />
            </intent-filter>
            <!-- VIEW with file endings: *.gpg (e.g. to import from OI File Manager) -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:host="*" />
                <data android:scheme="file" />
                <data android:scheme="content" />

                <!-- ASCII data, mostly keys, but sometimes signatures and encrypted data -->
                <data android:pathPattern=".*\\.asc" />
                <data android:pathPattern=".*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <!-- GnuPG binary encrypted/signed data, binary format -->
                <data android:pathPattern=".*\\.gpg" />
                <data android:pathPattern=".*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <!-- PGP encrypted data, binary format -->
                <data android:pathPattern=".*\\.pgp" />
                <data android:pathPattern=".*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <!-- on some mail clients, PGP attachments show up as *.bin -->
                <data android:pathPattern=".*\\.bin" />
                <data android:pathPattern=".*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
            </intent-filter>
            <!--
                Some apps will only respect these file associations
                if the mimeType is not set, and other apps will only respect them if mimeType is set
                to */*. Therefore we have two whole copies of the same thing, besides setting the mimeType.
            -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:host="*" />
                <data android:scheme="file" />
                <data android:scheme="content" />

                <data android:mimeType="*/*" />

                <!-- ASCII data, mostly keys, but sometimes signatures and encrypted data -->
                <data android:pathPattern=".*\\.asc" />
                <data android:pathPattern=".*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.asc" />
                <!-- GnuPG binary encrypted/signed data, binary format -->
                <data android:pathPattern=".*\\.gpg" />
                <data android:pathPattern=".*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
                <!-- PGP encrypted data, binary format -->
                <data android:pathPattern=".*\\.pgp" />
                <data android:pathPattern=".*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pgp" />
                <!-- on some mail clients, PGP attachments show up as *.bin -->
                <data android:pathPattern=".*\\.bin" />
                <data android:pathPattern=".*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.bin" />
            </intent-filter>

            <!-- VIEW from keyserver urls opened in a browser -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="android.intent.action.VIEW" />

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

                <data android:scheme="https" />
                <data android:scheme="http" />
                <!-- if we don't specify a host, pathPattern will be ignored-->
                <data android:host="*" />
                <!-- convention for keyserver paths specified by internet draft
                 draft-shaw-openpgp-hkp-00.txt
                 (http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-3) -->
                <data android:pathPattern="/pks/lookup.*" />
            </intent-filter>

            <!-- IMPORT_KEY with files TODO: does this work? -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="org.sufficientlysecure.keychain.action.IMPORT_KEY" />

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

                <data android:mimeType="*/*" />
            </intent-filter>
            <!-- IMPORT_KEY with mimeType 'application/pgp-keys' -->
            <intent-filter>
                <action android:name="org.sufficientlysecure.keychain.action.IMPORT_KEY" />

                <category android:name="android.intent.category.DEFAULT" />
                <!-- MIME type as defined in http://tools.ietf.org/html/rfc3156, section 7 -->
                <data android:mimeType="application/pgp-keys" />
            </intent-filter>
            <!-- IMPORT_KEY without mimeType to allow import with extras Bundle -->
            <intent-filter android:label="@string/intent_import_key">
                <action android:name="org.sufficientlysecure.keychain.action.IMPORT_KEY" />
                <action android:name="org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_KEYSERVER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".ui.LogDisplayActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:label="@string/title_log_display" />
        <activity
            android:name=".ui.ConsolidateDialogActivity"
            android:theme="@android:style/Theme.NoDisplay" />
        <activity
            android:name=".ui.PassphraseDialogActivity"
            android:theme="@android:style/Theme.NoDisplay" />
        <activity android:name=".ui.PassphraseWizardActivity" />
        <!--
        NOTE: singleTop is set to get NFC foreground dispatch to work.
              Then, all NFC intents will be broadcasted to onNewIntent() of this activity!
              If more than one task stack of OpenKeychain exists, the broadcast
              restarts the activity with onCreate() instead of calling onNewIntent().
              taskAffinity and allowTaskReparenting somehow prevents this from happening!
         -->
        <activity
            android:name=".ui.NfcOperationActivity"
            android:allowTaskReparenting="true"
            android:launchMode="singleTop"
            android:taskAffinity=":Nfc" />

        <!--<activity-->
        <!--android:name=".ui.NfcIntentActivity"-->
        <!--android:launchMode="singleTop">-->
        <!--<intent-filter>-->
        <!--<action android:name="android.nfc.action.NDEF_DISCOVERED" />-->

        <!--<category android:name="android.intent.category.DEFAULT" />-->
        <!--<data android:host="my.yubico.com" android:scheme="https"/>-->
        <!--</intent-filter>-->
        <!--</activity>-->

        <activity
            android:name=".ui.HelpActivity"
            android:label="@string/title_help" />

        <!-- Internal services/content providers (not exported) -->
        <service
            android:name=".service.PassphraseCacheService"
            android:exported="false"
            android:process=":passphrase_cache" />
        <service
            android:name=".remote.CryptoInputParcelCacheService"
            android:exported="false"
            android:process=":remote_api" />
        <service
            android:name=".service.KeychainNewService"
            android:exported="false" />
        <service
            android:name=".service.KeychainService"
            android:exported="false" />

        <provider
            android:name=".provider.KeychainProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false" />

        <!-- Internal classes of the remote APIs (not exported) -->
        <activity
            android:name=".remote.ui.RemoteServiceActivity"
            android:exported="false"
            android:label="@string/app_name"
            android:launchMode="singleTop" />
        <activity
            android:name=".remote.ui.SelectSignKeyIdActivity"
            android:exported="false"
            android:label="@string/app_name"
            android:launchMode="singleTop" />
        <activity
            android:name=".remote.ui.SelectAllowedKeysActivity"
            android:exported="false"
            android:label="@string/app_name"
            android:launchMode="singleTop" />
        <activity
            android:name=".remote.ui.AppSettingsActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:exported="false">

            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.MainActivity" />
        </activity>
        <activity
            android:name=".remote.ui.AccountSettingsActivity"
            android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
            android:exported="false" />

        <!-- OpenPGP Remote API, this service has explicitly no permission requirements
             because we are using our own package based allow/disallow system -->
        <service
            android:name=".remote.OpenPgpService"
            android:enabled="true"
            android:exported="true"
            android:process=":remote_api"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="org.openintents.openpgp.IOpenPgpService" />
            </intent-filter>
        </service>

        <!-- Contact Sync services -->
        <service
            android:name=".service.DummyAccountService"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>
            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/account_desc" />
        </service>

        <service
            android:name=".service.ContactSyncAdapterService"
            android:exported="true"
            android:process=":sync"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_adapter_desc" />
            <meta-data
                android:name="android.provider.CONTACTS_STRUCTURE"
                android:resource="@xml/custom_pgp_contacts_structure" />
        </service>

        <!-- Storage Provider for temporary decrypted files -->
        <provider
            android:name=".provider.TemporaryStorageProvider"
            android:authorities="${applicationId}.tempstorage"
            android:exported="true"
            android:writePermission="${applicationId}.WRITE_TEMPORARY_STORAGE" />

    </application>

</manifest>
