Added option to show number of messages in nav menu

This commit is contained in:
M66B
2021-07-27 15:21:47 +02:00
parent aaacabe593
commit 6e61c71d48
6 changed files with 33 additions and 7 deletions

View File

@@ -49,7 +49,7 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
private LifecycleOwner owner;
private LayoutInflater inflater;
private boolean debug;
private boolean nav_count;
private int colorUnread;
private int textColorSecondary;
@@ -127,8 +127,8 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
tvItem.setTextColor(count == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(count == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setText(folder.last_sync == null ? null : TF.format(folder.last_sync));
tvItemExtra.setVisibility(debug ? View.VISIBLE : View.GONE);
tvItemExtra.setText(NF.format(folder.messages));
tvItemExtra.setVisibility(nav_count ? View.VISIBLE : View.GONE);
ivExternal.setVisibility(View.GONE);
ivWarning.setVisibility(folder.error == null ? View.GONE : View.VISIBLE);
@@ -159,8 +159,8 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.nav_count = prefs.getBoolean("nav_count", false);
boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
this.debug = prefs.getBoolean("debug", false);
int colorHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
this.colorUnread = (highlight_unread ? colorHighlight : Helper.resolveColor(context, R.attr.colorUnread));
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);

View File

@@ -48,6 +48,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
private LifecycleOwner owner;
private LayoutInflater inflater;
private boolean nav_count;
private int colorUnread;
private int textColorSecondary;
@@ -103,7 +104,9 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
tvItem.setTextColor(count == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(count == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setVisibility(View.GONE);
tvItemExtra.setText(NF.format(folder.messages));
tvItemExtra.setVisibility(nav_count ? View.VISIBLE : View.GONE);
ivExternal.setVisibility(View.GONE);
ivWarning.setVisibility(View.GONE);
}
@@ -131,6 +134,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.nav_count = prefs.getBoolean("nav_count", false);
boolean highlight_unread = prefs.getBoolean("highlight_unread", true);
int colorHighlight = prefs.getInt("highlight_color", Helper.resolveColor(context, R.attr.colorUnreadHighlight));
this.colorUnread = (highlight_unread ? colorHighlight : Helper.resolveColor(context, R.attr.colorUnread));

View File

@@ -108,7 +108,7 @@ public class FragmentOptions extends FragmentBase {
"subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist",
"send_pending",
"portrait2", "landscape", "landscape3", "startup",
"portrait2", "landscape", "landscape3", "nav_count", "startup",
"cards", "beige", "tabular_card_bg", "shadow_unread",
"indentation", "date", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe",

View File

@@ -73,6 +73,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swPortrait2;
private SwitchCompat swLandscape;
private SwitchCompat swLandscape3;
private SwitchCompat swNavMessageCount;
private SwitchCompat swThreading;
private SwitchCompat swThreadingUnread;
@@ -155,7 +156,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread",
"date", "date_bold", "navbar_colorize", "portrait2", "landscape", "landscape3",
"date", "date_bold", "navbar_colorize", "portrait2", "landscape", "landscape3", "nav_count",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe",
"avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
@@ -193,6 +194,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swPortrait2 = view.findViewById(R.id.swPortrait2);
swLandscape = view.findViewById(R.id.swLandscape);
swLandscape3 = view.findViewById(R.id.swLandscape3);
swNavMessageCount = view.findViewById(R.id.swNavMessageCount);
swThreading = view.findViewById(R.id.swThreading);
swThreadingUnread = view.findViewById(R.id.swThreadingUnread);
@@ -372,6 +374,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swNavMessageCount.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("nav_count", checked).apply();
}
});
swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -1022,6 +1031,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swLandscape.setEnabled(normal);
swLandscape3.setChecked(prefs.getBoolean("landscape3", true));
swLandscape3.setEnabled(normal);
swNavMessageCount.setChecked(prefs.getBoolean("nav_count", false));
swThreading.setChecked(prefs.getBoolean("threading", true));
swThreadingUnread.setChecked(prefs.getBoolean("threading_unread", false));