diff options
author | Thialfihar <thialfihar@gmail.com> | 2011-03-19 18:23:54 +0000 |
---|---|---|
committer | Thialfihar <thialfihar@gmail.com> | 2011-03-19 18:23:54 +0000 |
commit | 3a22ac4197ec3190e359851b1c42259bbdd7522f (patch) | |
tree | 87b73f32b02f4f8109e8c5eab0e57c246d743c7d /src | |
parent | 4e37568eab3d6158a8d0a299a6090942c2bd469e (diff) | |
download | open-keychain-3a22ac4197ec3190e359851b1c42259bbdd7522f.tar.gz open-keychain-3a22ac4197ec3190e359851b1c42259bbdd7522f.tar.bz2 open-keychain-3a22ac4197ec3190e359851b1c42259bbdd7522f.zip |
applied proposed patch by mattispasch for issue 99
Diffstat (limited to 'src')
-rw-r--r-- | src/org/thialfihar/android/apg/EncryptActivity.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/org/thialfihar/android/apg/EncryptActivity.java b/src/org/thialfihar/android/apg/EncryptActivity.java index 29af975bf..9ba71f570 100644 --- a/src/org/thialfihar/android/apg/EncryptActivity.java +++ b/src/org/thialfihar/android/apg/EncryptActivity.java @@ -18,6 +18,7 @@ package org.thialfihar.android.apg; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.security.NoSuchAlgorithmException; @@ -30,6 +31,7 @@ import org.bouncycastle2.openpgp.PGPPublicKey; import org.bouncycastle2.openpgp.PGPPublicKeyRing; import org.bouncycastle2.openpgp.PGPSecretKey; import org.bouncycastle2.openpgp.PGPSecretKeyRing; +import org.thialfihar.android.apg.provider.DataProvider; import org.thialfihar.android.apg.utils.Choice; import android.app.Dialog; @@ -699,21 +701,30 @@ public class EncryptActivity extends BaseActivity { out.close(); if (mEncryptTarget != Id.target.file) { - if (useAsciiArmour) { - String extraData = new String(((ByteArrayOutputStream)out).toByteArray()); - if (mGenerateSignature) { - data.putString(Apg.EXTRA_SIGNATURE_TEXT, extraData); - } else { - data.putString(Apg.EXTRA_ENCRYPTED_MESSAGE, extraData); - } - } else { - byte extraData[] = ((ByteArrayOutputStream)out).toByteArray(); - if (mGenerateSignature) { - data.putByteArray(Apg.EXTRA_SIGNATURE_DATA, extraData); - } else { - data.putByteArray(Apg.EXTRA_ENCRYPTED_DATA, extraData); - } - } + + if(out instanceof ByteArrayOutputStream) { + if (useAsciiArmour) { + String extraData = new String(((ByteArrayOutputStream)out).toByteArray()); + if (mGenerateSignature) { + data.putString(Apg.EXTRA_SIGNATURE_TEXT, extraData); + } else { + data.putString(Apg.EXTRA_ENCRYPTED_MESSAGE, extraData); + } + } else { + byte extraData[] = ((ByteArrayOutputStream)out).toByteArray(); + if (mGenerateSignature) { + data.putByteArray(Apg.EXTRA_SIGNATURE_DATA, extraData); + } else { + data.putByteArray(Apg.EXTRA_ENCRYPTED_DATA, extraData); + } + } + } else if(out instanceof FileOutputStream) { + String fileName = mDataDestination.getStreamFilename(); + String uri = "content://" + DataProvider.AUTHORITY + "/data/" + fileName; + data.putString(Apg.EXTRA_RESULT_URI, uri); + } else { + throw new Apg.GeneralException("No output-data found."); + } } } catch (IOException e) { error = "" + e; |