mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
More file association hacks for AndroidManifest and key import
This commit is contained in:
parent
927b120275
commit
1d2c93ca8a
@ -31,7 +31,7 @@
|
||||
For OI Filemanager it makes no difference, gpg files can't be associated
|
||||
-->
|
||||
|
||||
<!-- Specified in buid.gradle -->
|
||||
<!-- Specified in build.gradle -->
|
||||
<!--<uses-sdk-->
|
||||
<!--android:minSdkVersion="9"-->
|
||||
<!--android:targetSdkVersion="19" />-->
|
||||
@ -223,28 +223,8 @@
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
<data android:scheme="content" />
|
||||
<!-- Workaround to match files in pathes with dots in them, like /cdcard/my.folder/test.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" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.gpg" />
|
||||
</intent-filter>
|
||||
<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="*/*" />
|
||||
<!-- GnuPG ASCII data, mostly keys, but sometimes signatures and encrypted data -->
|
||||
<data android:pathPattern=".*\\.asc" />
|
||||
<data android:pathPattern=".*\\..*\\.asc" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.asc" />
|
||||
@ -255,6 +235,101 @@
|
||||
<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="*/*" />
|
||||
|
||||
<!-- GnuPG 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
|
||||
@ -324,6 +399,9 @@
|
||||
|
||||
<!-- 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>
|
||||
<!-- NFC: Handle NFC tags detected from outside our application -->
|
||||
<intent-filter>
|
||||
@ -343,28 +421,8 @@
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
<data android:scheme="content" />
|
||||
<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" />
|
||||
</intent-filter>
|
||||
<!-- VIEW with file endings: *.asc -->
|
||||
<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="*/*" />
|
||||
<!-- GnuPG ASCII data, mostly keys, but sometimes signatures and encrypted data -->
|
||||
<data android:pathPattern=".*\\.asc" />
|
||||
<data android:pathPattern=".*\\..*\\.asc" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.asc" />
|
||||
@ -375,7 +433,103 @@
|
||||
<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="*/*" />
|
||||
|
||||
<!-- GnuPG 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>
|
||||
|
||||
<!-- Keychain's own Actions -->
|
||||
<!-- IMPORT_KEY with files TODO: does this work? -->
|
||||
<intent-filter android:label="@string/intent_import_key">
|
||||
|
@ -35,7 +35,6 @@ import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.AsyncTaskResultWrapper;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListKeybaseLoader;
|
||||
@ -288,13 +287,13 @@ public class ImportKeysListFragment extends ListFragment implements
|
||||
if (error == null) {
|
||||
// No error
|
||||
mCachedKeyData = ((ImportKeysListLoader) loader).getParcelableRings();
|
||||
} else if (error instanceof ImportKeysListLoader.FileHasNoContent) {
|
||||
} else if (error instanceof ImportKeysListLoader.FileHasNoContentException) {
|
||||
Notify.showNotify(getActivity(), R.string.error_import_file_no_content, Notify.Style.ERROR);
|
||||
} else if (error instanceof ImportKeysListLoader.NonPgpPart) {
|
||||
} else if (error instanceof ImportKeysListLoader.NonPgpPartException) {
|
||||
Notify.showNotify(getActivity(),
|
||||
((ImportKeysListLoader.NonPgpPart) error).getCount() + " " + getResources().
|
||||
((ImportKeysListLoader.NonPgpPartException) error).getCount() + " " + getResources().
|
||||
getQuantityString(R.plurals.error_import_non_pgp_part,
|
||||
((ImportKeysListLoader.NonPgpPart) error).getCount()),
|
||||
((ImportKeysListLoader.NonPgpPartException) error).getCount()),
|
||||
Notify.Style.OK
|
||||
);
|
||||
} else {
|
||||
|
@ -30,20 +30,20 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportKeysListLoader
|
||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
|
||||
public static class FileHasNoContent extends Exception {
|
||||
|
||||
public static class FileHasNoContentException extends Exception {
|
||||
}
|
||||
|
||||
public static class NonPgpPart extends Exception {
|
||||
public static class NonPgpPartException extends Exception {
|
||||
private int mCount;
|
||||
|
||||
public NonPgpPart(int count) {
|
||||
public NonPgpPartException(int count) {
|
||||
this.mCount = count;
|
||||
}
|
||||
|
||||
@ -67,7 +67,6 @@ public class ImportKeysListLoader
|
||||
|
||||
@Override
|
||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||
|
||||
// This has already been loaded! nvm any further, just return
|
||||
if (mEntryListWrapper != null) {
|
||||
return mEntryListWrapper;
|
||||
@ -119,7 +118,6 @@ public class ImportKeysListLoader
|
||||
* @return
|
||||
*/
|
||||
private void generateListOfKeyrings(InputData inputData) {
|
||||
|
||||
boolean isEmpty = true;
|
||||
|
||||
PositionAwareInputStream progressIn = new PositionAwareInputStream(
|
||||
@ -129,13 +127,14 @@ public class ImportKeysListLoader
|
||||
// PGPObject chunks after the first one, e.g. files with several consecutive ASCII
|
||||
// armor blocks
|
||||
BufferedInputStream bufferedInput = new BufferedInputStream(progressIn);
|
||||
bufferedInput.mark(1024);
|
||||
try {
|
||||
|
||||
// read all available blocks... (asc files can contain many blocks with BEGIN END)
|
||||
while (bufferedInput.available() > 0) {
|
||||
// TODO: deal with non-keyring objects?
|
||||
List<UncachedKeyRing> rings = UncachedKeyRing.fromStream(bufferedInput);
|
||||
for(UncachedKeyRing key : rings) {
|
||||
for (UncachedKeyRing key : rings) {
|
||||
ImportKeysListEntry item = new ImportKeysListEntry(getContext(), key);
|
||||
mData.add(item);
|
||||
mParcelableRings.put(item.hashCode(), new ParcelableKeyRing(key.getEncoded()));
|
||||
@ -144,14 +143,26 @@ public class ImportKeysListLoader
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(Constants.TAG, "Exception on parsing key file!", e);
|
||||
|
||||
try {
|
||||
bufferedInput.reset();
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
Log.d(Constants.TAG, "Last 1024 byte input data: " + convertStreamToString(bufferedInput));
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, e);
|
||||
}
|
||||
|
||||
if (isEmpty) {
|
||||
Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
|
||||
FileHasNoContentException e = new FileHasNoContentException();
|
||||
Log.e(Constants.TAG, "File has no content!", e);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
(mData, new FileHasNoContent());
|
||||
(mData, e);
|
||||
}
|
||||
}
|
||||
|
||||
static String convertStreamToString(java.io.InputStream is) {
|
||||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
||||
return s.hasNext() ? s.next() : "";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user