mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-24 07:58:50 -05:00
close streams more consistently (outside of encrypt/decrypt), force a new output filename guess if the ASCII armour checkbox state changes
This commit is contained in:
parent
e542c37eb3
commit
6b52878056
@ -1314,7 +1314,9 @@ public class Apg {
|
||||
}
|
||||
compressGen.close();
|
||||
encryptOut.close();
|
||||
out.close();
|
||||
if (armored) {
|
||||
armorOut.close();
|
||||
}
|
||||
|
||||
progress.setProgress("done.", 100, 100);
|
||||
}
|
||||
@ -1625,8 +1627,6 @@ public class Apg {
|
||||
}
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
if (signature != null) {
|
||||
progress.setProgress("verifying signature...", 80, 100);
|
||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||
|
@ -186,6 +186,8 @@ public class DecryptFileActivity extends BaseActivity {
|
||||
OutputStream out = new FileOutputStream(mOutputFilename);
|
||||
|
||||
data = Apg.decrypt(in, out, Apg.getPassPhrase(), this, mAssumeSymmetricEncryption);
|
||||
|
||||
out.close();
|
||||
} catch (PGPException e) {
|
||||
error = e.getMessage();
|
||||
} catch (IOException e) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package org.thialfihar.android.apg;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -85,6 +84,13 @@ public class EncryptFileActivity extends BaseActivity {
|
||||
|
||||
mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
|
||||
mAsciiArmour.setChecked(getDefaultAsciiArmour());
|
||||
mAsciiArmour.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
guessOutputFilename();
|
||||
}
|
||||
});
|
||||
|
||||
// asymmetric tab
|
||||
mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys);
|
||||
@ -254,13 +260,17 @@ public class EncryptFileActivity extends BaseActivity {
|
||||
startActivityForResult(intent, Id.request.public_keys);
|
||||
}
|
||||
|
||||
private void guessOutputFilename() {
|
||||
mInputFilename = mFilename.getText().toString();
|
||||
File file = new File(mInputFilename);
|
||||
String ending = (mAsciiArmour.isChecked() ? ".asc" : ".gpg");
|
||||
mOutputFilename = Constants.path.app_dir + "/" + file.getName() + ending;
|
||||
}
|
||||
|
||||
private void encryptClicked() {
|
||||
String currentFilename = mFilename.getText().toString();
|
||||
if (mInputFilename == null || !mInputFilename.equals(currentFilename)) {
|
||||
mInputFilename = mFilename.getText().toString();
|
||||
File file = new File(mInputFilename);
|
||||
String ending = (mAsciiArmour.isChecked() ? ".asc" : ".gpg");
|
||||
mOutputFilename = Constants.path.app_dir + "/" + file.getName() + ending;
|
||||
guessOutputFilename();
|
||||
}
|
||||
|
||||
if (mInputFilename.equals("")) {
|
||||
|
@ -206,6 +206,8 @@ public class EncryptMessageActivity extends BaseActivity {
|
||||
Apg.signText(in, out, getSecretKeyId(),
|
||||
Apg.getPassPhrase(), getDefaultHashAlgorithm(), this);
|
||||
}
|
||||
|
||||
out.close();
|
||||
data.putString("message", new String(out.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
error = e.getMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user