applied proposed patch by mattispasch for issue 99

This commit is contained in:
Thialfihar 2011-03-19 18:23:54 +00:00
parent 4e37568eab
commit 3a22ac4197

View File

@ -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,6 +701,8 @@ public class EncryptActivity extends BaseActivity {
out.close();
if (mEncryptTarget != Id.target.file) {
if(out instanceof ByteArrayOutputStream) {
if (useAsciiArmour) {
String extraData = new String(((ByteArrayOutputStream)out).toByteArray());
if (mGenerateSignature) {
@ -714,6 +718,13 @@ public class EncryptActivity extends BaseActivity {
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;