Browse Source

Allow deleting sent messages

main
M66B 6 years ago
parent
commit
710b72b5e8
2 changed files with 13 additions and 4 deletions
  1. +10
    -4
      app/src/main/java/eu/faircode/email/AdapterFolder.java
  2. +3
    -0
      app/src/main/java/eu/faircode/email/DaoMessage.java

+ 10
- 4
app/src/main/java/eu/faircode/email/AdapterFolder.java View File

@ -166,10 +166,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
popupMenu.getMenu().add(Menu.NONE, action_sync, 1, R.string.title_synchronize_now);
popupMenu.getMenu().findItem(action_sync).setEnabled("connected".equals(accountState));
if (folder.account != null) {
popupMenu.getMenu().add(Menu.NONE, action_delete, 2, R.string.title_delete_local);
popupMenu.getMenu().add(Menu.NONE, action_delete, 2, R.string.title_delete_local);
if (folder.account != null)
popupMenu.getMenu().add(Menu.NONE, action_edit, 3, R.string.title_edit_properties);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@ -192,12 +192,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
case action_delete:
Bundle args = new Bundle();
args.putLong("id", folder.id);
args.putBoolean("outbox", folder.account == null);
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id");
DB.getInstance(context).message().deleteMessages(id);
boolean outbox = args.getBoolean("outbox");
Log.i(Helper.TAG, "Delete local messages outbox=" + outbox);
if (outbox)
DB.getInstance(context).message().deleteSeenMessages(id);
else
DB.getInstance(context).message().deleteMessages(id);
return null;
}


+ 3
- 0
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -192,6 +192,9 @@ public interface DaoMessage {
@Query("DELETE FROM message WHERE folder = :folder")
int deleteMessages(long folder);
@Query("DELETE FROM message WHERE folder = :folder AND seen")
int deleteSeenMessages(long folder);
@Query("DELETE FROM message WHERE folder = :folder AND received < :received AND NOT uid IS NULL")
int deleteMessagesBefore(long folder, long received);


Loading…
Cancel
Save