diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index 1220cdd19..fec568e6b 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -1684,25 +1684,20 @@ public class Apg { progress.setProgress("reading data...", 0, 100); - // mostly taken from CLearSignedFileProcessor + // mostly taken from ClearSignedFileProcessor ByteArrayOutputStream lineOut = new ByteArrayOutputStream(); int lookAhead = readInputLine(lineOut, aIn); byte[] lineSep = getLineSeparator(); - if (lookAhead != -1 && aIn.isClearText()) - { - byte[] line = lineOut.toByteArray(); + byte[] line = lineOut.toByteArray(); + out.write(line, 0, getLengthWithoutSeparator(line)); + out.write(lineSep); + + while (lookAhead != -1 && aIn.isClearText()) { + lookAhead = readInputLine(lineOut, lookAhead, aIn); + line = lineOut.toByteArray(); out.write(line, 0, getLengthWithoutSeparator(line)); out.write(lineSep); - - while (lookAhead != -1 && aIn.isClearText()) - { - lookAhead = readInputLine(lineOut, lookAhead, aIn); - - line = lineOut.toByteArray(); - out.write(line, 0, getLengthWithoutSeparator(line)); - out.write(lineSep); - } } out.close(); diff --git a/src/org/thialfihar/android/apg/DecryptActivity.java b/src/org/thialfihar/android/apg/DecryptActivity.java index 1d3510c5a..58db77c83 100644 --- a/src/org/thialfihar/android/apg/DecryptActivity.java +++ b/src/org/thialfihar/android/apg/DecryptActivity.java @@ -41,6 +41,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Message; import android.text.ClipboardManager; +import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AnimationUtils; @@ -151,6 +152,13 @@ public class DecryptActivity extends BaseActivity { mDeleteAfter = (CheckBox) findViewById(R.id.delete_after_decryption); + // default: message source + mSource.setInAnimation(null); + mSource.setOutAnimation(null); + while (mSource.getCurrentView().getId() != R.id.source_message) { + mSource.showNext(); + } + Intent intent = getIntent(); if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) { Uri uri = intent.getData(); @@ -196,12 +204,23 @@ public class DecryptActivity extends BaseActivity { } mReplyTo = extras.getString("replyTo"); mSubject = extras.getString("subject"); + } else if (intent.getAction() != null && intent.getAction().equals(Apg.Intent.DECRYPT_FILE)) { + mSource.setInAnimation(null); + mSource.setOutAnimation(null); + while (mSource.getCurrentView().getId() != R.id.source_file) { + mSource.showNext(); + } } - if (mMessage.getText().length() == 0) { + Log.e("err?", "" + mSource.getCurrentView().getId() + " " + R.id.source_message + " " + mMessage.getText().length()); + if (mSource.getCurrentView().getId() == R.id.source_message && + mMessage.getText().length() == 0) { ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); String data = ""; Matcher matcher = Apg.PGP_MESSAGE.matcher(clip.getText()); + if (!matcher.matches()) { + matcher = Apg.PGP_SIGNED_MESSAGE.matcher(clip.getText()); + } if (matcher.matches()) { data = matcher.group(1); mMessage.setText(data); @@ -226,7 +245,8 @@ public class DecryptActivity extends BaseActivity { }); mReplyButton.setVisibility(View.INVISIBLE); - if (mMessage.getText().length() > 0) { + if (mSource.getCurrentView().getId() == R.id.source_message && + mMessage.getText().length() > 0) { mDecryptButton.performClick(); }