Browse Source

Added spam menu

main
M66B 6 years ago
parent
commit
fdc868e7b3
2 changed files with 51 additions and 4 deletions
  1. +48
    -4
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +3
    -0
      app/src/main/res/menu/menu_message.xml

+ 48
- 4
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -796,6 +796,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
@Override @Override
public boolean onMenuItemClick(MenuItem target) { public boolean onMenuItemClick(MenuItem target) {
switch (target.getItemId()) { switch (target.getItemId()) {
case R.id.menu_junk:
onJunk(data);
return true;
case R.id.menu_forward: case R.id.menu_forward:
onForward(data); onForward(data);
return true; return true;
@ -1020,6 +1023,51 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
}); });
} }
private void onJunk(final ActionData data) {
new DialogBuilderLifecycle(context, owner)
.setMessage(R.string.title_ask_spam)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle args = new Bundle();
args.putLong("id", data.message.id);
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
db.message().setMessageUiHide(id, true);
EntityMessage message = db.message().getMessage(id);
EntityFolder spam = db.folder().getFolderByType(message.account, EntityFolder.JUNK);
EntityOperation.queue(db, message, EntityOperation.MOVE, spam.id);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
EntityOperation.process(context);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, ex);
}
}.load(context, owner, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private void onDelete(final ActionData data) { private void onDelete(final ActionData data) {
if (data.delete) { if (data.delete) {
// No trash or is trash // No trash or is trash
@ -1141,10 +1189,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
} }
}); });
EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK);
if (junk != null && !message.folder.equals(junk.id))
folders.add(0, junk);
EntityFolder sent = db.folder().getFolderByType(message.account, EntityFolder.SENT); EntityFolder sent = db.folder().getFolderByType(message.account, EntityFolder.SENT);
if (sent != null && !message.folder.equals(sent.id)) if (sent != null && !message.folder.equals(sent.id))
folders.add(0, sent); folders.add(0, sent);


+ 3
- 0
app/src/main/res/menu/menu_message.xml View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_junk"
android:title="@string/title_spam" />
<item <item
android:id="@+id/menu_forward" android:id="@+id/menu_forward"


Loading…
Cancel
Save