Highlight unread messages

pull/23/head
M66B 6 years ago
parent 601d63482d
commit 33c0ec0efe

@ -233,6 +233,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
else else
holder.tvName.setText(name); holder.tvName.setText(name);
holder.tvName.setTypeface(null, folder.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL); holder.tvName.setTypeface(null, folder.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL);
holder.tvName.setTextColor(Helper.resolveColor(context, folder.unseen > 0 ? R.attr.colorUnread : android.R.attr.textColorSecondary));
holder.tvAfter.setText(Integer.toString(folder.after)); holder.tvAfter.setText(Integer.toString(folder.after));
holder.tvAfter.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE); holder.tvAfter.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE);

@ -245,14 +245,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else } else
holder.tvCount.setText(Helper.localizeFolderName(context, message.folderName)); holder.tvCount.setText(Helper.localizeFolderName(context, message.folderName));
holder.ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
boolean unseen = (message.thread == null ? message.unseen > 0 : !message.seen); boolean unseen = (message.thread == null ? message.unseen > 0 : !message.seen);
int visibility = (unseen ? Typeface.BOLD : Typeface.NORMAL); int visibility = (unseen ? Typeface.BOLD : Typeface.NORMAL);
holder.tvFrom.setTypeface(null, visibility); holder.tvFrom.setTypeface(null, visibility);
holder.tvTime.setTypeface(null, visibility); holder.tvTime.setTypeface(null, visibility);
holder.ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
holder.tvSubject.setTypeface(null, visibility); holder.tvSubject.setTypeface(null, visibility);
holder.tvCount.setTypeface(null, visibility); holder.tvCount.setTypeface(null, visibility);
holder.tvFrom.setTextColor(Helper.resolveColor(context, unseen ? R.attr.colorUnread : android.R.attr.textColorSecondary));
holder.tvTime.setTextColor(Helper.resolveColor(context, unseen ? R.attr.colorUnread : android.R.attr.textColorSecondary));
holder.wire(); holder.wire();
} }
} }

@ -20,11 +20,10 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.TypedArray;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -34,10 +33,11 @@ public class Helper {
static final String TAG = BuildConfig.APPLICATION_ID; static final String TAG = BuildConfig.APPLICATION_ID;
static int resolveColor(Context context, int attr) { static int resolveColor(Context context, int attr) {
TypedValue typedValue = new TypedValue(); int[] attrs = new int[]{attr};
Resources.Theme theme = context.getTheme(); TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
theme.resolveAttribute(attr, typedValue, true); int color = a.getColor(0, 0xFF0000);
return typedValue.data; a.recycle();
return color;
} }
static String localizeFolderName(Context context, String name) { static String localizeFolderName(Context context, String name) {

@ -6,11 +6,13 @@
<color name="colorActionForeground">#fff</color> <color name="colorActionForeground">#fff</color>
<color name="lightColorUnread">#000</color>
<color name="lightColorSeparator">#ffaaaaaa</color> <color name="lightColorSeparator">#ffaaaaaa</color>
<color name="lightColorDrawerScrim">#99000000</color> <color name="lightColorDrawerScrim">#99000000</color>
<color name="lightColorDrawerText">#111</color> <color name="lightColorDrawerText">#111</color>
<color name="lightColorDrawerBackground">#eee</color> <color name="lightColorDrawerBackground">#eee</color>
<color name="darkColorUnread">#fff</color>
<color name="darkColorSeparator">#ff878787</color> <color name="darkColorSeparator">#ff878787</color>
<color name="darkColorDrawerScrim">#997f7f7f</color> <color name="darkColorDrawerScrim">#997f7f7f</color>
<color name="darkColorDrawerText">#fff</color> <color name="darkColorDrawerText">#fff</color>

@ -1,4 +1,5 @@
<resources> <resources>
<attr name="colorUnread" format="reference" />
<attr name="colorSeparator" format="reference" /> <attr name="colorSeparator" format="reference" />
<attr name="colorDrawerScrim" format="reference" /> <attr name="colorDrawerScrim" format="reference" />
<attr name="colorDrawerText" format="reference" /> <attr name="colorDrawerText" format="reference" />
@ -11,6 +12,7 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="colorUnread">@color/lightColorUnread</item>
<item name="colorSeparator">@color/lightColorSeparator</item> <item name="colorSeparator">@color/lightColorSeparator</item>
<item name="colorDrawerScrim">@color/lightColorDrawerScrim</item> <item name="colorDrawerScrim">@color/lightColorDrawerScrim</item>
<item name="colorDrawerText">@color/lightColorDrawerText</item> <item name="colorDrawerText">@color/lightColorDrawerText</item>
@ -24,6 +26,7 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="colorUnread">@color/darkColorUnread</item>
<item name="colorSeparator">@color/darkColorSeparator</item> <item name="colorSeparator">@color/darkColorSeparator</item>
<item name="colorDrawerScrim">@color/darkColorDrawerScrim</item> <item name="colorDrawerScrim">@color/darkColorDrawerScrim</item>
<item name="colorDrawerText">@color/darkColorDrawerText</item> <item name="colorDrawerText">@color/darkColorDrawerText</item>

Loading…
Cancel
Save