Debug: added option to save user flags

pull/214/head
M66B 11 months ago
parent 3fdedcd813
commit 0853694aa2

@ -1940,6 +1940,8 @@ class Core {
private static void onRaw(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, IOException, JSONException {
// Download raw message
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean save_user_flags = prefs.getBoolean("save_user_flags", false);
if (message.raw == null || !message.raw) {
IMAPMessage imessage = (IMAPMessage) ifolder.getMessageByUID(message.uid);
@ -1955,12 +1957,21 @@ class Core {
Properties props = MessageHelper.getSessionProperties(account.unicode);
Session isession = Session.getInstance(props, null);
MessageHelper helper;
MimeMessage saved;
try (InputStream is = new FileInputStream(file)) {
helper = new MessageHelper(new MimeMessage(isession, is), context);
saved = new MimeMessage(isession, is);
}
if (save_user_flags) {
String userFlags = TextUtils.join(",", imessage.getFlags().getUserFlags());
saved.addHeader("X-User-Flags", userFlags);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
saved.writeTo(os);
}
}
// Yahoo is returning incorrect messages
MessageHelper helper = new MessageHelper(saved, context);
if (!Objects.equals(message.msgid, helper.getMessageID()))
throw new MessagingException("Incorrect msgid=" + message.msgid + "/" + helper.getMessageID());

@ -221,6 +221,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swJsonLd;
private SwitchCompat swDupMsgId;
private SwitchCompat swThreadByRef;
private SwitchCompat swSaveUserFlags;
private SwitchCompat swMdn;
private SwitchCompat swAppChooser;
private SwitchCompat swAppChooserShare;
@ -287,7 +288,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"exact_alarms",
"native_dkim", "native_arc", "native_arc_whitelist",
"webp", "animate_images",
"easy_correct", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "mdn",
"easy_correct", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "global_keywords", "test_iab"
));
@ -460,6 +461,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swJsonLd = view.findViewById(R.id.swJsonLd);
swDupMsgId = view.findViewById(R.id.swDupMsgId);
swThreadByRef = view.findViewById(R.id.swThreadByRef);
swSaveUserFlags = view.findViewById(R.id.swSaveUserFlags);
swMdn = view.findViewById(R.id.swMdn);
swAppChooser = view.findViewById(R.id.swAppChooser);
swAppChooserShare = view.findViewById(R.id.swAppChooserShare);
@ -1570,6 +1572,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swSaveUserFlags.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("save_user_flags", checked).apply();
}
});
swMdn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2365,6 +2374,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swJsonLd.setChecked(prefs.getBoolean("json_ld", false));
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
swThreadByRef.setChecked(prefs.getBoolean("thread_byref", true));
swSaveUserFlags.setChecked(prefs.getBoolean("save_user_flags", false));
swMdn.setChecked(prefs.getBoolean("mdn", swExperiments.isChecked()));
swAppChooser.setChecked(prefs.getBoolean("app_chooser", false));
swAppChooserShare.setChecked(prefs.getBoolean("app_chooser_share", false));

@ -1867,6 +1867,17 @@
app:layout_constraintTop_toBottomOf="@id/swDupMsgId"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSaveUserFlags"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_save_user_flags"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swThreadByRef"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swMdn"
android:layout_width="0dp"
@ -1875,7 +1886,7 @@
android:text="@string/title_advanced_mdn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swThreadByRef"
app:layout_constraintTop_toBottomOf="@id/swSaveUserFlags"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -948,6 +948,7 @@
<string name="title_advanced_json_ld" translatable="false">Show Linked Data (JSON-LD)</string>
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
<string name="title_advanced_thread_by_ref" translatable="false">Thread by common reference</string>
<string name="title_advanced_save_user_flags" translatable="false">Save user flags</string>
<string name="title_advanced_mdn" translatable="false">Process MDNs</string>
<string name="title_advanced_app_chooser" translatable="false">Use Android app chooser for links</string>
<string name="title_advanced_app_chooser_share" translatable="false">Use Android app chooser for files</string>

Loading…
Cancel
Save