diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Id.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Id.java index 80122b587..a75a57c26 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Id.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Id.java @@ -20,11 +20,9 @@ package org.sufficientlysecure.keychain; import org.spongycastle.bcpg.CompressionAlgorithmTags; /** - * * TODO: - * + *

* - refactor ids, some are not needed and can be done with xml - * */ public final class Id { @@ -34,7 +32,6 @@ public final class Id { public static final int secret_key = 0x21070002; public static final int user_id = 0x21070003; public static final int key = 0x21070004; - public static final int public_secret_key = 0x21070005; } public static final class choice { @@ -50,19 +47,6 @@ public final class Id { public static final int bzip2 = CompressionAlgorithmTags.BZIP2; public static final int zip = CompressionAlgorithmTags.ZIP; } - - public static final class usage { - public static final int sign_only = 0x21070001; - public static final int encrypt_only = 0x21070002; - public static final int sign_and_encrypt = 0x21070003; - } - - public static final class action { - public static final int encrypt = 0x21070001; - public static final int decrypt = 0x21070002; - public static final int import_public = 0x21070003; - public static final int import_secret = 0x21070004; - } } public static final class return_value { @@ -73,34 +57,9 @@ public final class Id { public static final int bad = -3; } - public static final class target { - public static final int clipboard = 0x21070001; - public static final int email = 0x21070002; - public static final int file = 0x21070003; - public static final int message = 0x21070004; - } - - public static final class mode { - public static final int undefined = 0x21070001; - public static final int byte_array = 0x21070002; - public static final int file = 0x21070003; - public static final int stream = 0x21070004; - } - public static final class key { public static final int none = 0; public static final int symmetric = -1; } - public static final class content { - public static final int unknown = 0; - public static final int encrypted_data = 1; - public static final int keys = 2; - } - - public static final class keyserver { - public static final int search = 0x21070001; - public static final int get = 0x21070002; - public static final int add = 0x21070003; - } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java index ec2860593..9b505d2d9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java @@ -48,8 +48,8 @@ public class PgpHelper { public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern .compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----" + - "BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*", - Pattern.DOTALL); + "BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*", + Pattern.DOTALL); public static final Pattern PGP_PUBLIC_KEY = Pattern.compile( ".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*", @@ -71,21 +71,28 @@ public class PgpHelper { return "OpenPGP Keychain v" + getVersion(context); } - public static int getStreamContent(Context context, InputStream inStream) throws IOException { - InputStream in = PGPUtil.getDecoderStream(inStream); - PGPObjectFactory pgpF = new PGPObjectFactory(in); - Object object = pgpF.nextObject(); - while (object != null) { - if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) { - return Id.content.keys; - } else if (object instanceof PGPEncryptedDataList) { - return Id.content.encrypted_data; - } - object = pgpF.nextObject(); - } - - return Id.content.unknown; - } +// public static final class content { +// public static final int unknown = 0; +// public static final int encrypted_data = 1; +// public static final int keys = 2; +// } +// +// public static int getStreamContent(Context context, InputStream inStream) throws IOException { +// +// InputStream in = PGPUtil.getDecoderStream(inStream); +// PGPObjectFactory pgpF = new PGPObjectFactory(in); +// Object object = pgpF.nextObject(); +// while (object != null) { +// if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) { +// return Id.content.keys; +// } else if (object instanceof PGPEncryptedDataList) { +// return Id.content.encrypted_data; +// } +// object = pgpF.nextObject(); +// } +// +// return Id.content.unknown; +// } /** * Generate a random filename diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java index cde00a874..1413f3325 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java @@ -24,7 +24,9 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + import com.beardedhen.androidbootstrap.BootstrapButton; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -79,7 +81,7 @@ public class ImportKeysFileFragment extends Fragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode & 0xFFFF) { + switch (requestCode) { case REQUEST_CODE_FILE: { if (resultCode == Activity.RESULT_OK && data != null) {