Fixed reloading draft text

pull/156/head
M66B 5 years ago
parent 709506deb2
commit 376e4ff344

@ -197,6 +197,7 @@ public class FragmentCompose extends FragmentBase {
private boolean show_images = false; private boolean show_images = false;
private boolean autosave = false; private boolean autosave = false;
private boolean busy = false; private boolean busy = false;
private Uri photoURI = null; private Uri photoURI = null;
private OpenPgpServiceConnection pgpService; private OpenPgpServiceConnection pgpService;
@ -652,6 +653,8 @@ public class FragmentCompose extends FragmentBase {
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
state = State.NONE;
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (working < 0) { if (working < 0) {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -707,7 +710,7 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public void onPause() { public void onPause() {
if (autosave) if (autosave && state == State.LOADED)
onAction(R.id.action_save); onAction(R.id.action_save);
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
@ -2453,7 +2456,7 @@ public class FragmentCompose extends FragmentBase {
if (draft == null || draft.ui_hide) if (draft == null || draft.ui_hide)
throw new MessageRemovedException("Draft for action was deleted hide=" + (draft != null)); throw new MessageRemovedException("Draft for action was deleted hide=" + (draft != null));
Log.i("Load action id=" + draft.id + " action=" + action); Log.i("Load action id=" + draft.id + " action=" + getActionName(action));
// Move draft to new account // Move draft to new account
if (draft.account != aid && aid >= 0) { if (draft.account != aid && aid >= 0) {
@ -2742,7 +2745,7 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
protected void onExecuted(Bundle args, EntityMessage draft) { protected void onExecuted(Bundle args, EntityMessage draft) {
int action = args.getInt("action"); int action = args.getInt("action");
Log.i("Loaded action id=" + (draft == null ? null : draft.id) + " action=" + action); Log.i("Loaded action id=" + (draft == null ? null : draft.id) + " action=" + getActionName(action));
etTo.setText(MessageHelper.formatAddressesCompose(draft.to)); etTo.setText(MessageHelper.formatAddressesCompose(draft.to));
etCc.setText(MessageHelper.formatAddressesCompose(draft.cc)); etCc.setText(MessageHelper.formatAddressesCompose(draft.cc));
@ -2779,6 +2782,25 @@ public class FragmentCompose extends FragmentBase {
else else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} }
String getActionName(int id) {
switch (id) {
case R.id.action_delete:
return "delete";
case R.id.action_undo:
return "undo";
case R.id.action_redo:
return "redo";
case R.id.action_save:
return "save";
case R.id.menu_encrypt:
return "encrypt";
case R.id.action_send:
return "send";
default:
return Integer.toString(id);
}
}
}; };
private void checkDraft(long id) { private void checkDraft(long id) {

Loading…
Cancel
Save