diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index 8a9abcd25a..cede5be5bc 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -5352,17 +5352,33 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return true;
}
+ final Context context = getContext();
+ if (context == null)
+ return true;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean expand_first = prefs.getBoolean("expand_first", true);
+ boolean expand_all = prefs.getBoolean("expand_all", false);
+ long download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
+ boolean dup_msgids = prefs.getBoolean("dup_msgids", false);
+
// Mark duplicates
Map> duplicates = new HashMap<>();
- for (TupleMessageEx message : messages)
- if (message != null &&
- !TextUtils.isEmpty(message.hash)) {
- if (!duplicates.containsKey(message.hash))
- duplicates.put(message.hash, new ArrayList<>());
- duplicates.get(message.hash).add(message);
- }
- for (String hash : duplicates.keySet()) {
- List dups = duplicates.get(hash);
+ for (TupleMessageEx message : messages) {
+ if (message == null)
+ continue;
+
+ String key = (dup_msgids ? message.msgid : message.hash);
+ if (TextUtils.isEmpty(key))
+ continue;
+
+ if (!duplicates.containsKey(key))
+ duplicates.put(key, new ArrayList<>());
+ duplicates.get(key).add(message);
+ }
+
+ for (String key : duplicates.keySet()) {
+ List dups = duplicates.get(key);
int base = 0;
for (int i = 0; i < dups.size(); i++)
if (dups.get(i).folder == folder) {
@@ -5376,16 +5392,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (autoExpanded) {
autoExpanded = false;
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
- boolean expand_first = prefs.getBoolean("expand_first", true);
- boolean expand_all = prefs.getBoolean("expand_all", false);
- long download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
-
if (download == 0)
download = Long.MAX_VALUE;
- boolean unmetered = ConnectionHelper.getNetworkState(getContext()).isUnmetered();
+ boolean unmetered = ConnectionHelper.getNetworkState(context).isUnmetered();
int count = 0;
int unseen = 0;
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index b08311302c..d4d923df6b 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -141,6 +141,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAuthNtlm;
private SwitchCompat swAuthSasl;
private SwitchCompat swExactAlarms;
+ private SwitchCompat swDupMsgId;
private SwitchCompat swTestIab;
private TextView tvProcessors;
private TextView tvMemoryClass;
@@ -170,7 +171,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"protocol", "debug", "log_level",
"use_modseq", "perform_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl",
- "exact_alarms", "test_iab"
+ "exact_alarms", "dup_msgids", "test_iab"
};
private final static String[] RESET_QUESTIONS = new String[]{
@@ -263,6 +264,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthNtlm = view.findViewById(R.id.swAuthNtlm);
swAuthSasl = view.findViewById(R.id.swAuthSasl);
swExactAlarms = view.findViewById(R.id.swExactAlarms);
+ swDupMsgId = view.findViewById(R.id.swDupMsgId);
swTestIab = view.findViewById(R.id.swTestIab);
tvProcessors = view.findViewById(R.id.tvProcessors);
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
@@ -742,6 +744,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
+ swDupMsgId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("dup_msgids", checked).apply();
+ }
+ });
+
swTestIab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -1223,6 +1232,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthNtlm.setChecked(prefs.getBoolean("auth_ntlm", true));
swAuthSasl.setChecked(prefs.getBoolean("auth_sasl", true));
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
+ swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));
tvProcessors.setText(getString(R.string.title_advanced_processors, Runtime.getRuntime().availableProcessors()));
diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml
index 899d44ddee..99f377b2a1 100644
--- a/app/src/main/res/layout/fragment_options_misc.xml
+++ b/app/src/main/res/layout/fragment_options_misc.xml
@@ -815,6 +815,17 @@
app:layout_constraintTop_toBottomOf="@id/swAuthSasl"
app:switchPadding="12dp" />
+
+
NTLM
SASL
Use exact timers
+ Duplicates by message ID
Test IAB
Processors: %1$d
Memory class: %1$s/%2$s Total: %3$s