Added create template from draft

pull/194/head
M66B 4 years ago
parent 2a780b11b7
commit e13c637e50

@ -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:"))

@ -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<List<EntityAnswer>>() {
@Override
protected List<EntityAnswer> 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);

@ -55,12 +55,19 @@
</item>
<item
android:id="@+id/menu_answer"
android:id="@+id/menu_answer_insert"
android:title="@string/title_insert_template"
app:showAsAction="never">
<menu />
</item>
<item
android:id="@+id/menu_answer_create"
android:title="@string/title_create_template"
app:showAsAction="never">
<menu />
</item>
<item
android:id="@+id/menu_clear"
android:title="@string/title_style_clear"

@ -1046,6 +1046,7 @@
<string name="title_media_toolbar">Media toolbar</string>
<string name="title_insert_contact_group">Insert contact group</string>
<string name="title_insert_template">Insert template</string>
<string name="title_create_template">Create template</string>
<string name="title_edit_plain_text">Edit as plain text</string>
<string name="title_edit_formatted_text">Edit as reformatted text</string>
<string name="title_select_certificate">Select public key</string>

Loading…
Cancel
Save