mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-19 18:35:34 +00:00
Added option to check dups by msgid
This commit is contained in:
parent
fd99e64969
commit
9d39102597
4 changed files with 50 additions and 18 deletions
|
@ -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<String, List<TupleMessageEx>> 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<TupleMessageEx> 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<TupleMessageEx> 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;
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -815,6 +815,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swAuthSasl"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDupMsgId"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_dup_msgid"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swTestIab"
|
||||
android:layout_width="0dp"
|
||||
|
@ -823,7 +834,7 @@
|
|||
android:text="@string/title_advanced_test_iab"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
|
||||
app:layout_constraintTop_toBottomOf="@id/swDupMsgId"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -658,6 +658,7 @@
|
|||
<string name="title_advanced_auth_ntlm" translatable="false">NTLM</string>
|
||||
<string name="title_advanced_auth_sasl" translatable="false">SASL</string>
|
||||
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
|
||||
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
|
||||
<string name="title_advanced_test_iab" translatable="false">Test IAB</string>
|
||||
<string name="title_advanced_processors" translatable="false">Processors: %1$d</string>
|
||||
<string name="title_advanced_memory_class" translatable="false">Memory class: %1$s/%2$s Total: %3$s</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue