Browse Source

Swap spam/trash button

main
M66B 6 years ago
parent
commit
8a309c6198
2 changed files with 39 additions and 39 deletions
  1. +33
    -33
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  2. +6
    -6
      app/src/main/res/menu/action_view_bottom.xml

+ 33
- 33
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -198,12 +198,12 @@ public class FragmentMessage extends FragmentEx {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_trash:
onActionDelete(id);
return true;
case R.id.action_spam:
onActionSpam(id);
return true;
case R.id.action_trash:
onActionDelete(id);
return true;
case R.id.action_move:
onActionMove(id);
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.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_trash).setVisible(!outbox && !trash && hasTrash);
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_reply).setVisible(!outbox);
@ -439,6 +439,35 @@ public class FragmentMessage extends FragmentEx {
.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) {
String folderType = (String) bottom_navigation.getTag();
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) {
Bundle args = new Bundle();
args.putLong("id", id);


+ 6
- 6
app/src/main/res/menu/action_view_bottom.xml View File

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


Loading…
Cancel
Save