mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 01:06:04 +00:00
Added PGP reminder
This commit is contained in:
parent
66b62d5077
commit
fbf421fc23
3 changed files with 54 additions and 2 deletions
|
@ -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<Address> 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);
|
||||
|
|
|
@ -30,6 +30,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvRemindPgp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_pgp_reminder"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?attr/colorWarning"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRemindTo" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvRemindExtra"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -39,7 +50,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?attr/colorWarning"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRemindTo" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRemindPgp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvRemindSubject"
|
||||
|
|
|
@ -858,6 +858,7 @@
|
|||
<string name="title_from_missing">Sender missing</string>
|
||||
<string name="title_extra_missing">Username missing</string>
|
||||
<string name="title_to_missing">Recipient missing</string>
|
||||
<string name="title_pgp_reminder">PGP keys available</string>
|
||||
<string name="title_subject_reminder">Subject is empty</string>
|
||||
<string name="title_text_reminder">Message is empty</string>
|
||||
<string name="title_attachment_keywords">attached,attachment,attachments,included</string>
|
||||
|
|
Loading…
Reference in a new issue