From 974a73b07d4386767b8ef8a71b5cff5fa63ef8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:11:19 +0100 Subject: [PATCH] Use new account extra to allow multiple accounts --- src/com/fsck/k9/activity/MessageCompose.java | 7 ++++++- src/com/fsck/k9/view/MessageOpenPgpView.java | 12 ++++++++++-- src/com/fsck/k9/view/SingleMessageView.java | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index 97da7de73..e8134ba41 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -2003,7 +2003,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, private void executeOpenPgpMethod(Intent intent) { intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); - + // this follows user id format of OpenPGP to allow key generation based on it + // includes account number to make it unique + String accName = mAccount.getName() + " (" + mAccount.getAccountNumber() + ") <" + + mAccount.getEmail() + ">"; + intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accName); + final InputStream is = getOpenPgpInputStream(); final ByteArrayOutputStream os = new ByteArrayOutputStream(); diff --git a/src/com/fsck/k9/view/MessageOpenPgpView.java b/src/com/fsck/k9/view/MessageOpenPgpView.java index a728cd3cf..356e54a7d 100644 --- a/src/com/fsck/k9/view/MessageOpenPgpView.java +++ b/src/com/fsck/k9/view/MessageOpenPgpView.java @@ -28,6 +28,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.crypto.CryptoHelper; @@ -60,6 +61,7 @@ public class MessageOpenPgpView extends LinearLayout { private static final int REQUEST_CODE_DECRYPT_VERIFY = 12; String mData; + Account mAccount; public MessageOpenPgpView(Context context, AttributeSet attrs) { super(context, attrs); @@ -90,12 +92,13 @@ public class MessageOpenPgpView extends LinearLayout { * Fill the decrypt layout with signature data, if known, make controls * visible, if they should be visible. */ - public void updateLayout(String openPgpProvider, String decryptedData, + public void updateLayout(Account account, String decryptedData, final OpenPgpSignatureResult signatureResult, final Message message) { // set class variables - mOpenPgpProvider = openPgpProvider; + mAccount = account; + mOpenPgpProvider = mAccount.getOpenPgpProvider(); mDecryptedData = decryptedData; mMessage = message; @@ -263,6 +266,11 @@ public class MessageOpenPgpView extends LinearLayout { private void decryptVerify(Intent intent) { intent.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + // this follows user id format of OpenPGP to allow key generation based on it + // includes account number to make it unique + String accName = mAccount.getName() + " (" + mAccount.getAccountNumber() + ") <" + + mAccount.getEmail() + ">"; + intent.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, accName); InputStream is = null; try { diff --git a/src/com/fsck/k9/view/SingleMessageView.java b/src/com/fsck/k9/view/SingleMessageView.java index 9092ee645..492db924e 100644 --- a/src/com/fsck/k9/view/SingleMessageView.java +++ b/src/com/fsck/k9/view/SingleMessageView.java @@ -620,7 +620,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, if (text != null) { loadBodyFromText(text); updateCryptoLayout(account.getCryptoProvider(), pgpData, message); - mOpenPgpView.updateLayout(account.getOpenPgpProvider(),pgpData.getDecryptedData(), + mOpenPgpView.updateLayout(account, pgpData.getDecryptedData(), pgpData.getSignatureResult(), message); } else { showStatusMessage(getContext().getString(R.string.webview_empty_message));