Swap spam/trash button

pull/30/head
M66B 6 years ago
parent 194b7e8dea
commit 8a309c6198

@ -198,12 +198,12 @@ public class FragmentMessage extends FragmentEx {
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_trash:
onActionDelete(id);
return true;
case R.id.action_spam: case R.id.action_spam:
onActionSpam(id); onActionSpam(id);
return true; return true;
case R.id.action_trash:
onActionDelete(id);
return true;
case R.id.action_move: case R.id.action_move:
onActionMove(id); onActionMove(id);
return true; return true;
@ -333,8 +333,8 @@ public class FragmentMessage extends FragmentEx {
top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!outbox && message.cc != null); top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!outbox && message.cc != null);
top_navigation.setVisibility(View.VISIBLE); top_navigation.setVisibility(View.VISIBLE);
bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!outbox && !trash && hasTrash);
bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(!outbox && !junk && hasJunk); bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(!outbox && !junk && hasJunk);
bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!outbox && !trash && hasTrash);
bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(!outbox && (!inbox || hasUser)); bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(!outbox && (!inbox || hasUser));
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(!outbox && !archive && hasArchive); bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(!outbox && !archive && hasArchive);
bottom_navigation.getMenu().findItem(R.id.action_reply).setVisible(!outbox); bottom_navigation.getMenu().findItem(R.id.action_reply).setVisible(!outbox);
@ -439,6 +439,35 @@ public class FragmentMessage extends FragmentEx {
.putExtra("action", "reply_all")); .putExtra("action", "reply_all"));
} }
private void onActionSpam(final long id) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
.setMessage(R.string.title_ask_spam)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB db = DB.getInstance(getContext());
EntityMessage message = db.message().getMessage(id);
message.ui_hide = true;
db.message().updateMessage(message);
EntityFolder spam = db.folder().getFolderByType(message.account, EntityFolder.TYPE_JUNK);
EntityOperation.queue(getContext(), message, EntityOperation.MOVE, spam.id);
EntityOperation.process(getContext());
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
});
}
})
.setNegativeButton(android.R.string.cancel, null).show();
}
private void onActionDelete(final long id) { private void onActionDelete(final long id) {
String folderType = (String) bottom_navigation.getTag(); String folderType = (String) bottom_navigation.getTag();
if (EntityFolder.TYPE_TRASH.equals(folderType)) { if (EntityFolder.TYPE_TRASH.equals(folderType)) {
@ -488,35 +517,6 @@ public class FragmentMessage extends FragmentEx {
} }
} }
private void onActionSpam(final long id) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
.setMessage(R.string.title_ask_spam)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB db = DB.getInstance(getContext());
EntityMessage message = db.message().getMessage(id);
message.ui_hide = true;
db.message().updateMessage(message);
EntityFolder spam = db.folder().getFolderByType(message.account, EntityFolder.TYPE_JUNK);
EntityOperation.queue(getContext(), message, EntityOperation.MOVE, spam.id);
EntityOperation.process(getContext());
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
});
}
})
.setNegativeButton(android.R.string.cancel, null).show();
}
private void onActionMove(final long id) { private void onActionMove(final long id) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);

@ -2,18 +2,18 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_trash"
android:icon="@drawable/baseline_delete_24"
android:title="@string/title_trash"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_spam" android:id="@+id/action_spam"
android:icon="@drawable/baseline_report_24" android:icon="@drawable/baseline_report_24"
android:title="@string/title_spam" android:title="@string/title_spam"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/action_trash"
android:icon="@drawable/baseline_delete_24"
android:title="@string/title_trash"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_move" android:id="@+id/action_move"
android:icon="@drawable/baseline_folder_24" android:icon="@drawable/baseline_folder_24"

Loading…
Cancel
Save