aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/thialfihar/android/apg/EncryptActivity.java
diff options
context:
space:
mode:
authorThialfihar <thialfihar@gmail.com>2010-07-27 22:41:50 +0000
committerThialfihar <thialfihar@gmail.com>2010-07-27 22:41:50 +0000
commitb13eb7dbf3d342e3d63d7718c1f66b082f055540 (patch)
treef08b1b04cb7366b8b357777464d120db20e39980 /src/org/thialfihar/android/apg/EncryptActivity.java
parent20f7755b2c2395431f059ec14ddc6c1d2359e20d (diff)
downloadopen-keychain-b13eb7dbf3d342e3d63d7718c1f66b082f055540.tar.gz
open-keychain-b13eb7dbf3d342e3d63d7718c1f66b082f055540.tar.bz2
open-keychain-b13eb7dbf3d342e3d63d7718c1f66b082f055540.zip
added a "force V3 signature" setting similar to the GPG version, hopefully making APG useful for some special cases where that is needed
Update issue 39 Two new strings: <string name="section_advanced">Advanced</string> <string name="label_forceV3Signature">Force V3 Signatures</string> "V3" is just "version 3" and should remain untranslated, both strings can be seen at the bottom of the preferences activity.
Diffstat (limited to 'src/org/thialfihar/android/apg/EncryptActivity.java')
-rw-r--r--src/org/thialfihar/android/apg/EncryptActivity.java32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/org/thialfihar/android/apg/EncryptActivity.java b/src/org/thialfihar/android/apg/EncryptActivity.java
index b3b002346..e1e773216 100644
--- a/src/org/thialfihar/android/apg/EncryptActivity.java
+++ b/src/org/thialfihar/android/apg/EncryptActivity.java
@@ -619,16 +619,15 @@ public class EncryptActivity extends BaseActivity {
String error = null;
Bundle data = new Bundle();
Message msg = new Message();
- fillDataSource();
- fillDataDestination();
+
try {
InputData in;
OutputStream out;
boolean useAsciiArmour = true;
long encryptionKeyIds[] = null;
long signatureKeyId = 0;
- boolean signOnly = false;
int compressionId = 0;
+ boolean signOnly = false;
String passPhrase = null;
if (mMode.getCurrentView().getId() == R.id.modeSymmetric) {
@@ -642,6 +641,9 @@ public class EncryptActivity extends BaseActivity {
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
}
+ fillDataSource(signOnly && !mReturnResult);
+ fillDataDestination();
+
// streams
in = mDataSource.getInputData(this, true);
out = mDataDestination.getOutputStream(this);
@@ -661,14 +663,18 @@ public class EncryptActivity extends BaseActivity {
if (signOnly) {
Apg.signText(this, in, out, getSecretKeyId(),
Apg.getCachedPassPhrase(getSecretKeyId()),
- mPreferences.getDefaultHashAlgorithm(), this);
+ mPreferences.getDefaultHashAlgorithm(),
+ mPreferences.getForceV3Signatures(),
+ this);
} else {
Apg.encrypt(this, in, out, useAsciiArmour,
encryptionKeyIds, signatureKeyId,
Apg.getCachedPassPhrase(signatureKeyId), this,
mPreferences.getDefaultEncryptionAlgorithm(),
mPreferences.getDefaultHashAlgorithm(),
- compressionId, passPhrase);
+ compressionId,
+ mPreferences.getForceV3Signatures(),
+ passPhrase);
}
out.close();
@@ -930,7 +936,7 @@ public class EncryptActivity extends BaseActivity {
return super.onCreateDialog(id);
}
- protected void fillDataSource() {
+ protected void fillDataSource(boolean fixContent) {
mDataSource = new DataSource();
if (mContentUri != null) {
mDataSource.setUri(mContentUri);
@@ -940,7 +946,19 @@ public class EncryptActivity extends BaseActivity {
if (mData != null) {
mDataSource.setData(mData);
} else {
- mDataSource.setText(mMessage.getText().toString());
+ String message = mMessage.getText().toString();
+ if (fixContent) {
+ // fix the message a bit, trailing spaces and newlines break stuff,
+ // because GMail sends as HTML and such things fuck up the
+ // signature,
+ // TODO: things like "<" and ">" also fuck up the signature
+ message = message.replaceAll(" +\n", "\n");
+ message = message.replaceAll("\n\n+", "\n\n");
+ message = message.replaceFirst("^\n+", "");
+ // make sure there'll be exactly one newline at the end
+ message = message.replaceFirst("\n*$", "\n");
+ }
+ mDataSource.setText(message);
}
}
}