extra constants moved into coresponding activities

This commit is contained in:
Dominik 2012-06-20 15:55:36 +03:00
parent c5ed6ce6f7
commit 47f88cdf4b
18 changed files with 153 additions and 130 deletions

View File

@ -22,7 +22,7 @@ public final class Constants {
public static final String TAG = "APG"; public static final String TAG = "APG";
public static final String PACKAGE_NAME = "org.thialfihar.android.apg"; public static final String PACKAGE_NAME = "org.thialfihar.android.apg";
/* /*
* TODO: * TODO:
@ -35,7 +35,6 @@ public final class Constants {
*/ */
public static final String INTENT_PREFIX = "org.thialfihar.android.apg.intent."; public static final String INTENT_PREFIX = "org.thialfihar.android.apg.intent.";
public static final class path { public static final class path {
public static final String APP_DIR = Environment.getExternalStorageDirectory() + "/APG"; public static final String APP_DIR = Environment.getExternalStorageDirectory() + "/APG";
} }

View File

@ -143,7 +143,7 @@ import java.util.regex.Pattern;
/** /**
* TODO: * TODO:
* *
* - Externalize the constants * - Externalize the authority and content uri constants
* *
* - Separate this file into different helpers * - Separate this file into different helpers
* *
@ -155,32 +155,6 @@ public class PGPHelper {
Security.addProvider(new BouncyCastleProvider()); Security.addProvider(new BouncyCastleProvider());
} }
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_ERROR = "error";
public static final String EXTRA_DECRYPTED_MESSAGE = "decryptedMessage";
public static final String EXTRA_DECRYPTED_DATA = "decryptedData";
public static final String EXTRA_ENCRYPTED_MESSAGE = "encryptedMessage";
public static final String EXTRA_ENCRYPTED_DATA = "encryptedData";
public static final String EXTRA_RESULT_URI = "resultUri";
public static final String EXTRA_SIGNATURE_DATA = "signatureData";
public static final String EXTRA_SIGNATURE_TEXT = "signatureText";
public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
public static final String EXTRA_USER_ID = "userId";
public static final String EXTRA_USER_IDS = "userIds";
public static final String EXTRA_KEY_ID = "keyId";
public static final String EXTRA_REPLY_TO = "replyTo";
public static final String EXTRA_SEND_TO = "sendTo";
public static final String EXTRA_SUBJECT = "subject";
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
public static final String EXTRA_SELECTION = "selection";
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
public static final String EXTRA_BINARY = "binary";
public static final String EXTRA_KEY_SERVERS = "keyServers";
public static final String EXTRA_EXPECTED_FINGERPRINT = "expectedFingerprint";
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
public static final String AUTHORITY = DataProvider.AUTHORITY; public static final String AUTHORITY = DataProvider.AUTHORITY;
public static final Uri CONTENT_URI_SECRET_KEY_RINGS = Uri.parse("content://" + AUTHORITY public static final Uri CONTENT_URI_SECRET_KEY_RINGS = Uri.parse("content://" + AUTHORITY

View File

@ -275,7 +275,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable,
case Id.request.secret_keys: { case Id.request.secret_keys: {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras(); Bundle bundle = data.getExtras();
setSecretKeyId(bundle.getLong(PGPHelper.EXTRA_KEY_ID)); setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.EXTRA_KEY_ID));
} else { } else {
setSecretKeyId(Id.key.none); setSecretKeyId(Id.key.none);
} }

View File

@ -75,6 +75,13 @@ public class DecryptActivity extends SherlockFragmentActivity {
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
+ "DECRYPT_AND_RETURN"; + "DECRYPT_AND_RETURN";
// possible extra keys
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_REPLY_TO = "replyTo";
public static final String EXTRA_SUBJECT = "subject";
public static final String EXTRA_BINARY = "binary";
private long mSignatureKeyId = 0; private long mSignatureKeyId = 0;
private Intent mIntent; private Intent mIntent;
@ -96,9 +103,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
private ImageView mSourcePrevious = null; private ImageView mSourcePrevious = null;
private ImageView mSourceNext = null; private ImageView mSourceNext = null;
// private Button mDecryptButton = null;
// private Button mReplyButton = null;
private boolean mDecryptEnabled = true; private boolean mDecryptEnabled = true;
private String mDecryptString = ""; private String mDecryptString = "";
private boolean mReplyEnabled = true; private boolean mReplyEnabled = true;
@ -117,9 +121,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
private byte[] mData = null; private byte[] mData = null;
private boolean mReturnBinary = false; private boolean mReturnBinary = false;
// private DataSource mDataSource = null;
// private DataDestination mDataDestination = null;
private long mUnknownSignatureKeyId = 0; private long mUnknownSignatureKeyId = 0;
private long mSecretKeyId = Id.key.none; private long mSecretKeyId = Id.key.none;
@ -288,11 +289,11 @@ public class DecryptActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "got extras"); Log.d(Constants.TAG, "got extras");
} }
mData = extras.getByteArray(PGPHelper.EXTRA_DATA); mData = extras.getByteArray(EXTRA_DATA);
String textData = null; String textData = null;
if (mData == null) { if (mData == null) {
Log.d(Constants.TAG, "EXTRA_DATA was null"); Log.d(Constants.TAG, "EXTRA_DATA was null");
textData = extras.getString(PGPHelper.EXTRA_TEXT); textData = extras.getString(EXTRA_TEXT);
} else { } else {
Log.d(Constants.TAG, "Got data from EXTRA_DATA"); Log.d(Constants.TAG, "Got data from EXTRA_DATA");
} }
@ -322,8 +323,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
} }
} }
} }
mReplyTo = extras.getString(PGPHelper.EXTRA_REPLY_TO); mReplyTo = extras.getString(EXTRA_REPLY_TO);
mSubject = extras.getString(PGPHelper.EXTRA_SUBJECT); mSubject = extras.getString(EXTRA_SUBJECT);
} else if (ACTION_DECRYPT_FILE.equals(mIntent.getAction())) { } else if (ACTION_DECRYPT_FILE.equals(mIntent.getAction())) {
mInputFilename = mIntent.getDataString(); mInputFilename = mIntent.getDataString();
if ("file".equals(mIntent.getScheme())) { if ("file".equals(mIntent.getScheme())) {
@ -343,11 +344,11 @@ public class DecryptActivity extends SherlockFragmentActivity {
extras = new Bundle(); extras = new Bundle();
} }
mReturnBinary = extras.getBoolean(PGPHelper.EXTRA_BINARY, false); mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
if (mContentUri == null) { if (mContentUri == null) {
mData = extras.getByteArray(PGPHelper.EXTRA_DATA); mData = extras.getByteArray(EXTRA_DATA);
String data = extras.getString(PGPHelper.EXTRA_TEXT); String data = extras.getString(EXTRA_TEXT);
if (data != null) { if (data != null) {
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(data); Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(data);
if (matcher.matches()) { if (matcher.matches()) {
@ -402,7 +403,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (key != null) { if (key != null) {
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class); Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID); intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mSignatureKeyId); intent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, mSignatureKeyId);
startActivity(intent); startActivity(intent);
} }
} }
@ -633,11 +634,11 @@ public class DecryptActivity extends SherlockFragmentActivity {
String data = mMessage.getText().toString(); String data = mMessage.getText().toString();
data = data.replaceAll("(?m)^", "> "); data = data.replaceAll("(?m)^", "> ");
data = "\n\n" + data; data = "\n\n" + data;
intent.putExtra(PGPHelper.EXTRA_TEXT, data); intent.putExtra(EncryptActivity.EXTRA_TEXT, data);
intent.putExtra(PGPHelper.EXTRA_SUBJECT, "Re: " + mSubject); intent.putExtra(EncryptActivity.EXTRA_SUBJECT, "Re: " + mSubject);
intent.putExtra(PGPHelper.EXTRA_SEND_TO, mReplyTo); intent.putExtra(EncryptActivity.EXTRA_SEND_TO, mReplyTo);
intent.putExtra(PGPHelper.EXTRA_SIGNATURE_KEY_ID, getSecretKeyId()); intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, getSecretKeyId());
intent.putExtra(PGPHelper.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId }); intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId });
startActivity(intent); startActivity(intent);
} }
@ -1044,7 +1045,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
removeDialog(Id.dialog.lookup_unknown_key); removeDialog(Id.dialog.lookup_unknown_key);
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class); Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID); intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mUnknownSignatureKeyId); intent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, mUnknownSignatureKeyId);
startActivityForResult(intent, Id.request.look_up_key_id); startActivityForResult(intent, Id.request.look_up_key_id);
} }
}); });

View File

@ -69,6 +69,12 @@ public class EditKeyActivity extends SherlockFragmentActivity {
public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEY"; public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEY";
public static final String ACTION_EDIT_KEY = Constants.INTENT_PREFIX + "EDIT_KEY"; public static final String ACTION_EDIT_KEY = Constants.INTENT_PREFIX + "EDIT_KEY";
// possible extra keys
public static final String EXTRA_USER_IDS = "userIds";
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
public static final String EXTRA_KEY_ID = "keyId";
private Intent mIntent = null; private Intent mIntent = null;
private ActionBar mActionBar; private ActionBar mActionBar;
@ -166,14 +172,14 @@ public class EditKeyActivity extends SherlockFragmentActivity {
if (extras != null) { if (extras != null) {
// if userId is given, prefill the fields // if userId is given, prefill the fields
if (extras.containsKey(PGPHelper.EXTRA_USER_IDS)) { if (extras.containsKey(EXTRA_USER_IDS)) {
Log.d(Constants.TAG, "UserIds are given!"); Log.d(Constants.TAG, "UserIds are given!");
mUserIds.add(extras.getString(PGPHelper.EXTRA_USER_IDS)); mUserIds.add(extras.getString(EXTRA_USER_IDS));
} }
// if no passphrase is given // if no passphrase is given
if (extras.containsKey(PGPHelper.EXTRA_NO_PASSPHRASE)) { if (extras.containsKey(EXTRA_NO_PASSPHRASE)) {
boolean noPassphrase = extras.getBoolean(PGPHelper.EXTRA_NO_PASSPHRASE); boolean noPassphrase = extras.getBoolean(EXTRA_NO_PASSPHRASE);
if (noPassphrase) { if (noPassphrase) {
// check "no passphrase" checkbox and remove button // check "no passphrase" checkbox and remove button
mNoPassphrase.setChecked(true); mNoPassphrase.setChecked(true);
@ -182,9 +188,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
} }
// generate key // generate key
if (extras.containsKey(PGPHelper.EXTRA_GENERATE_DEFAULT_KEYS)) { if (extras.containsKey(EXTRA_GENERATE_DEFAULT_KEYS)) {
boolean generateDefaultKeys = extras boolean generateDefaultKeys = extras.getBoolean(EXTRA_GENERATE_DEFAULT_KEYS);
.getBoolean(PGPHelper.EXTRA_GENERATE_DEFAULT_KEYS);
if (generateDefaultKeys) { if (generateDefaultKeys) {
// build layout in handler after generating keys not directly in onCreate // build layout in handler after generating keys not directly in onCreate
@ -264,8 +269,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
if (extras != null) { if (extras != null) {
if (extras.containsKey(PGPHelper.EXTRA_KEY_ID)) { if (extras.containsKey(EXTRA_KEY_ID)) {
long keyId = mIntent.getExtras().getLong(PGPHelper.EXTRA_KEY_ID); long keyId = mIntent.getExtras().getLong(EXTRA_KEY_ID);
if (keyId != 0) { if (keyId != 0) {
PGPSecretKey masterKey = null; PGPSecretKey masterKey = null;

View File

@ -76,6 +76,15 @@ public class EncryptActivity extends SherlockFragmentActivity {
public static final String ACTION_GENERATE_SIGNATURE = Constants.INTENT_PREFIX public static final String ACTION_GENERATE_SIGNATURE = Constants.INTENT_PREFIX
+ "GENERATE_SIGNATURE"; + "GENERATE_SIGNATURE";
// possible extra keys
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
public static final String EXTRA_SEND_TO = "sendTo";
public static final String EXTRA_SUBJECT = "subject";
public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
private Intent mIntent = null; private Intent mIntent = null;
private String mSubject = null; private String mSubject = null;
private String mSendTo = null; private String mSendTo = null;
@ -365,21 +374,21 @@ public class EncryptActivity extends SherlockFragmentActivity {
mAsciiArmourDemand = false; mAsciiArmourDemand = false;
} }
if (extras.containsKey(PGPHelper.EXTRA_ASCII_ARMOUR)) { if (extras.containsKey(EXTRA_ASCII_ARMOUR)) {
mAsciiArmourDemand = extras.getBoolean(PGPHelper.EXTRA_ASCII_ARMOUR, true); mAsciiArmourDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true);
mOverrideAsciiArmour = true; mOverrideAsciiArmour = true;
mAsciiArmour.setChecked(mAsciiArmourDemand); mAsciiArmour.setChecked(mAsciiArmourDemand);
} }
mData = extras.getByteArray(PGPHelper.EXTRA_DATA); mData = extras.getByteArray(EXTRA_DATA);
String textData = null; String textData = null;
if (mData == null) { if (mData == null) {
textData = extras.getString(PGPHelper.EXTRA_TEXT); textData = extras.getString(EXTRA_TEXT);
} }
mSendTo = extras.getString(PGPHelper.EXTRA_SEND_TO); mSendTo = extras.getString(EXTRA_SEND_TO);
mSubject = extras.getString(PGPHelper.EXTRA_SUBJECT); mSubject = extras.getString(EXTRA_SUBJECT);
long signatureKeyId = extras.getLong(PGPHelper.EXTRA_SIGNATURE_KEY_ID); long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
long encryptionKeyIds[] = extras.getLongArray(PGPHelper.EXTRA_ENCRYPTION_KEY_IDS); long encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
if (signatureKeyId != 0) { if (signatureKeyId != 0) {
PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(signatureKeyId); PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(signatureKeyId);
PGPSecretKey masterKey = null; PGPSecretKey masterKey = null;
@ -964,7 +973,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
initialKeyIds[i] = keyIds.get(i); initialKeyIds[i] = keyIds.get(i);
} }
} }
intent.putExtra(PGPHelper.EXTRA_SELECTION, initialKeyIds); intent.putExtra(SelectPublicKeyListActivity.EXTRA_SELECTION, initialKeyIds);
startActivityForResult(intent, Id.request.public_keys); startActivityForResult(intent, Id.request.public_keys);
} }
@ -1007,7 +1016,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
case Id.request.public_keys: { case Id.request.public_keys: {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras(); Bundle bundle = data.getExtras();
mEncryptionKeyIds = bundle.getLongArray(PGPHelper.EXTRA_SELECTION); mEncryptionKeyIds = bundle
.getLongArray(SelectPublicKeyListActivity.EXTRA_SELECTION);
} }
updateView(); updateView();
break; break;
@ -1016,7 +1026,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
case Id.request.secret_keys: { case Id.request.secret_keys: {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras(); Bundle bundle = data.getExtras();
setSecretKeyId(bundle.getLong(PGPHelper.EXTRA_KEY_ID)); setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.EXTRA_KEY_ID));
} else { } else {
setSecretKeyId(Id.key.none); setSecretKeyId(Id.key.none);
} }

View File

@ -43,6 +43,11 @@ public class ImportFromQRCodeActivity extends BaseActivity {
public static final String IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX public static final String IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX
+ "IMPORT_FROM_QR_CODE"; + "IMPORT_FROM_QR_CODE";
public static final String EXTRA_KEY_ID = "keyId";
// TODO: remove when using new intentservice:
public static final String EXTRA_ERROR = "error";
private static final String TAG = "ImportFromQRCodeActivity"; private static final String TAG = "ImportFromQRCodeActivity";
private final Bundle status = new Bundle(); private final Bundle status = new Bundle();
@ -64,12 +69,8 @@ public class ImportFromQRCodeActivity extends BaseActivity {
try { try {
// TODO: display some sort of spinner here while the user waits // TODO: display some sort of spinner here while the user waits
HkpKeyServer server = new HkpKeyServer(mPreferences.getKeyServers()[0]); // TODO: // TODO: there should be only 1
// there HkpKeyServer server = new HkpKeyServer(mPreferences.getKeyServers()[0]);
// should
// be
// only
// 1
String encodedKey = server.get(keyId); String encodedKey = server.get(keyId);
PGPKeyRing keyring = PGPHelper.decodeKeyRing(new ByteArrayInputStream( PGPKeyRing keyring = PGPHelper.decodeKeyRing(new ByteArrayInputStream(
@ -85,27 +86,27 @@ public class ImportFromQRCodeActivity extends BaseActivity {
int retval = PGPHelper.storeKeyRingInCache(publicKeyRing); int retval = PGPHelper.storeKeyRingInCache(publicKeyRing);
if (retval != Id.return_value.ok if (retval != Id.return_value.ok
&& retval != Id.return_value.updated) { && retval != Id.return_value.updated) {
status.putString(PGPHelper.EXTRA_ERROR, status.putString(EXTRA_ERROR,
"Failed to store signed key in local cache"); "Failed to store signed key in local cache");
} else { } else {
Intent intent = new Intent(ImportFromQRCodeActivity.this, Intent intent = new Intent(ImportFromQRCodeActivity.this,
SignKeyActivity.class); SignKeyActivity.class);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId); intent.putExtra(EXTRA_KEY_ID, keyId);
startActivityForResult(intent, Id.request.sign_key); startActivityForResult(intent, Id.request.sign_key);
} }
} else { } else {
status.putString( status.putString(
PGPHelper.EXTRA_ERROR, EXTRA_ERROR,
"Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key."); "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
} }
} }
} catch (QueryException e) { } catch (QueryException e) {
Log.e(TAG, "Failed to query KeyServer", e); Log.e(TAG, "Failed to query KeyServer", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to query KeyServer"); status.putString(EXTRA_ERROR, "Failed to query KeyServer");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "Failed to query KeyServer", e); Log.e(TAG, "Failed to query KeyServer", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to query KeyServer"); status.putString(EXTRA_ERROR, "Failed to query KeyServer");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
} }
} }
@ -162,7 +163,7 @@ public class ImportFromQRCodeActivity extends BaseActivity {
super.doneCallback(msg); super.doneCallback(msg);
Bundle data = msg.getData(); Bundle data = msg.getData();
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
.show(); .show();

View File

@ -72,6 +72,11 @@ public class KeyListActivity extends BaseActivity {
public static final String ACTION_IMPORT = Constants.INTENT_PREFIX + "IMPORT"; public static final String ACTION_IMPORT = Constants.INTENT_PREFIX + "IMPORT";
public static final String EXTRA_TEXT = "text";
// TODO: remove when using new intentservice:
public static final String EXTRA_ERROR = "error";
protected ExpandableListView mList; protected ExpandableListView mList;
protected KeyListAdapter mListAdapter; protected KeyListAdapter mListAdapter;
protected View mFilterLayout; protected View mFilterLayout;
@ -146,7 +151,7 @@ public class KeyListActivity extends BaseActivity {
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
mImportFilename = Uri.decode(intent.getDataString().replace("file://", "")); mImportFilename = Uri.decode(intent.getDataString().replace("file://", ""));
} else { } else {
mImportData = intent.getStringExtra(PGPHelper.EXTRA_TEXT); mImportData = intent.getStringExtra(EXTRA_TEXT);
} }
importKeys(); importKeys();
} }
@ -373,7 +378,7 @@ public class KeyListActivity extends BaseActivity {
} }
if (error != null) { if (error != null) {
data.putString(PGPHelper.EXTRA_ERROR, error); data.putString(EXTRA_ERROR, error);
} }
msg.setData(data); msg.setData(data);
@ -401,7 +406,7 @@ public class KeyListActivity extends BaseActivity {
case Id.message.import_done: { case Id.message.import_done: {
removeDialog(Id.dialog.importing); removeDialog(Id.dialog.importing);
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(KeyListActivity.this, getString(R.string.errorMessage, error), Toast.makeText(KeyListActivity.this, getString(R.string.errorMessage, error),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
@ -448,7 +453,7 @@ public class KeyListActivity extends BaseActivity {
case Id.message.export_done: { case Id.message.export_done: {
removeDialog(Id.dialog.exporting); removeDialog(Id.dialog.exporting);
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(KeyListActivity.this, getString(R.string.errorMessage, error), Toast.makeText(KeyListActivity.this, getString(R.string.errorMessage, error),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();

View File

@ -47,6 +47,11 @@ public class KeyServerExportActivity extends BaseActivity {
public static final String ACTION_EXPORT_KEY_TO_SERVER = Constants.INTENT_PREFIX public static final String ACTION_EXPORT_KEY_TO_SERVER = Constants.INTENT_PREFIX
+ "EXPORT_KEY_TO_SERVER"; + "EXPORT_KEY_TO_SERVER";
public static final String EXTRA_KEY_ID = "keyId";
// TODO: remove when using new intentservice:
public static final String EXTRA_ERROR = "error";
private Button export; private Button export;
private Spinner keyServer; private Spinner keyServer;
@ -103,7 +108,7 @@ public class KeyServerExportActivity extends BaseActivity {
HkpKeyServer server = new HkpKeyServer((String) keyServer.getSelectedItem()); HkpKeyServer server = new HkpKeyServer((String) keyServer.getSelectedItem());
int keyRingId = getIntent().getIntExtra(PGPHelper.EXTRA_KEY_ID, -1); int keyRingId = getIntent().getIntExtra(EXTRA_KEY_ID, -1);
PGPKeyRing keyring = PGPHelper.getKeyRing(keyRingId); PGPKeyRing keyring = PGPHelper.getKeyRing(keyRingId);
if (keyring != null && keyring instanceof PGPPublicKeyRing) { if (keyring != null && keyring instanceof PGPPublicKeyRing) {
@ -116,7 +121,7 @@ public class KeyServerExportActivity extends BaseActivity {
data.putInt(Constants.extras.STATUS, Id.message.export_done); data.putInt(Constants.extras.STATUS, Id.message.export_done);
if (error != null) { if (error != null) {
data.putString(PGPHelper.EXTRA_ERROR, error); data.putString(EXTRA_ERROR, error);
} }
msg.setData(data); msg.setData(data);
@ -128,7 +133,7 @@ public class KeyServerExportActivity extends BaseActivity {
super.doneCallback(msg); super.doneCallback(msg);
Bundle data = msg.getData(); Bundle data = msg.getData();
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
.show(); .show();

View File

@ -60,6 +60,12 @@ public class KeyServerQueryActivity extends BaseActivity {
public static final String ACTION_LOOK_UP_KEY_ID_AND_RETURN = Constants.INTENT_PREFIX public static final String ACTION_LOOK_UP_KEY_ID_AND_RETURN = Constants.INTENT_PREFIX
+ "LOOK_UP_KEY_ID_AND_RETURN"; + "LOOK_UP_KEY_ID_AND_RETURN";
public static final String EXTRA_KEY_ID = "keyId";
// TODO: remove when using new intentservice:
public static final String EXTRA_ERROR = "error";
public static final String EXTRA_TEXT = "text";
private ListView mList; private ListView mList;
private EditText mQuery; private EditText mQuery;
private Button mSearch; private Button mSearch;
@ -129,7 +135,7 @@ public class KeyServerQueryActivity extends BaseActivity {
Intent intent = getIntent(); Intent intent = getIntent();
if (ACTION_LOOK_UP_KEY_ID.equals(intent.getAction()) if (ACTION_LOOK_UP_KEY_ID.equals(intent.getAction())
|| ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) { || ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) {
long keyId = intent.getLongExtra(PGPHelper.EXTRA_KEY_ID, 0); long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0);
if (keyId != 0) { if (keyId != 0) {
String query = "0x" + PGPHelper.keyToHex(keyId); String query = "0x" + PGPHelper.keyToHex(keyId);
mQuery.setText(query); mQuery.setText(query);
@ -185,7 +191,7 @@ public class KeyServerQueryActivity extends BaseActivity {
data.putInt(Constants.extras.STATUS, Id.message.done); data.putInt(Constants.extras.STATUS, Id.message.done);
if (error != null) { if (error != null) {
data.putString(PGPHelper.EXTRA_ERROR, error); data.putString(EXTRA_ERROR, error);
} }
msg.setData(data); msg.setData(data);
@ -199,7 +205,7 @@ public class KeyServerQueryActivity extends BaseActivity {
removeDialog(Id.dialog.querying); removeDialog(Id.dialog.querying);
Bundle data = msg.getData(); Bundle data = msg.getData();
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
.show(); .show();
@ -217,7 +223,7 @@ public class KeyServerQueryActivity extends BaseActivity {
if (ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) { if (ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) {
if (mKeyData != null) { if (mKeyData != null) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData); intent.putExtra(EXTRA_TEXT, mKeyData);
setResult(RESULT_OK, intent); setResult(RESULT_OK, intent);
} else { } else {
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
@ -227,7 +233,7 @@ public class KeyServerQueryActivity extends BaseActivity {
if (mKeyData != null) { if (mKeyData != null) {
Intent intent = new Intent(this, PublicKeyListActivity.class); Intent intent = new Intent(this, PublicKeyListActivity.class);
intent.setAction(KeyListActivity.ACTION_IMPORT); intent.setAction(KeyListActivity.ACTION_IMPORT);
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData); intent.putExtra(KeyListActivity.EXTRA_TEXT, mKeyData);
startActivity(intent); startActivity(intent);
} }
} }
@ -320,7 +326,7 @@ public class KeyServerQueryActivity extends BaseActivity {
} }
if (!second) { if (!second) {
View sep = new View(mActivity); View sep = new View(mActivity);
sep.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1)); sep.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
sep.setBackgroundResource(android.R.drawable.divider_horizontal_dark); sep.setBackgroundResource(android.R.drawable.divider_horizontal_dark);
ll.addView(sep); ll.addView(sep);
} }

View File

@ -151,9 +151,9 @@ public class MailListActivity extends ListActivity {
Intent intent = new Intent(MailListActivity.this, DecryptActivity.class); Intent intent = new Intent(MailListActivity.this, DecryptActivity.class);
intent.setAction(DecryptActivity.ACTION_DECRYPT); intent.setAction(DecryptActivity.ACTION_DECRYPT);
Message message = (Message) ((MailboxAdapter) getListAdapter()).getItem(position); Message message = (Message) ((MailboxAdapter) getListAdapter()).getItem(position);
intent.putExtra(PGPHelper.EXTRA_TEXT, message.data); intent.putExtra(DecryptActivity.EXTRA_TEXT, message.data);
intent.putExtra(PGPHelper.EXTRA_SUBJECT, message.subject); intent.putExtra(DecryptActivity.EXTRA_SUBJECT, message.subject);
intent.putExtra(PGPHelper.EXTRA_REPLY_TO, message.replyTo); intent.putExtra(DecryptActivity.EXTRA_REPLY_TO, message.replyTo);
startActivity(intent); startActivity(intent);
} }
}); });

View File

@ -195,7 +195,8 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(PreferencesActivity.this, Intent intent = new Intent(PreferencesActivity.this,
PreferencesKeyServerActivity.class); PreferencesKeyServerActivity.class);
intent.putExtra(PGPHelper.EXTRA_KEY_SERVERS, mPreferences.getKeyServers()); intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
mPreferences.getKeyServers());
startActivityForResult(intent, Id.request.key_server_preference); startActivityForResult(intent, Id.request.key_server_preference);
return false; return false;
} }
@ -209,7 +210,8 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
if (resultCode == RESULT_CANCELED || data == null) { if (resultCode == RESULT_CANCELED || data == null) {
return; return;
} }
String servers[] = data.getStringArrayExtra(PGPHelper.EXTRA_KEY_SERVERS); String servers[] = data
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
mPreferences.setKeyServers(servers); mPreferences.setKeyServers(servers);
mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers, mKeyServerPreference.setSummary(getResources().getString(R.string.nKeyServers,
servers.length)); servers.length));

View File

@ -41,6 +41,9 @@ import android.widget.TextView;
public class PreferencesKeyServerActivity extends SherlockActivity implements OnClickListener, public class PreferencesKeyServerActivity extends SherlockActivity implements OnClickListener,
EditorListener { EditorListener {
public static final String EXTRA_KEY_SERVERS = "keyServers";
private LayoutInflater mInflater; private LayoutInflater mInflater;
private ViewGroup mEditors; private ViewGroup mEditors;
private View mAdd; private View mAdd;
@ -114,7 +117,7 @@ public class PreferencesKeyServerActivity extends SherlockActivity implements On
mAdd.setOnClickListener(this); mAdd.setOnClickListener(this);
Intent intent = getIntent(); Intent intent = getIntent();
String servers[] = intent.getStringArrayExtra(PGPHelper.EXTRA_KEY_SERVERS); String servers[] = intent.getStringArrayExtra(EXTRA_KEY_SERVERS);
if (servers != null) { if (servers != null) {
for (int i = 0; i < servers.length; ++i) { for (int i = 0; i < servers.length; ++i) {
KeyServerEditor view = (KeyServerEditor) mInflater.inflate( KeyServerEditor view = (KeyServerEditor) mInflater.inflate(
@ -153,7 +156,7 @@ public class PreferencesKeyServerActivity extends SherlockActivity implements On
} }
} }
String[] dummy = new String[0]; String[] dummy = new String[0];
data.putExtra(PGPHelper.EXTRA_KEY_SERVERS, servers.toArray(dummy)); data.putExtra(EXTRA_KEY_SERVERS, servers.toArray(dummy));
setResult(RESULT_OK, data); setResult(RESULT_OK, data);
finish(); finish();
} }

View File

@ -25,6 +25,7 @@ import org.thialfihar.android.apg.helper.PGPHelper;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import android.app.ListActivity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -125,7 +126,7 @@ public class PublicKeyListActivity extends KeyListActivity {
Intent intent = new Intent(this, KeyServerQueryActivity.class); Intent intent = new Intent(this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN); intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId); intent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, keyId);
startActivityForResult(intent, Id.request.look_up_key_id); startActivityForResult(intent, Id.request.look_up_key_id);
return true; return true;
@ -137,7 +138,7 @@ public class PublicKeyListActivity extends KeyListActivity {
Intent intent = new Intent(this, KeyServerExportActivity.class); Intent intent = new Intent(this, KeyServerExportActivity.class);
intent.setAction(KeyServerExportActivity.ACTION_EXPORT_KEY_TO_SERVER); intent.setAction(KeyServerExportActivity.ACTION_EXPORT_KEY_TO_SERVER);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyRingId); intent.putExtra(KeyServerExportActivity.EXTRA_KEY_ID, keyRingId);
startActivityForResult(intent, Id.request.export_to_server); startActivityForResult(intent, Id.request.export_to_server);
return true; return true;
@ -158,7 +159,7 @@ public class PublicKeyListActivity extends KeyListActivity {
} }
Intent intent = new Intent(this, SignKeyActivity.class); Intent intent = new Intent(this, SignKeyActivity.class);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId); intent.putExtra(SignKeyActivity.EXTRA_KEY_ID, keyId);
startActivity(intent); startActivity(intent);
return true; return true;
@ -175,13 +176,14 @@ public class PublicKeyListActivity extends KeyListActivity {
switch (requestCode) { switch (requestCode) {
case Id.request.look_up_key_id: { case Id.request.look_up_key_id: {
if (resultCode == RESULT_CANCELED || data == null if (resultCode == RESULT_CANCELED || data == null
|| data.getStringExtra(PGPHelper.EXTRA_TEXT) == null) { || data.getStringExtra(KeyServerQueryActivity.EXTRA_TEXT) == null) {
return; return;
} }
Intent intent = new Intent(this, PublicKeyListActivity.class); Intent intent = new Intent(this, PublicKeyListActivity.class);
intent.setAction(PublicKeyListActivity.ACTION_IMPORT); intent.setAction(PublicKeyListActivity.ACTION_IMPORT);
intent.putExtra(PGPHelper.EXTRA_TEXT, data.getStringExtra(PGPHelper.EXTRA_TEXT)); intent.putExtra(PublicKeyListActivity.EXTRA_TEXT,
data.getStringExtra(KeyListActivity.EXTRA_TEXT));
handleIntent(intent); handleIntent(intent);
break; break;
} }

View File

@ -171,7 +171,7 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
private void editKey() { private void editKey() {
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem); long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY); Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId); intent.putExtra(EditKeyActivity.EXTRA_KEY_ID, keyId);
startActivityForResult(intent, Id.message.edit_key); startActivityForResult(intent, Id.message.edit_key);
} }

View File

@ -43,6 +43,9 @@ public class SelectPublicKeyListActivity extends BaseActivity {
public static final String ACTION_SELECT_PUBLIC_KEYS = Constants.INTENT_PREFIX public static final String ACTION_SELECT_PUBLIC_KEYS = Constants.INTENT_PREFIX
+ "SELECT_PUBLIC_KEYS"; + "SELECT_PUBLIC_KEYS";
public static final String EXTRA_SELECTION = "selection";
public static final String EXTRA_USER_IDS = "userIds";
protected ListView mList; protected ListView mList;
protected SelectPublicKeyListAdapter mListAdapter; protected SelectPublicKeyListAdapter mListAdapter;
protected View mFilterLayout; protected View mFilterLayout;
@ -95,7 +98,7 @@ public class SelectPublicKeyListActivity extends BaseActivity {
} }
long selectedKeyIds[] = null; long selectedKeyIds[] = null;
selectedKeyIds = intent.getLongArrayExtra(PGPHelper.EXTRA_SELECTION); selectedKeyIds = intent.getLongArrayExtra(EXTRA_SELECTION);
if (selectedKeyIds == null) { if (selectedKeyIds == null) {
Vector<Long> vector = new Vector<Long>(); Vector<Long> vector = new Vector<Long>();
@ -157,8 +160,8 @@ public class SelectPublicKeyListActivity extends BaseActivity {
selectedKeyIds[i] = keys.get(i); selectedKeyIds[i] = keys.get(i);
} }
String userIdArray[] = new String[0]; String userIdArray[] = new String[0];
data.putExtra(PGPHelper.EXTRA_SELECTION, selectedKeyIds); data.putExtra(EXTRA_SELECTION, selectedKeyIds);
data.putExtra(PGPHelper.EXTRA_USER_IDS, userIds.toArray(userIdArray)); data.putExtra(EXTRA_USER_IDS, userIds.toArray(userIdArray));
setResult(RESULT_OK, data); setResult(RESULT_OK, data);
finish(); finish();
} }

View File

@ -42,6 +42,9 @@ public class SelectSecretKeyListActivity extends BaseActivity {
public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX
+ "SELECT_SECRET_KEY"; + "SELECT_SECRET_KEY";
public static final String EXTRA_USER_ID = "userId";
public static final String EXTRA_KEY_ID = "keyId";
protected ListView mList; protected ListView mList;
protected SelectSecretKeyListAdapter mListAdapter; protected SelectSecretKeyListAdapter mListAdapter;
protected View mFilterLayout; protected View mFilterLayout;
@ -68,8 +71,8 @@ public class SelectSecretKeyListActivity extends BaseActivity {
mList.setOnItemClickListener(new OnItemClickListener() { mList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Intent data = new Intent(); Intent data = new Intent();
data.putExtra(PGPHelper.EXTRA_KEY_ID, id); data.putExtra(EXTRA_KEY_ID, id);
data.putExtra(PGPHelper.EXTRA_USER_ID, (String) mList.getItemAtPosition(position)); data.putExtra(EXTRA_USER_ID, (String) mList.getItemAtPosition(position));
setResult(RESULT_OK, data); setResult(RESULT_OK, data);
finish(); finish();
} }

View File

@ -60,7 +60,11 @@ import android.widget.Toast;
* signs the specified public key with the specified secret master key * signs the specified public key with the specified secret master key
*/ */
public class SignKeyActivity extends BaseActivity { public class SignKeyActivity extends BaseActivity {
private static final String TAG = "SignKeyActivity";
public static final String EXTRA_KEY_ID = "keyId";
// TODO: remove when using new intentservice:
public static final String EXTRA_ERROR = "error";
private long pubKeyId = 0; private long pubKeyId = 0;
private long masterKeyId = 0; private long masterKeyId = 0;
@ -124,7 +128,7 @@ public class SignKeyActivity extends BaseActivity {
} }
}); });
pubKeyId = getIntent().getLongExtra(PGPHelper.EXTRA_KEY_ID, 0); pubKeyId = getIntent().getLongExtra(EXTRA_KEY_ID, 0);
if (pubKeyId == 0) { if (pubKeyId == 0) {
finish(); // nothing to do if we dont know what key to sign finish(); // nothing to do if we dont know what key to sign
} else { } else {
@ -170,7 +174,7 @@ public class SignKeyActivity extends BaseActivity {
final Bundle status = new Bundle(); final Bundle status = new Bundle();
Message msg = new Message(); Message msg = new Message();
status.putString(PGPHelper.EXTRA_ERROR, "Key has already been signed"); status.putString(EXTRA_ERROR, "Key has already been signed");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
@ -210,7 +214,7 @@ public class SignKeyActivity extends BaseActivity {
try { try {
String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId); String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId);
if (passphrase == null || passphrase.length() <= 0) { if (passphrase == null || passphrase.length() <= 0) {
status.putString(PGPHelper.EXTRA_ERROR, "Unable to obtain passphrase"); status.putString(EXTRA_ERROR, "Unable to obtain passphrase");
} else { } else {
PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId); PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId);
@ -249,27 +253,27 @@ public class SignKeyActivity extends BaseActivity {
// store the signed key in our local cache // store the signed key in our local cache
int retval = PGPHelper.storeKeyRingInCache(pubring); int retval = PGPHelper.storeKeyRingInCache(pubring);
if (retval != Id.return_value.ok && retval != Id.return_value.updated) { if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
status.putString(PGPHelper.EXTRA_ERROR, "Failed to store signed key in local cache"); status.putString(EXTRA_ERROR, "Failed to store signed key in local cache");
} }
} }
} catch (PGPException e) { } catch (PGPException e) {
Log.e(TAG, "Failed to sign key", e); Log.e(Constants.TAG, "Failed to sign key", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to sign key"); status.putString(EXTRA_ERROR, "Failed to sign key");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
return; return;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Failed to sign key", e); Log.e(Constants.TAG, "Failed to sign key", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to sign key"); status.putString(EXTRA_ERROR, "Failed to sign key");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
return; return;
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {
Log.e(TAG, "Failed to sign key", e); Log.e(Constants.TAG, "Failed to sign key", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to sign key"); status.putString(EXTRA_ERROR, "Failed to sign key");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
return; return;
} catch (SignatureException e) { } catch (SignatureException e) {
Log.e(TAG, "Failed to sign key", e); Log.e(Constants.TAG, "Failed to sign key", e);
status.putString(PGPHelper.EXTRA_ERROR, "Failed to sign key"); status.putString(EXTRA_ERROR, "Failed to sign key");
status.putInt(Constants.extras.STATUS, Id.message.done); status.putInt(Constants.extras.STATUS, Id.message.done);
return; return;
} }
@ -279,7 +283,7 @@ public class SignKeyActivity extends BaseActivity {
msg.setData(status); msg.setData(status);
sendMessage(msg); sendMessage(msg);
if (status.containsKey(PGPHelper.EXTRA_ERROR)) { if (status.containsKey(EXTRA_ERROR)) {
setResult(Id.return_value.error); setResult(Id.return_value.error);
} else { } else {
setResult(Id.return_value.ok); setResult(Id.return_value.ok);
@ -293,7 +297,7 @@ public class SignKeyActivity extends BaseActivity {
switch (requestCode) { switch (requestCode) {
case Id.request.secret_keys: { case Id.request.secret_keys: {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
masterKeyId = data.getLongExtra(PGPHelper.EXTRA_KEY_ID, 0); masterKeyId = data.getLongExtra(EXTRA_KEY_ID, 0);
// re-enable the sign button so the user can initiate the sign process // re-enable the sign button so the user can initiate the sign process
Button sign = (Button) findViewById(R.id.sign); Button sign = (Button) findViewById(R.id.sign);
@ -316,7 +320,7 @@ public class SignKeyActivity extends BaseActivity {
removeDialog(Id.dialog.signing); removeDialog(Id.dialog.signing);
Bundle data = msg.getData(); Bundle data = msg.getData();
String error = data.getString(PGPHelper.EXTRA_ERROR); String error = data.getString(EXTRA_ERROR);
if (error != null) { if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
.show(); .show();