diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1ab02a76f..2f90dc154 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -92,6 +92,9 @@ + + + diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index d2f37903a..671bbfb8d 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -100,8 +100,30 @@ public class Apg { public static final String ENCRYPT = "org.thialfihar.android.apg.intent.ENCRYPT"; public static final String DECRYPT_FILE = "org.thialfihar.android.apg.intent.DECRYPT_FILE"; public static final String ENCRYPT_FILE = "org.thialfihar.android.apg.intent.ENCRYPT_FILE"; + public static final String DECRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.DECRYPT_AND_RETURN"; } + public static final String EXTRA_DATA = "data"; + public static final String EXTRA_STATUS = "status"; + public static final String EXTRA_ERROR = "error"; + public static final String EXTRA_DECRYPTED_MESSAGE = "decryptedMessage"; + public static final String EXTRA_ENCRYPTED_MESSAGE = "decryptedMessage"; + public static final String EXTRA_SIGNATURE = "signature"; + public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId"; + public static final String EXTRA_SIGNATURE_USER_ID = "signatureUserId"; + public static final String EXTRA_SIGNATURE_SUCCESS = "signatureSuccess"; + public static final String EXTRA_SIGNATURE_UNKNOWN = "signatureUnknown"; + 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_MESSAGE = "message"; + public static final String EXTRA_PROGRESS = "progress"; + public static final String EXTRA_MAX = "max"; + public static final String EXTRA_ACCOUNT = "account"; + public static String VERSION = "1.0.0"; public static String FULL_VERSION = "APG v" + VERSION; @@ -1410,7 +1432,7 @@ public class Apg { if (dataChunk instanceof PGPOnePassSignatureList) { progress.setProgress(R.string.progress_processingSignature, currentProgress, 100); - returnData.putBoolean("signature", true); + returnData.putBoolean(EXTRA_SIGNATURE, true); PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk; for (int i = 0; i < sigList.size(); ++i) { signature = sigList.get(i); @@ -1428,17 +1450,17 @@ public class Apg { if (sigKeyRing != null) { userId = getMainUserId(getMasterKey(sigKeyRing)); } - returnData.putString("signatureUserId", userId); + returnData.putString(EXTRA_SIGNATURE_USER_ID, userId); break; } } - returnData.putLong("signatureKeyId", signatureKeyId); + returnData.putLong(EXTRA_SIGNATURE_KEY_ID, signatureKeyId); if (signature != null) { signature.initVerify(signatureKey, new BouncyCastleProvider()); } else { - returnData.putBoolean("signatureUnknown", true); + returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true); } dataChunk = plainFact.nextObject(); @@ -1470,7 +1492,7 @@ public class Apg { try { signature.update(buffer, 0, n); } catch (SignatureException e) { - returnData.putBoolean("signatureSuccess", false); + returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, false); signature = null; } } @@ -1490,9 +1512,9 @@ public class Apg { PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject(); PGPSignature messageSignature = (PGPSignature) signatureList.get(signatureIndex); if (signature.verify(messageSignature)) { - returnData.putBoolean("signatureSuccess", true); + returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, true); } else { - returnData.putBoolean("signatureSuccess", false); + returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, false); } } } @@ -1545,7 +1567,7 @@ public class Apg { byte[] clearText = out.toByteArray(); outStream.write(clearText); - returnData.putBoolean("signature", true); + returnData.putBoolean(EXTRA_SIGNATURE, true); progress.setProgress(R.string.progress_processingSignature, 60, 100); PGPObjectFactory pgpFact = new PGPObjectFactory(aIn); @@ -1572,15 +1594,15 @@ public class Apg { if (sigKeyRing != null) { userId = getMainUserId(getMasterKey(sigKeyRing)); } - returnData.putString("signatureUserId", userId); + returnData.putString(EXTRA_SIGNATURE_USER_ID, userId); break; } } - returnData.putLong("signatureKeyId", signatureKeyId); + returnData.putLong(EXTRA_SIGNATURE_KEY_ID, signatureKeyId); if (signature == null) { - returnData.putBoolean("signatureUnknown", true); + returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true); progress.setProgress(R.string.progress_done, 100, 100); return returnData; } @@ -1605,7 +1627,7 @@ public class Apg { while (lookAhead != -1); } - returnData.putBoolean("signatureSuccess", signature.verify()); + returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, signature.verify()); progress.setProgress(R.string.progress_done, 100, 100); return returnData; diff --git a/src/org/thialfihar/android/apg/BaseActivity.java b/src/org/thialfihar/android/apg/BaseActivity.java index 375658db5..282057975 100644 --- a/src/org/thialfihar/android/apg/BaseActivity.java +++ b/src/org/thialfihar/android/apg/BaseActivity.java @@ -292,7 +292,7 @@ public class BaseActivity extends Activity case Id.request.secret_keys: { if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); - setSecretKeyId(bundle.getLong("selectedKeyId")); + setSecretKeyId(bundle.getLong(Apg.EXTRA_KEY_ID)); } else { setSecretKeyId(Id.key.none); } @@ -314,9 +314,9 @@ public class BaseActivity extends Activity public void setProgress(int progress, int max) { Message msg = new Message(); Bundle data = new Bundle(); - data.putInt("type", Id.message.progress_update); - data.putInt("progress", progress); - data.putInt("max", max); + data.putInt(Apg.EXTRA_STATUS, Id.message.progress_update); + data.putInt(Apg.EXTRA_PROGRESS, progress); + data.putInt(Apg.EXTRA_MAX, max); msg.setData(data); mHandler.sendMessage(msg); } @@ -324,10 +324,10 @@ public class BaseActivity extends Activity public void setProgress(String message, int progress, int max) { Message msg = new Message(); Bundle data = new Bundle(); - data.putInt("type", Id.message.progress_update); - data.putString("message", message); - data.putInt("progress", progress); - data.putInt("max", max); + data.putInt(Apg.EXTRA_STATUS, Id.message.progress_update); + data.putString(Apg.EXTRA_MESSAGE, message); + data.putInt(Apg.EXTRA_PROGRESS, progress); + data.putInt(Apg.EXTRA_MAX, max); msg.setData(data); mHandler.sendMessage(msg); } @@ -338,16 +338,16 @@ public class BaseActivity extends Activity return; } - int type = data.getInt("type"); + int type = data.getInt(Apg.EXTRA_STATUS); switch (type) { case Id.message.progress_update: { - String message = data.getString("message"); + String message = data.getString(Apg.EXTRA_MESSAGE); if (mProgressDialog != null) { if (message != null) { mProgressDialog.setMessage(message); } - mProgressDialog.setMax(data.getInt("max")); - mProgressDialog.setProgress(data.getInt("progress")); + mProgressDialog.setMax(data.getInt(Apg.EXTRA_MAX)); + mProgressDialog.setProgress(data.getInt(Apg.EXTRA_PROGRESS)); } break; } diff --git a/src/org/thialfihar/android/apg/DecryptActivity.java b/src/org/thialfihar/android/apg/DecryptActivity.java index df18627ff..2be7de4b9 100644 --- a/src/org/thialfihar/android/apg/DecryptActivity.java +++ b/src/org/thialfihar/android/apg/DecryptActivity.java @@ -34,6 +34,7 @@ import org.bouncycastle2.openpgp.PGPException; import org.bouncycastle2.util.Strings; import org.openintents.intents.FileManager; +import android.app.Activity; import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -57,6 +58,8 @@ import android.widget.ViewFlipper; public class DecryptActivity extends BaseActivity { private long mSignatureKeyId = 0; + private Intent mIntent; + private String mReplyTo = null; private String mSubject = null; private boolean mSignedOnly = false; @@ -158,9 +161,9 @@ public class DecryptActivity extends BaseActivity { mSource.showNext(); } - Intent intent = getIntent(); - if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) { - Uri uri = intent.getData(); + mIntent = getIntent(); + if (mIntent.getAction() != null && mIntent.getAction().equals(Intent.ACTION_VIEW)) { + Uri uri = mIntent.getData(); try { InputStream attachment = getContentResolver().openInputStream(uri); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); @@ -177,8 +180,8 @@ public class DecryptActivity extends BaseActivity { } catch (IOException e) { // ignore, then } - } else if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEND)) { - Bundle extras = intent.getExtras(); + } else if (mIntent.getAction() != null && mIntent.getAction().equals(Intent.ACTION_SEND)) { + Bundle extras = mIntent.getExtras(); if (extras == null) { extras = new Bundle(); } @@ -190,12 +193,12 @@ public class DecryptActivity extends BaseActivity { if (mSubject.startsWith("Fwd: ")) { mSubject = mSubject.substring(5); } - } else if (intent.getAction() != null && intent.getAction().equals(Apg.Intent.DECRYPT)) { - Bundle extras = intent.getExtras(); + } else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT)) { + Bundle extras = mIntent.getExtras(); if (extras == null) { extras = new Bundle(); } - String data = extras.getString("data"); + String data = extras.getString(Apg.EXTRA_DATA); if (data != null) { Matcher matcher = Apg.PGP_MESSAGE.matcher(data); if (matcher.matches()) { @@ -214,14 +217,40 @@ public class DecryptActivity extends BaseActivity { } } } - mReplyTo = extras.getString("replyTo"); - mSubject = extras.getString("subject"); - } else if (intent.getAction() != null && intent.getAction().equals(Apg.Intent.DECRYPT_FILE)) { + mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO); + mSubject = extras.getString(Apg.EXTRA_SUBJECT); + } else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT_FILE)) { mSource.setInAnimation(null); mSource.setOutAnimation(null); while (mSource.getCurrentView().getId() != R.id.sourceFile) { mSource.showNext(); } + } else if (mIntent.getAction() != null && mIntent.getAction().equals(Apg.Intent.DECRYPT_AND_RETURN)) { + Bundle extras = mIntent.getExtras(); + if (extras == null) { + extras = new Bundle(); + } + String data = extras.getString(Apg.EXTRA_DATA); + if (data != null) { + Matcher matcher = Apg.PGP_MESSAGE.matcher(data); + if (matcher.matches()) { + data = matcher.group(1); + // replace non breakable spaces + data = data.replaceAll("\\xa0", " "); + mMessage.setText(data); + } else { + matcher = Apg.PGP_SIGNED_MESSAGE.matcher(data); + if (matcher.matches()) { + data = matcher.group(1); + // replace non breakable spaces + data = data.replaceAll("\\xa0", " "); + mMessage.setText(data); + mDecryptButton.setText(R.string.btn_verify); + } + } + } + mReplyTo = extras.getString(Apg.EXTRA_REPLY_TO); + mSubject = extras.getString(Apg.EXTRA_SUBJECT); } if (mSource.getCurrentView().getId() == R.id.sourceMessage && @@ -412,12 +441,11 @@ public class DecryptActivity extends BaseActivity { String data = mMessage.getText().toString(); data = data.replaceAll("(?m)^", "> "); data = "\n\n" + data; - intent.putExtra("data", data); - intent.putExtra("subject", "Re: " + mSubject); - intent.putExtra("sendTo", mReplyTo); - intent.putExtra("eyId", mSignatureKeyId); - intent.putExtra("signatureKeyId", getSecretKeyId()); - intent.putExtra("encryptionKeyIds", new long[] { mSignatureKeyId }); + intent.putExtra(Apg.EXTRA_DATA, data); + intent.putExtra(Apg.EXTRA_SUBJECT, "Re: " + mSubject); + intent.putExtra(Apg.EXTRA_SEND_TO, mReplyTo); + intent.putExtra(Apg.EXTRA_SIGNATURE_KEY_ID, getSecretKeyId()); + intent.putExtra(Apg.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId }); startActivity(intent); } @@ -475,9 +503,8 @@ public class DecryptActivity extends BaseActivity { out.close(); if (mDecryptTarget == Id.target.message) { - data.putString("decryptedMessage", - Strings.fromUTF8ByteArray(((ByteArrayOutputStream) - out).toByteArray())); + data.putByteArray(Apg.EXTRA_DECRYPTED_MESSAGE, + ((ByteArrayOutputStream) out).toByteArray()); } } catch (PGPException e) { error = "" + e; @@ -489,10 +516,10 @@ public class DecryptActivity extends BaseActivity { error = "" + e; } - data.putInt("type", Id.message.done); + data.putInt(Apg.EXTRA_STATUS, Id.message.done); if (error != null) { - data.putString("error", error); + data.putString(Apg.EXTRA_ERROR, error); } msg.setData(data); @@ -509,19 +536,17 @@ public class DecryptActivity extends BaseActivity { mSignatureLayout.setVisibility(View.GONE); mReplyButton.setVisibility(View.INVISIBLE); - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(DecryptActivity.this, - getString(R.string.errorMessage, - data.getString("error")), - Toast.LENGTH_SHORT).show(); + getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); return; } Toast.makeText(this, R.string.decryptionSuccessful, Toast.LENGTH_SHORT).show(); switch (mDecryptTarget) { case Id.target.message: { - String decryptedMessage = data.getString("decryptedMessage"); + String decryptedMessage = Strings.fromUTF8ByteArray(data.getByteArray(Apg.EXTRA_DECRYPTED_MESSAGE)); mMessage.setText(decryptedMessage); mReplyButton.setVisibility(View.VISIBLE); break; @@ -541,9 +566,9 @@ public class DecryptActivity extends BaseActivity { } } - if (data.getBoolean("signature")) { - String userId = data.getString("signatureUserId"); - mSignatureKeyId = data.getLong("signatureKeyId"); + if (data.getBoolean(Apg.EXTRA_SIGNATURE)) { + String userId = data.getString(Apg.EXTRA_SIGNATURE_USER_ID); + mSignatureKeyId = data.getLong(Apg.EXTRA_SIGNATURE_KEY_ID); mUserIdRest.setText("id: " + Long.toHexString(mSignatureKeyId & 0xffffffffL)); if (userId == null) { userId = getResources().getString(R.string.unknownUserId); @@ -555,15 +580,23 @@ public class DecryptActivity extends BaseActivity { } mUserId.setText(userId); - if (data.getBoolean("signatureSuccess")) { + if (data.getBoolean(Apg.EXTRA_SIGNATURE_SUCCESS)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - } else if (data.getBoolean("signatureUnknown")) { + } else if (data.getBoolean(Apg.EXTRA_SIGNATURE_UNKNOWN)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_error); } else { mSignatureStatusImage.setImageResource(R.drawable.overlay_error); } mSignatureLayout.setVisibility(View.VISIBLE); } + + if (mIntent.getAction() != null && + mIntent.getAction().equals(Apg.Intent.DECRYPT_AND_RETURN)) { + Intent intent = new Intent(); + intent.putExtras(data); + setResult(RESULT_OK, intent); + finish(); + } } @Override diff --git a/src/org/thialfihar/android/apg/EditKeyActivity.java b/src/org/thialfihar/android/apg/EditKeyActivity.java index 6c8842fcc..e71fd8e8c 100644 --- a/src/org/thialfihar/android/apg/EditKeyActivity.java +++ b/src/org/thialfihar/android/apg/EditKeyActivity.java @@ -71,7 +71,7 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { Intent intent = getIntent(); long keyId = 0; if (intent.getExtras() != null) { - keyId = intent.getExtras().getLong("keyId"); + keyId = intent.getExtras().getLong(Apg.EXTRA_KEY_ID); } if (keyId != 0) { @@ -262,10 +262,10 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { error = "" + e; } - data.putInt("type", Id.message.done); + data.putInt(Apg.EXTRA_STATUS, Id.message.done); if (error != null) { - data.putString("error", error); + data.putString(Apg.EXTRA_ERROR, error); } msg.setData(data); @@ -279,11 +279,10 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { Bundle data = msg.getData(); removeDialog(Id.dialog.saving); - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(EditKeyActivity.this, - getString(R.string.errorMessage, data.getString("error")), - Toast.LENGTH_SHORT).show(); + getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(EditKeyActivity.this, R.string.keySaved, Toast.LENGTH_SHORT).show(); setResult(RESULT_OK); diff --git a/src/org/thialfihar/android/apg/EncryptActivity.java b/src/org/thialfihar/android/apg/EncryptActivity.java index 3c6e3ccb8..b3abc2024 100644 --- a/src/org/thialfihar/android/apg/EncryptActivity.java +++ b/src/org/thialfihar/android/apg/EncryptActivity.java @@ -273,11 +273,11 @@ public class EncryptActivity extends BaseActivity { if (extras == null) { extras = new Bundle(); } - String data = extras.getString("data"); - mSendTo = extras.getString("sendTo"); - mSubject = extras.getString("subject"); - long signatureKeyId = extras.getLong("signatureKeyId"); - long encryptionKeyIds[] = extras.getLongArray("encryptionKeyIds"); + String data = extras.getString(Apg.EXTRA_DATA); + mSendTo = extras.getString(Apg.EXTRA_SEND_TO); + mSubject = extras.getString(Apg.EXTRA_SUBJECT); + long signatureKeyId = extras.getLong(Apg.EXTRA_SIGNATURE_KEY_ID); + long encryptionKeyIds[] = extras.getLongArray(Apg.EXTRA_ENCRYPTION_KEY_IDS); if (signatureKeyId != 0) { PGPSecretKeyRing keyRing = Apg.getSecretKeyRing(signatureKeyId); PGPSecretKey masterKey = null; @@ -582,7 +582,8 @@ public class EncryptActivity extends BaseActivity { out.close(); if (mEncryptTarget != Id.target.file) { - data.putString("message", new String(((ByteArrayOutputStream)out).toByteArray())); + data.putByteArray(Apg.EXTRA_ENCRYPTED_MESSAGE, + ((ByteArrayOutputStream)out).toByteArray()); } } catch (IOException e) { error = "" + e; @@ -598,10 +599,10 @@ public class EncryptActivity extends BaseActivity { error = "" + e; } - data.putInt("type", Id.message.done); + data.putInt(Apg.EXTRA_STATUS, Id.message.done); if (error != null) { - data.putString("error", error); + data.putString(Apg.EXTRA_ERROR, error); } msg.setData(data); @@ -645,7 +646,7 @@ public class EncryptActivity extends BaseActivity { private void selectPublicKeys() { Intent intent = new Intent(this, SelectPublicKeyListActivity.class); - intent.putExtra("selection", mEncryptionKeyIds); + intent.putExtra(Apg.EXTRA_SELECTION, mEncryptionKeyIds); startActivityForResult(intent, Id.request.public_keys); } @@ -702,7 +703,7 @@ public class EncryptActivity extends BaseActivity { case Id.request.public_keys: { if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); - mEncryptionKeyIds = bundle.getLongArray("selection"); + mEncryptionKeyIds = bundle.getLongArray(Apg.EXTRA_SELECTION); } updateView(); break; @@ -723,14 +724,13 @@ public class EncryptActivity extends BaseActivity { removeDialog(Id.dialog.encrypting); Bundle data = msg.getData(); - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(EncryptActivity.this, - getString(R.string.errorMessage, data.getString("error")), - Toast.LENGTH_SHORT).show(); + getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); return; } else { - String message = data.getString("message"); + String message = Strings.fromUTF8ByteArray(data.getByteArray(Apg.EXTRA_ENCRYPTED_MESSAGE)); switch (mEncryptTarget) { case Id.target.clipboard: { ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); diff --git a/src/org/thialfihar/android/apg/KeyListActivity.java b/src/org/thialfihar/android/apg/KeyListActivity.java index 36fad0086..7e86504b3 100644 --- a/src/org/thialfihar/android/apg/KeyListActivity.java +++ b/src/org/thialfihar/android/apg/KeyListActivity.java @@ -276,13 +276,13 @@ public class KeyListActivity extends BaseActivity { } if (mTask == Id.task.import_keys) { - data.putInt("type", Id.message.import_done); + data.putInt(Apg.EXTRA_STATUS, Id.message.import_done); } else { - data.putInt("type", Id.message.export_done); + data.putInt(Apg.EXTRA_STATUS, Id.message.export_done); } if (error != null) { - data.putString("error", error); + data.putString(Apg.EXTRA_ERROR, error); } msg.setData(data); @@ -305,15 +305,15 @@ public class KeyListActivity extends BaseActivity { Bundle data = msg.getData(); if (data != null) { - int type = data.getInt("type"); + int type = data.getInt(Apg.EXTRA_STATUS); switch (type) { case Id.message.import_done: { removeDialog(Id.dialog.importing); - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(KeyListActivity.this, - getString(R.string.errorMessage, data.getString("error")), + getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); } else { int added = data.getInt("added"); @@ -338,10 +338,10 @@ public class KeyListActivity extends BaseActivity { case Id.message.export_done: { removeDialog(Id.dialog.exporting); - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(KeyListActivity.this, - getString(R.string.errorMessage, data.getString("error")), + getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show(); } else { int exported = data.getInt("exported"); diff --git a/src/org/thialfihar/android/apg/MailListActivity.java b/src/org/thialfihar/android/apg/MailListActivity.java index f0abe8f45..d166feede 100644 --- a/src/org/thialfihar/android/apg/MailListActivity.java +++ b/src/org/thialfihar/android/apg/MailListActivity.java @@ -87,7 +87,7 @@ public class MailListActivity extends ListActivity { mconversations = new Vector(); mmessages = new Vector(); - String account = getIntent().getExtras().getString("account"); + String account = getIntent().getExtras().getString(Apg.EXTRA_ACCOUNT); // TODO: what if account is null? Uri uri = Uri.parse("content://gmail-ls/conversations/" + account); Cursor cursor = @@ -153,9 +153,9 @@ public class MailListActivity extends ListActivity { Intent intent = new Intent(MailListActivity.this, DecryptActivity.class); intent.setAction(Apg.Intent.DECRYPT); Message message = (Message) ((MailboxAdapter) getListAdapter()).getItem(position); - intent.putExtra("data", message.data); - intent.putExtra("subject", message.subject); - intent.putExtra("replyTo", message.replyTo); + intent.putExtra(Apg.EXTRA_DATA, message.data); + intent.putExtra(Apg.EXTRA_SUBJECT, message.subject); + intent.putExtra(Apg.EXTRA_REPLY_TO, message.replyTo); startActivity(intent); } }); diff --git a/src/org/thialfihar/android/apg/MainActivity.java b/src/org/thialfihar/android/apg/MainActivity.java index cdb79f1bf..ef3623ecb 100644 --- a/src/org/thialfihar/android/apg/MainActivity.java +++ b/src/org/thialfihar/android/apg/MainActivity.java @@ -112,7 +112,7 @@ public class MainActivity extends BaseActivity { public void onItemClick(AdapterView arg0, View view, int index, long id) { String accountName = (String) mAccounts.getSelectedItem(); startActivity(new Intent(MainActivity.this, MailListActivity.class) - .putExtra("account", accountName)); + .putExtra(Apg.EXTRA_ACCOUNT, accountName)); } }); registerForContextMenu(mAccounts); diff --git a/src/org/thialfihar/android/apg/SecretKeyListActivity.java b/src/org/thialfihar/android/apg/SecretKeyListActivity.java index 3d46cee5c..0252c46d2 100644 --- a/src/org/thialfihar/android/apg/SecretKeyListActivity.java +++ b/src/org/thialfihar/android/apg/SecretKeyListActivity.java @@ -153,7 +153,7 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli private void editKey() { long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem); Intent intent = new Intent(this, EditKeyActivity.class); - intent.putExtra("keyId", keyId); + intent.putExtra(Apg.EXTRA_KEY_ID, keyId); startActivityForResult(intent, Id.message.edit_key); } diff --git a/src/org/thialfihar/android/apg/SelectPublicKeyListActivity.java b/src/org/thialfihar/android/apg/SelectPublicKeyListActivity.java index c58243ef0..aeb6d59a3 100644 --- a/src/org/thialfihar/android/apg/SelectPublicKeyListActivity.java +++ b/src/org/thialfihar/android/apg/SelectPublicKeyListActivity.java @@ -38,7 +38,7 @@ public class SelectPublicKeyListActivity extends BaseActivity { mIntent = getIntent(); long selectedKeyIds[] = null; if (mIntent.getExtras() != null) { - selectedKeyIds = mIntent.getExtras().getLongArray("selection"); + selectedKeyIds = mIntent.getExtras().getLongArray(Apg.EXTRA_SELECTION); } mList = (ListView) findViewById(R.id.list); @@ -96,7 +96,7 @@ public class SelectPublicKeyListActivity extends BaseActivity { for (int i = 0; i < vector.size(); ++i) { selectedKeyIds[i] = vector.get(i); } - data.putExtra("selection", selectedKeyIds); + data.putExtra(Apg.EXTRA_SELECTION, selectedKeyIds); setResult(RESULT_OK, data); finish(); } diff --git a/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java b/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java index 88fc29972..cd87a94b6 100644 --- a/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java +++ b/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java @@ -43,7 +43,7 @@ public class SelectSecretKeyListActivity extends BaseActivity { @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { Intent data = new Intent(); - data.putExtra("selectedKeyId", id); + data.putExtra(Apg.EXTRA_KEY_ID, id); setResult(RESULT_OK, data); finish(); } diff --git a/src/org/thialfihar/android/apg/ui/widget/SectionView.java b/src/org/thialfihar/android/apg/ui/widget/SectionView.java index 32e73a491..e5dcd4aca 100644 --- a/src/org/thialfihar/android/apg/ui/widget/SectionView.java +++ b/src/org/thialfihar/android/apg/ui/widget/SectionView.java @@ -76,7 +76,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - String error = data.getString("error"); + String error = data.getString(Apg.EXTRA_ERROR); if (error != null) { Toast.makeText(getContext(), getContext().getString(R.string.errorMessage, error), @@ -327,7 +327,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor Bundle data = new Bundle(); data.putBoolean("closeProgressDialog", true); if (error != null) { - data.putString("error", error); + data.putString(Apg.EXTRA_ERROR, error); } else { data.putBoolean("gotNewKey", true); }