From adbebd29b05374aa5cc40f1da7e52f31816cc9fc Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 3 Feb 2020 10:48:24 +0100 Subject: [PATCH] Auto select insert contact group target --- .../java/eu/faircode/email/FragmentCompose.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index b22cb5ce62..6c53609d1f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1221,6 +1221,17 @@ public class FragmentCompose extends FragmentBase { Bundle args = new Bundle(); args.putLong("working", working); + int focussed = 0; + View v = view.findFocus(); + if (v != null) { + if (v.getId() == R.id.etCc) + focussed = 1; + else if (v.getId() == R.id.etBcc) + focussed = 2; + } + + args.putInt("focussed", focussed); + FragmentDialogContactGroup fragment = new FragmentDialogContactGroup(); fragment.setArguments(args); fragment.setTargetFragment(this, REQUEST_CONTACT_GROUP); @@ -4184,6 +4195,7 @@ public class FragmentCompose extends FragmentBase { @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final long working = getArguments().getLong("working"); + int focussed = getArguments().getInt("focussed"); View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_contact_group, null); final Spinner spGroup = dview.findViewById(R.id.spGroup); @@ -4211,6 +4223,8 @@ public class FragmentCompose extends FragmentBase { 0); spGroup.setAdapter(adapter); + spTarget.setSelection(focussed); + return new AlertDialog.Builder(getContext()) .setView(dview) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {