Use highlight unread color in navigation menu

pull/162/head
M66B 5 years ago
parent 3e0a494d61
commit 3a7ff9cda1

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
@ -31,6 +32,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
@ -48,6 +50,9 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
private LifecycleOwner owner;
private LayoutInflater inflater;
private int colorUnread;
private int textColorSecondary;
private List<TupleAccountEx> items = new ArrayList<>();
private NumberFormat NF = NumberFormat.getNumberInstance();
@ -96,8 +101,7 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
tvItem.setText(context.getString(R.string.title_name_count,
account.name, NF.format(account.unseen)));
tvItem.setTextColor(Helper.resolveColor(context,
account.unseen == 0 ? android.R.attr.textColorSecondary : android.R.attr.textColorPrimary));
tvItem.setTextColor(account.unseen == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(account.unseen == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setText(account.last_connected == null ? null : DTF.format(account.last_connected));
@ -128,6 +132,11 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
this.owner = owner;
this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnread : android.R.attr.textColorPrimary);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
this.DTF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
setHasStableIds(true);

@ -50,13 +50,15 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
private LifecycleOwner owner;
private LayoutInflater inflater;
private boolean debug;
private int colorUnread;
private int textColorSecondary;
private List<TupleFolderNav> items = new ArrayList<>();
private NumberFormat NF = NumberFormat.getNumberInstance();
private DateFormat DTF;
private boolean debug;
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private View view;
private ImageView ivItem;
@ -118,8 +120,7 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
tvItem.setText(context.getString(R.string.title_name_count,
folder.getDisplayName(context), NF.format(count)));
tvItem.setTextColor(Helper.resolveColor(context,
count == 0 ? android.R.attr.textColorSecondary : android.R.attr.textColorPrimary));
tvItem.setTextColor(count == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(count == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setText(folder.last_sync == null ? null : DTF.format(folder.last_sync));
@ -152,10 +153,13 @@ public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.View
this.owner = owner;
this.inflater = LayoutInflater.from(context);
this.DTF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
this.debug = prefs.getBoolean("debug", false);
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnread : android.R.attr.textColorPrimary);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
this.DTF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
setHasStableIds(true);
}

@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
@ -29,6 +30,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
@ -43,6 +45,9 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
private LifecycleOwner owner;
private LayoutInflater inflater;
private int colorUnread;
private int textColorSecondary;
private List<NavMenuItem> items = new ArrayList<>();
private NumberFormat NF = NumberFormat.getNumberInstance();
@ -85,8 +90,7 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
tvItem.setText(context.getString(R.string.title_name_count,
context.getString(menu.getTitle()), NF.format(menu.getCount())));
tvItem.setTextColor(Helper.resolveColor(context,
menu.getCount() == null ? android.R.attr.textColorSecondary : android.R.attr.textColorPrimary));
tvItem.setTextColor(menu.getCount() == null ? textColorSecondary : colorUnread);
tvItem.setTypeface(menu.getCount() == null ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setVisibility(View.GONE);
@ -120,6 +124,12 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
this.context = context;
this.owner = owner;
this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnread : android.R.attr.textColorPrimary);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
setHasStableIds(true);
}

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
@ -31,6 +32,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
@ -46,6 +48,9 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
private LifecycleOwner owner;
private LayoutInflater inflater;
private int colorUnread;
private int textColorSecondary;
private List<EntityFolderUnified> items = new ArrayList<>();
private NumberFormat NF = NumberFormat.getNumberInstance();
@ -86,8 +91,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
tvItem.setText(context.getString(R.string.title_name_count,
Helper.localizeFolderType(context, folder.type), NF.format(folder.unseen)));
tvItem.setTextColor(Helper.resolveColor(context,
folder.unseen == 0 ? android.R.attr.textColorSecondary : android.R.attr.textColorPrimary));
tvItem.setTextColor(folder.unseen == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(folder.unseen == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);
tvItemExtra.setVisibility(View.GONE);
@ -116,6 +120,11 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
this.context = context;
this.owner = owner;
this.inflater = LayoutInflater.from(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnread : android.R.attr.textColorPrimary);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
}
public void set(@NonNull List<EntityFolderUnified> types) {

Loading…
Cancel
Save