aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-08-10 20:44:02 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-08-10 20:44:02 +0200
commitb0821a3ddd56ebcd16b5e1b0de098cb90cab4c79 (patch)
treea99ad1b7009cbc6630bbba1d533b907a8b53eaaa /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
parent1abae04cda368409b54c7b3d0b3b8401040ef39e (diff)
downloadopen-keychain-b0821a3ddd56ebcd16b5e1b0de098cb90cab4c79.tar.gz
open-keychain-b0821a3ddd56ebcd16b5e1b0de098cb90cab4c79.tar.bz2
open-keychain-b0821a3ddd56ebcd16b5e1b0de098cb90cab4c79.zip
Introduction of metadata api, starting to fix decryption progress
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
index d8bf0d4d9..b42e832fa 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
@@ -357,6 +357,7 @@ public class PgpSignEncrypt {
BCPGOutputStream bcpgOut;
if (enableEncryption) {
/* actual encryption */
+ updateProgress(R.string.progress_encrypting, 20, 100);
encryptionOut = cPk.open(out, new byte[1 << 16]);
@@ -379,27 +380,26 @@ public class PgpSignEncrypt {
// file name not needed, so empty string
pOut = literalGen.open(bcpgOut, PGPLiteralData.BINARY, "", new Date(),
new byte[1 << 16]);
- updateProgress(R.string.progress_encrypting, 20, 100);
- long progress = 0;
- int n;
+ long alreadyWritten = 0;
+ int length;
byte[] buffer = new byte[1 << 16];
InputStream in = mData.getInputStream();
- while ((n = in.read(buffer)) > 0) {
- pOut.write(buffer, 0, n);
+ while ((length = in.read(buffer)) > 0) {
+ pOut.write(buffer, 0, length);
// update signature buffer if signature is requested
if (enableSignature) {
if (mSignatureForceV3) {
- signatureV3Generator.update(buffer, 0, n);
+ signatureV3Generator.update(buffer, 0, length);
} else {
- signatureGenerator.update(buffer, 0, n);
+ signatureGenerator.update(buffer, 0, length);
}
}
- progress += n;
+ alreadyWritten += length;
if (mData.getSize() != 0) {
- updateProgress((int) (20 + (95 - 20) * progress / mData.getSize()), 100);
+ updateProgress((int) (20 + (95 - 20) * alreadyWritten / mData.getSize()), 100);
}
}