From b68aba25b778f9acd4f1ded11fbd432527196213 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Sep 2018 11:07:14 +0000 Subject: [PATCH] Use recipient address for encryption Fixes #43 --- .idea/misc.xml | 2 +- app/src/main/java/eu/faircode/email/FragmentCompose.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index caad359b..77d47004 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -30,7 +30,7 @@ - + diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 9d02b6a0..6997c50f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -453,13 +453,14 @@ public class FragmentCompose extends FragmentEx { if (openPgpConnection == null || !openPgpConnection.isBound()) throw new IllegalArgumentException(getString(R.string.title_no_openpgp)); - EntityIdentity identity = (EntityIdentity) spFrom.getSelectedItem(); - if (identity == null) - throw new IllegalArgumentException(getString(R.string.title_from_missing)); + String to = etTo.getText().toString(); + InternetAddress ato[] = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to)); + if (ato == null || ato.length == 0) + throw new IllegalArgumentException(getString(R.string.title_to_missing)); Intent data = new Intent(); data.setAction(OpenPgpApi.ACTION_ENCRYPT); - data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{identity.email}); + data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{ato[0].getAddress()}); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); String plain = etBody.getText().toString();