From 099ad0b51048fc9191a07736b3622656f09498fa Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 12 Sep 2021 11:40:20 +0200 Subject: [PATCH] Added long press to insert contact group --- FAQ.md | 1 + .../eu/faircode/email/FragmentCompose.java | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/FAQ.md b/FAQ.md index abce917b2f..796f508321 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1950,6 +1950,7 @@ but even Google's Chrome cannot handle this. * Did you know that you can long press the full screen icon to show the original message text only? * Did you know that you can long press the answer button to reply to the sender? (since version 1.1562) * Did you know that you can long press the message move button to move across accounts? (since version 1.1702) +* Did you know that you can long press the add contact button in the message composer to insert a contact group? (since version 1.1721)
diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 544d47a85d..06fcd95b56 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -521,6 +521,28 @@ public class FragmentCompose extends FragmentBase { ibCcAdd.setOnClickListener(onPick); ibBccAdd.setOnClickListener(onPick); + View.OnLongClickListener onGroup = new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + int id = view.getId(); + if (id == R.id.ibToAdd) { + onMenuContactGroup(etTo); + return true; + } else if (id == R.id.ibCcAdd) { + onMenuContactGroup(etCc); + return true; + } else if (id == R.id.ibBccAdd) { + onMenuContactGroup(etBcc); + return true; + } else + return true; + } + }; + + ibToAdd.setOnLongClickListener(onGroup); + ibCcAdd.setOnLongClickListener(onGroup); + ibBccAdd.setOnLongClickListener(onGroup); + tvPlainTextOnly.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1810,11 +1832,11 @@ public class FragmentCompose extends FragmentBase { } private void onMenuContactGroup() { - Bundle args = new Bundle(); - args.putLong("working", working); + onMenuContactGroup(view.findFocus()); + } + private void onMenuContactGroup(View v) { int focussed = 0; - View v = view.findFocus(); if (v != null) { if (v.getId() == R.id.etCc) focussed = 1; @@ -1822,6 +1844,8 @@ public class FragmentCompose extends FragmentBase { focussed = 2; } + Bundle args = new Bundle(); + args.putLong("working", working); args.putInt("focussed", focussed); Helper.hideKeyboard(view);