Browse Source

Highlight unread messages

main
M66B 6 years ago
parent
commit
33c0ec0efe
5 changed files with 18 additions and 7 deletions
  1. +1
    -0
      app/src/main/java/eu/faircode/email/AdapterFolder.java
  2. +6
    -1
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  3. +6
    -6
      app/src/main/java/eu/faircode/email/Helper.java
  4. +2
    -0
      app/src/main/res/values/colors.xml
  5. +3
    -0
      app/src/main/res/values/styles.xml

+ 1
- 0
app/src/main/java/eu/faircode/email/AdapterFolder.java View File

@ -233,6 +233,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
else
holder.tvName.setText(name);
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.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE);


+ 6
- 1
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -245,14 +245,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else
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);
int visibility = (unseen ? Typeface.BOLD : Typeface.NORMAL);
holder.tvFrom.setTypeface(null, visibility);
holder.tvTime.setTypeface(null, visibility);
holder.ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
holder.tvSubject.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();
}
}

+ 6
- 6
app/src/main/java/eu/faircode/email/Helper.java View File

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


+ 2
- 0
app/src/main/res/values/colors.xml View File

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


+ 3
- 0
app/src/main/res/values/styles.xml View File

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


Loading…
Cancel
Save