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();
|
compressGen.close();
|
||||||
encryptOut.close();
|
encryptOut.close();
|
||||||
out.close();
|
if (armored) {
|
||||||
|
armorOut.close();
|
||||||
|
}
|
||||||
|
|
||||||
progress.setProgress("done.", 100, 100);
|
progress.setProgress("done.", 100, 100);
|
||||||
}
|
}
|
||||||
|
@ -1625,8 +1627,6 @@ public class Apg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
if (signature != null) {
|
if (signature != null) {
|
||||||
progress.setProgress("verifying signature...", 80, 100);
|
progress.setProgress("verifying signature...", 80, 100);
|
||||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||||
|
|
|
@ -186,6 +186,8 @@ public class DecryptFileActivity extends BaseActivity {
|
||||||
OutputStream out = new FileOutputStream(mOutputFilename);
|
OutputStream out = new FileOutputStream(mOutputFilename);
|
||||||
|
|
||||||
data = Apg.decrypt(in, out, Apg.getPassPhrase(), this, mAssumeSymmetricEncryption);
|
data = Apg.decrypt(in, out, Apg.getPassPhrase(), this, mAssumeSymmetricEncryption);
|
||||||
|
|
||||||
|
out.close();
|
||||||
} catch (PGPException e) {
|
} catch (PGPException e) {
|
||||||
error = e.getMessage();
|
error = e.getMessage();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -85,6 +84,13 @@ public class EncryptFileActivity extends BaseActivity {
|
||||||
|
|
||||||
mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
|
mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
|
||||||
mAsciiArmour.setChecked(getDefaultAsciiArmour());
|
mAsciiArmour.setChecked(getDefaultAsciiArmour());
|
||||||
|
mAsciiArmour.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
guessOutputFilename();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// asymmetric tab
|
// asymmetric tab
|
||||||
mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys);
|
mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys);
|
||||||
|
@ -254,13 +260,17 @@ public class EncryptFileActivity extends BaseActivity {
|
||||||
startActivityForResult(intent, Id.request.public_keys);
|
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() {
|
private void encryptClicked() {
|
||||||
String currentFilename = mFilename.getText().toString();
|
String currentFilename = mFilename.getText().toString();
|
||||||
if (mInputFilename == null || !mInputFilename.equals(currentFilename)) {
|
if (mInputFilename == null || !mInputFilename.equals(currentFilename)) {
|
||||||
mInputFilename = mFilename.getText().toString();
|
guessOutputFilename();
|
||||||
File file = new File(mInputFilename);
|
|
||||||
String ending = (mAsciiArmour.isChecked() ? ".asc" : ".gpg");
|
|
||||||
mOutputFilename = Constants.path.app_dir + "/" + file.getName() + ending;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInputFilename.equals("")) {
|
if (mInputFilename.equals("")) {
|
||||||
|
|
|
@ -206,6 +206,8 @@ public class EncryptMessageActivity extends BaseActivity {
|
||||||
Apg.signText(in, out, getSecretKeyId(),
|
Apg.signText(in, out, getSecretKeyId(),
|
||||||
Apg.getPassPhrase(), getDefaultHashAlgorithm(), this);
|
Apg.getPassPhrase(), getDefaultHashAlgorithm(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out.close();
|
||||||
data.putString("message", new String(out.toByteArray()));
|
data.putString("message", new String(out.toByteArray()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
error = e.getMessage();
|
error = e.getMessage();
|
||||||
|
|
Loading…
Reference in a new issue