Simplification/small fix

pull/178/head
M66B 5 years ago
parent 187ba8b73e
commit a51a22968c

@ -3380,15 +3380,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean compact = prefs.getBoolean("compact", false);
boolean quick_filter = prefs.getBoolean("quick_filter", false);
boolean drafts = EntityFolder.DRAFTS.equals(type);
boolean outbox = EntityFolder.OUTBOX.equals(type);
boolean sent = EntityFolder.SENT.equals(type);
boolean folder =
(viewType == AdapterMessage.ViewType.UNIFIED ||
(viewType == AdapterMessage.ViewType.FOLDER && !outbox));
boolean canSnooze =
(viewType == AdapterMessage.ViewType.UNIFIED && !EntityFolder.DRAFTS.equals(type)) ||
(viewType == AdapterMessage.ViewType.FOLDER && !EntityFolder.DRAFTS.equals(type));
MenuItem menuSearch = menu.findItem(R.id.menu_search);
menuSearch.setVisible(
(viewType == AdapterMessage.ViewType.UNIFIED && type == null)
@ -3436,11 +3435,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_ascending).setChecked(ascending);
menu.findItem(R.id.menu_filter).setVisible(viewType != AdapterMessage.ViewType.SEARCH && !outbox);
menu.findItem(R.id.menu_filter_seen).setVisible(viewType != AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_unflagged).setVisible(viewType != AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_unknown).setVisible(viewType != AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_snoozed).setVisible(viewType != AdapterMessage.ViewType.THREAD && canSnooze);
menu.findItem(R.id.menu_filter_seen).setVisible(folder);
menu.findItem(R.id.menu_filter_unflagged).setVisible(folder);
menu.findItem(R.id.menu_filter_unknown).setVisible(folder && !drafts && !sent);
menu.findItem(R.id.menu_filter_snoozed).setVisible(folder && !drafts);
menu.findItem(R.id.menu_filter_duplicates).setVisible(viewType == AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_filter_seen).setChecked(filter_seen);
menu.findItem(R.id.menu_filter_unflagged).setChecked(filter_unflagged);
menu.findItem(R.id.menu_filter_unknown).setChecked(filter_unknown);
@ -3449,14 +3449,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_compact).setChecked(compact);
boolean list = (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER);
menu.findItem(R.id.menu_select_language).setVisible(
language_detection && list && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q);
menu.findItem(R.id.menu_select_all).setVisible(!outbox && list);
language_detection && folder && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q);
menu.findItem(R.id.menu_select_all).setVisible(folder);
menu.findItem(R.id.menu_select_found).setVisible(viewType == AdapterMessage.ViewType.SEARCH);
menu.findItem(R.id.menu_empty_trash).setVisible(EntityFolder.TRASH.equals(type) && list);
menu.findItem(R.id.menu_empty_spam).setVisible(EntityFolder.JUNK.equals(type) && list);
menu.findItem(R.id.menu_empty_trash).setVisible(EntityFolder.TRASH.equals(type) && folder);
menu.findItem(R.id.menu_empty_spam).setVisible(EntityFolder.JUNK.equals(type) && folder);
menu.findItem(R.id.menu_force_sync).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);
@ -3466,7 +3464,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibSeen.setVisibility(quick_filter && folder ? View.VISIBLE : View.GONE);
ibUnflagged.setVisibility(quick_filter && folder ? View.VISIBLE : View.GONE);
ibSnoozed.setVisibility(quick_filter && folder && canSnooze ? View.VISIBLE : View.GONE);
ibSnoozed.setVisibility(quick_filter && folder && !drafts ? View.VISIBLE : View.GONE);
super.onPrepareOptionsMenu(menu);
}

Loading…
Cancel
Save