diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 6d1b25f937..b05486acfb 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -5648,6 +5648,8 @@ public class AdapterMessage extends RecyclerView.Adapter= message.label_colors.length) continue; + if (message.label_colors[i] == null) + continue; int len = ssb.length(); ssb.setSpan(new ForegroundColorSpan(message.label_colors[i]), @@ -5662,27 +5664,31 @@ public class AdapterMessage extends RecyclerView.Adapter 0) ssb.append(' '); - String keyword = message.keyword_titles[i]; + if (message.keyword_titles != null && + i < message.keyword_titles.length && + message.keyword_titles[i] != null) + keyword = message.keyword_titles[i]; + ssb.append(keyword); - if (message.keyword_colors[i] != null) { - int len = ssb.length(); - ssb.setSpan( - new ForegroundColorSpan(message.keyword_colors[i]), - len - keyword.length(), len, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } + if (message.keyword_colors == null) + continue; + if (i >= message.keyword_colors.length) + continue; + if (message.keyword_colors[i] == null) + continue; + + int len = ssb.length(); + ssb.setSpan( + new ForegroundColorSpan(message.keyword_colors[i]), + len - keyword.length(), len, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } return ssb; diff --git a/app/src/main/java/eu/faircode/email/TupleMessageEx.java b/app/src/main/java/eu/faircode/email/TupleMessageEx.java index 4aa5e98967..1be2d4d448 100644 --- a/app/src/main/java/eu/faircode/email/TupleMessageEx.java +++ b/app/src/main/java/eu/faircode/email/TupleMessageEx.java @@ -103,22 +103,23 @@ public class TupleMessageEx extends EntityMessage { List titles = new ArrayList<>(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - for (int i = 0; i < this.keywords.length; i++) { - String keyword = this.keywords[i]; + if (this.keywords != null) + for (int i = 0; i < this.keywords.length; i++) { + String keyword = this.keywords[i]; - String keyColor1 = "kwcolor." + keyword; - String keyColor2 = "keyword." + keyword; // legacy - if (prefs.contains(keyColor1)) - color.add(prefs.getInt(keyColor1, Color.GRAY)); - else if (prefs.contains(keyColor2)) - color.add(prefs.getInt(keyColor2, Color.GRAY)); - else - color.add(null); + String keyColor1 = "kwcolor." + keyword; + String keyColor2 = "keyword." + keyword; // legacy + if (prefs.contains(keyColor1)) + color.add(prefs.getInt(keyColor1, Color.GRAY)); + else if (prefs.contains(keyColor2)) + color.add(prefs.getInt(keyColor2, Color.GRAY)); + else + color.add(null); - String keyTitle = "kwtitle." + keyword; - String def = TupleKeyword.getDefaultKeywordAlias(context, keyword); - titles.add(prefs.getString(keyTitle, def)); - } + String keyTitle = "kwtitle." + keyword; + String def = TupleKeyword.getDefaultKeywordAlias(context, keyword); + titles.add(prefs.getString(keyTitle, def)); + } this.keyword_colors = color.toArray(new Integer[0]); this.keyword_titles = titles.toArray(new String[0]);