diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index d7e4a13990..fd57b0ad0e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4058,6 +4058,42 @@ public class FragmentCompose extends FragmentBase { if (TextUtils.isEmpty(draft.subject)) args.putBoolean("remind_subject", true); + if (pgpService.isBound() && + !EntityMessage.PGP_SIGNENCRYPT.equals(draft.ui_encrypt)) { + List
recipients = new ArrayList<>(); + if (draft.from != null) + recipients.addAll(Arrays.asList(draft.from)); + if (draft.to != null) + recipients.addAll(Arrays.asList(draft.to)); + if (draft.cc != null) + recipients.addAll(Arrays.asList(draft.cc)); + if (draft.bcc != null) + recipients.addAll(Arrays.asList(draft.bcc)); + + if (recipients.size() > 0) { + String[] userIds = new String[recipients.size()]; + for (int i = 0; i < recipients.size(); i++) { + InternetAddress recipient = (InternetAddress) recipients.get(i); + userIds[i] = recipient.getAddress().toLowerCase(); + } + + Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY_IDS); + intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, userIds); + + try { + OpenPgpApi api = new OpenPgpApi(context, pgpService.getService()); + Intent result = api.executeApi(intent, (InputStream) null, (OutputStream) null); + int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + if (resultCode == OpenPgpApi.RESULT_CODE_SUCCESS) { + long[] keyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + args.putBoolean("remind_pgp", keyIds.length > 0); + } + } catch (Throwable ex) { + Log.w(ex); + } + } + } + Document d = JsoupEx.parse(body); if (empty && d.select("div[fairemail=reference]").isEmpty()) @@ -4234,6 +4270,7 @@ public class FragmentCompose extends FragmentBase { boolean remind_to = args.getBoolean("remind_to", false); boolean remind_extra = args.getBoolean("remind_extra", false); boolean remind_subject = args.getBoolean("remind_subject", false); + boolean remind_pgp = args.getBoolean("remind_pgp", false); boolean remind_text = args.getBoolean("remind_text", false); boolean remind_attachment = args.getBoolean("remind_attachment", false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); @@ -4243,7 +4280,7 @@ public class FragmentCompose extends FragmentBase { (draft.cc == null ? 0 : draft.cc.length) + (draft.bcc == null ? 0 : draft.bcc.length); if (dialog || (send_reminders && - (remind_to || remind_extra || remind_subject || remind_text || remind_attachment || + (remind_to || remind_extra || remind_subject || remind_pgp || remind_text || remind_attachment || recipients > RECIPIENTS_WARNING))) { setBusy(false); @@ -4780,6 +4817,7 @@ public class FragmentCompose extends FragmentBase { boolean remind_to = args.getBoolean("remind_to", false); boolean remind_extra = args.getBoolean("remind_extra", false); boolean remind_subject = args.getBoolean("remind_subject", false); + boolean remind_pgp = args.getBoolean("remind_pgp", false); boolean remind_text = args.getBoolean("remind_text", false); boolean remind_attachment = args.getBoolean("remind_attachment", false); @@ -4793,6 +4831,7 @@ public class FragmentCompose extends FragmentBase { final ViewGroup dview = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.dialog_send, null); final TextView tvRemindTo = dview.findViewById(R.id.tvRemindTo); + final TextView tvRemindPgp = dview.findViewById(R.id.tvRemindPgp); final TextView tvRemindExtra = dview.findViewById(R.id.tvRemindExtra); final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject); final TextView tvRemindText = dview.findViewById(R.id.tvRemindText); @@ -4810,6 +4849,7 @@ public class FragmentCompose extends FragmentBase { final TextView tvNotAgain = dview.findViewById(R.id.tvNotAgain); tvRemindTo.setVisibility(remind_to ? View.VISIBLE : View.GONE); + tvRemindPgp.setVisibility(remind_pgp ? View.VISIBLE : View.GONE); tvRemindExtra.setVisibility(remind_extra ? View.VISIBLE : View.GONE); tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE); tvRemindText.setVisibility(remind_text ? View.VISIBLE : View.GONE); diff --git a/app/src/main/res/layout/dialog_send.xml b/app/src/main/res/layout/dialog_send.xml index 10468aa054..7788dcb1fd 100644 --- a/app/src/main/res/layout/dialog_send.xml +++ b/app/src/main/res/layout/dialog_send.xml @@ -30,6 +30,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvMessage" /> + + + app:layout_constraintTop_toBottomOf="@id/tvRemindPgp" /> Sender missing Username missing Recipient missing + PGP keys available Subject is empty Message is empty attached,attachment,attachments,included