Small behavior improvements

This commit is contained in:
M66B 2019-09-10 10:06:32 +02:00
parent b0d07fe623
commit 9c8129d223
1 changed files with 47 additions and 7 deletions

View File

@ -739,7 +739,6 @@ public class FragmentCompose extends FragmentBase {
private void onReferenceImages() { private void onReferenceImages() {
show_images = true; show_images = true;
onAction(R.id.action_save);
showDraft(working); showDraft(working);
} }
@ -1027,13 +1026,55 @@ public class FragmentCompose extends FragmentBase {
private void onMenuPlainOnly() { private void onMenuPlainOnly() {
plain_only = !plain_only; plain_only = !plain_only;
getActivity().invalidateOptionsMenu(); getActivity().invalidateOptionsMenu();
onAction(R.id.action_save);
Bundle args = new Bundle();
args.putLong("id", working);
args.putBoolean("plain_only", plain_only);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean plain_only = args.getBoolean("plain_only");
DB db = DB.getInstance(context);
db.message().setMessagePlainOnly(id, plain_only);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getFragmentManager(), ex);
}
}.execute(this, args, "compose:plain_only");
} }
private void onMenuEncrypt() { private void onMenuEncrypt() {
encrypt = !encrypt; encrypt = !encrypt;
getActivity().invalidateOptionsMenu(); getActivity().invalidateOptionsMenu();
onAction(R.id.action_save);
Bundle args = new Bundle();
args.putLong("id", working);
args.putBoolean("encrypt", encrypt);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean encrypt = args.getBoolean("encrypt");
DB db = DB.getInstance(context);
db.message().setMessageEncrypt(id, encrypt);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getFragmentManager(), ex);
}
}.execute(this, args, "compose:encrypt");
} }
private void onMenuSendAfter() { private void onMenuSendAfter() {
@ -1410,6 +1451,7 @@ public class FragmentCompose extends FragmentBase {
etBody.setText(HtmlHelper.fromHtml(html, cidGetter, null)); etBody.setText(HtmlHelper.fromHtml(html, cidGetter, null));
} }
// Save text & update remote draft
onAction(R.id.action_save); onAction(R.id.action_save);
} }
@ -2515,16 +2557,14 @@ public class FragmentCompose extends FragmentBase {
for (EntityAttachment attachment : attachments) { for (EntityAttachment attachment : attachments) {
if (attachment.available) if (attachment.available)
available++; available++;
if (attachment.progress != null) { if (attachment.progress != null)
downloading = true; downloading = true;
break;
}
} }
Log.i("Attachments=" + attachments.size() + Log.i("Attachments=" + attachments.size() +
" available=" + available + " downloading=" + downloading); " available=" + available + " downloading=" + downloading);
// Attachment deleted // Attachment deleted: update remote draft
if (available < last_available) if (available < last_available)
onAction(R.id.action_save); onAction(R.id.action_save);