Added message button configuration

This commit is contained in:
M66B 2020-06-26 12:29:30 +02:00
parent 895600194a
commit 278ef1584f
3 changed files with 68 additions and 21 deletions

View File

@ -1558,8 +1558,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean experiments = prefs.getBoolean("experiments", false); boolean experiments = prefs.getBoolean("experiments", false);
boolean expand_all = prefs.getBoolean("expand_all", false); boolean expand_all = prefs.getBoolean("expand_all", false);
boolean expand_one = prefs.getBoolean("expand_one", true); boolean expand_one = prefs.getBoolean("expand_one", true);
boolean extras = prefs.getBoolean("message_extras", true);
boolean tools = prefs.getBoolean("message_tools", true); boolean tools = prefs.getBoolean("message_tools", true);
boolean button_junk = prefs.getBoolean("button_junk", true);
boolean button_trash = prefs.getBoolean("button_trash", true);
boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true);
ibTrash.setTag(delete); ibTrash.setTag(delete);
@ -1569,17 +1572,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setVisibility(!tools || message.unsubscribe == null ? View.GONE : View.VISIBLE); ibUnsubscribe.setVisibility(!tools || message.unsubscribe == null ? View.GONE : View.VISIBLE);
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE); ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibLabels.setVisibility(tools && labels_header && labels && !outbox ? View.VISIBLE : View.GONE); ibLabels.setVisibility(tools && labels_header && labels && !outbox ? View.VISIBLE : View.GONE);
ibMove.setVisibility(tools && move ? View.VISIBLE : View.GONE); ibMove.setVisibility(tools && button_move && move ? View.VISIBLE : View.GONE);
ibArchive.setVisibility(tools && extras && archive ? View.VISIBLE : View.GONE); ibArchive.setVisibility(tools && button_archive && archive ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(outbox || (tools && extras && trash) ? View.VISIBLE : View.GONE); ibTrash.setVisibility(outbox || (tools && button_trash && trash) ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(tools && junk ? View.VISIBLE : View.GONE); ibJunk.setVisibility(tools && button_junk && junk ? View.VISIBLE : View.GONE);
ibInbox.setVisibility(tools && inbox ? View.VISIBLE : View.GONE); ibInbox.setVisibility(tools && inbox ? View.VISIBLE : View.GONE);
ibMore.setVisibility(!tools || outbox ? View.GONE : View.VISIBLE); ibMore.setVisibility(!tools || outbox ? View.GONE : View.VISIBLE);
ibTools.setImageLevel(tools ? 0 : 1); ibTools.setImageLevel(tools ? 0 : 1);
ibTools.setVisibility(outbox ? View.GONE : View.VISIBLE); ibTools.setVisibility(outbox ? View.GONE : View.VISIBLE);
ibTrashBottom.setVisibility(extras && trash ? View.VISIBLE : View.GONE); ibTrashBottom.setVisibility(button_trash && trash ? View.VISIBLE : View.GONE);
ibArchiveBottom.setVisibility(extras && archive ? View.VISIBLE : View.GONE); ibArchiveBottom.setVisibility(button_archive && archive ? View.VISIBLE : View.GONE);
if (bind) if (bind)
bindBody(message, scroll); bindBody(message, scroll);
@ -3758,12 +3761,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean full = properties.getValue("full", message.id); boolean full = properties.getValue("full", message.id);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean message_extras = prefs.getBoolean("message_extras", true); boolean button_junk = prefs.getBoolean("button_junk", true);
boolean button_trash = prefs.getBoolean("button_trash", true);
boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true);
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, ibMore); PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, ibMore);
popupMenu.inflate(R.menu.popup_message_more); popupMenu.inflate(R.menu.popup_message_more);
popupMenu.getMenu().findItem(R.id.menu_extras).setChecked(message_extras); popupMenu.getMenu().findItem(R.id.menu_button_junk).setChecked(button_junk);
popupMenu.getMenu().findItem(R.id.menu_button_trash).setChecked(button_trash);
popupMenu.getMenu().findItem(R.id.menu_button_archive).setChecked(button_archive);
popupMenu.getMenu().findItem(R.id.menu_button_move).setChecked(button_move);
popupMenu.getMenu().findItem(R.id.menu_unseen).setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen); popupMenu.getMenu().findItem(R.id.menu_unseen).setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen);
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled( popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(
(message.uid != null && !message.folderReadOnly) || message.accountProtocol != EntityAccount.TYPE_IMAP); (message.uid != null && !message.folderReadOnly) || message.accountProtocol != EntityAccount.TYPE_IMAP);
@ -3778,8 +3788,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_set_importance_normal).setEnabled(!EntityMessage.PRIORITIY_NORMAL.equals(i)); popupMenu.getMenu().findItem(R.id.menu_set_importance_normal).setEnabled(!EntityMessage.PRIORITIY_NORMAL.equals(i));
popupMenu.getMenu().findItem(R.id.menu_set_importance_high).setEnabled(!EntityMessage.PRIORITIY_HIGH.equals(i)); popupMenu.getMenu().findItem(R.id.menu_set_importance_high).setEnabled(!EntityMessage.PRIORITIY_HIGH.equals(i));
popupMenu.getMenu().findItem(R.id.menu_copy).setEnabled(message.uid != null && !message.folderReadOnly); popupMenu.getMenu().findItem(R.id.menu_move_to).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_copy).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP); popupMenu.getMenu().findItem(R.id.menu_move_to).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_copy_to).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_copy_to).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_delete).setEnabled(message.uid == null || !message.folderReadOnly); popupMenu.getMenu().findItem(R.id.menu_delete).setEnabled(message.uid == null || !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP); popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
@ -3813,8 +3826,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
public boolean onMenuItemClick(MenuItem target) { public boolean onMenuItemClick(MenuItem target) {
switch (target.getItemId()) { switch (target.getItemId()) {
case R.id.menu_extras: case R.id.menu_button_junk:
onMenuExtras(message, target.isChecked()); onMenuButton(message, "junk", target.isChecked());
return true;
case R.id.menu_button_trash:
onMenuButton(message, "trash", target.isChecked());
return true;
case R.id.menu_button_archive:
onMenuButton(message, "archive", target.isChecked());
return true;
case R.id.menu_button_move:
onMenuButton(message, "move", target.isChecked());
return true; return true;
case R.id.menu_unseen: case R.id.menu_unseen:
onMenuUnseen(message); onMenuUnseen(message);
@ -3837,7 +3859,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_set_importance_high: case R.id.menu_set_importance_high:
onMenuSetImportance(message, EntityMessage.PRIORITIY_HIGH); onMenuSetImportance(message, EntityMessage.PRIORITIY_HIGH);
return true; return true;
case R.id.menu_copy: case R.id.menu_move_to:
onActionMove(message, false);
return true;
case R.id.menu_copy_to:
onActionMove(message, true); onActionMove(message, true);
return true; return true;
case R.id.menu_delete: case R.id.menu_delete:
@ -4074,9 +4099,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ToastEx.makeText(context, context.getString(R.string.title_no_viewer, uri), Toast.LENGTH_LONG).show(); ToastEx.makeText(context, context.getString(R.string.title_no_viewer, uri), Toast.LENGTH_LONG).show();
} }
private void onMenuExtras(final TupleMessageEx message, boolean isChecked) { private void onMenuButton(final TupleMessageEx message, String button, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("message_extras", !isChecked).apply(); prefs.edit().putBoolean("button_" + button, !isChecked).apply();
setupTools(message, false, false); setupTools(message, false, false);
} }

View File

@ -1,9 +1,27 @@
<?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 <item
android:id="@+id/menu_extras" android:id="@+id/menu_button"
android:title="@string/title_buttons">
<menu>
<item
android:id="@+id/menu_button_junk"
android:checkable="true" android:checkable="true"
android:title="@string/title_extras" /> android:title="@string/title_spam" />
<item
android:id="@+id/menu_button_trash"
android:checkable="true"
android:title="@string/title_trash" />
<item
android:id="@+id/menu_button_archive"
android:checkable="true"
android:title="@string/title_archive" />
<item
android:id="@+id/menu_button_move"
android:checkable="true"
android:title="@string/title_move" />
</menu>
</item>
<item <item
android:id="@+id/menu_unseen" android:id="@+id/menu_unseen"
@ -38,7 +56,11 @@
</item> </item>
<item <item
android:id="@+id/menu_copy" android:id="@+id/menu_move_to"
android:title="@string/title_move_to" />
<item
android:id="@+id/menu_copy_to"
android:title="@string/title_copy_to" /> android:title="@string/title_copy_to" />
<item <item

View File

@ -720,7 +720,7 @@
<string name="title_subject_reply">Re: %1$s</string> <string name="title_subject_reply">Re: %1$s</string>
<string name="title_subject_forward">Fwd: %1$s</string> <string name="title_subject_forward">Fwd: %1$s</string>
<string name="title_extras">Extra buttons</string> <string name="title_buttons">Buttons</string>
<string name="title_seen">Mark read</string> <string name="title_seen">Mark read</string>
<string name="title_unseen">Mark unread</string> <string name="title_unseen">Mark unread</string>
<string name="title_hide">Hide</string> <string name="title_hide">Hide</string>