diff --git a/app/src/main/java/eu/faircode/email/FragmentAnswer.java b/app/src/main/java/eu/faircode/email/FragmentAnswer.java index 8c2947aa45..db735e0eff 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAnswer.java +++ b/app/src/main/java/eu/faircode/email/FragmentAnswer.java @@ -185,15 +185,16 @@ public class FragmentAnswer extends FragmentBase { @Override protected void onExecuted(Bundle args, EntityAnswer answer) { if (savedInstanceState == null) { - etName.setText(answer == null ? null : answer.name); + etName.setText(answer == null ? getArguments().getString("subject") : answer.name); etGroup.setText(answer == null ? null : answer.group); cbStandard.setChecked(answer == null ? false : answer.standard); cbFavorite.setChecked(answer == null ? false : answer.favorite); cbHide.setChecked(answer == null ? false : answer.hide); - if (answer == null) + String html = (answer == null ? getArguments().getString("html") : answer.text); + if (html == null) etText.setText(null); else - etText.setText(HtmlHelper.fromHtml(answer.text, new Html.ImageGetter() { + etText.setText(HtmlHelper.fromHtml(html, new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { if (source != null && source.startsWith("cid:")) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 8f0857e2ee..f15c41387f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1328,7 +1328,8 @@ public class FragmentCompose extends FragmentBase { menu.findItem(R.id.menu_compact).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_contact_group).setEnabled( state == State.LOADED && hasPermission(Manifest.permission.READ_CONTACTS)); - menu.findItem(R.id.menu_answer).setEnabled(state == State.LOADED); + menu.findItem(R.id.menu_answer_insert).setEnabled(state == State.LOADED); + menu.findItem(R.id.menu_answer_create).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_clear).setEnabled(state == State.LOADED); int colorEncrypt = Helper.resolveColor(getContext(), R.attr.colorEncrypt); @@ -1412,8 +1413,11 @@ public class FragmentCompose extends FragmentBase { } else if (itemId == R.id.menu_contact_group) { onMenuContactGroup(); return true; - } else if (itemId == R.id.menu_answer) { - onMenuAnswer(); + } else if (itemId == R.id.menu_answer_insert) { + onMenuAnswerInsert(); + return true; + } else if (itemId == R.id.menu_answer_create) { + onMenuAnswerCreate(); return true; } else if (itemId == R.id.menu_clear) { StyleHelper.apply(R.id.menu_clear, getViewLifecycleOwner(), null, etBody); @@ -1595,7 +1599,7 @@ public class FragmentCompose extends FragmentBase { fragment.show(getParentFragmentManager(), "compose:groups"); } - private void onMenuAnswer() { + private void onMenuAnswerInsert() { new SimpleTask>() { @Override protected List onExecute(Context context, Bundle args) { @@ -1704,6 +1708,18 @@ public class FragmentCompose extends FragmentBase { }.execute(getContext(), getViewLifecycleOwner(), new Bundle(), "compose:answer"); } + private void onMenuAnswerCreate() { + Bundle args = new Bundle(); + args.putString("subject", etSubject.getText().toString()); + args.putString("html", HtmlHelper.toHtml(etBody.getText(), getContext())); + + FragmentAnswer fragment = new FragmentAnswer(); + fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getParentFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("compose:answer"); + fragmentTransaction.commit(); + } + private boolean onActionStyle(int action, View anchor) { Log.i("Style action=" + action); return StyleHelper.apply(action, getViewLifecycleOwner(), anchor, etBody); diff --git a/app/src/main/res/menu/menu_compose.xml b/app/src/main/res/menu/menu_compose.xml index 08368b9b2e..d7087ecb29 100644 --- a/app/src/main/res/menu/menu_compose.xml +++ b/app/src/main/res/menu/menu_compose.xml @@ -55,12 +55,19 @@ + + + + Media toolbar Insert contact group Insert template + Create template Edit as plain text Edit as reformatted text Select public key