From 3c9b00daa8db68d1fcf911b2d241cdac38878ee2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 9 Jan 2022 19:09:55 +0100 Subject: [PATCH] Replace single CR by LF --- .../main/java/eu/faircode/email/EditTextCompose.java | 3 +-- .../main/java/eu/faircode/email/FragmentMessages.java | 5 +---- app/src/main/java/eu/faircode/email/HtmlHelper.java | 10 ++++++---- app/src/main/java/eu/faircode/email/MessageHelper.java | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EditTextCompose.java b/app/src/main/java/eu/faircode/email/EditTextCompose.java index f369c5680b..92090617d0 100644 --- a/app/src/main/java/eu/faircode/email/EditTextCompose.java +++ b/app/src/main/java/eu/faircode/email/EditTextCompose.java @@ -33,7 +33,6 @@ import android.os.Parcelable; import android.text.Html; import android.text.SpannableStringBuilder; import android.text.Spanned; -import android.text.style.ImageSpan; import android.text.style.QuoteSpan; import android.text.style.StyleSpan; import android.util.AttributeSet; @@ -228,7 +227,7 @@ public class EditTextCompose extends FixedEditText { if (raw) html = text.toString(); else - html = "
" + HtmlHelper.formatPre(text.toString(), false) + "
"; + html = "
" + HtmlHelper.formatPlainText(text.toString(), false) + "
"; } else html = h; diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 5c4b8b183a..f5239d44aa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -35,7 +35,6 @@ import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecorato import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.app.Activity; import android.app.Dialog; import android.app.NotificationManager; @@ -184,7 +183,6 @@ import org.openintents.openpgp.AutocryptPeerUpdate; import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; -import org.openintents.openpgp.util.OpenPgpServiceConnection; import java.io.ByteArrayInputStream; import java.io.File; @@ -240,7 +238,6 @@ import javax.mail.MessageRemovedException; import javax.mail.MessagingException; import javax.mail.Part; import javax.mail.Session; -import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; @@ -7248,7 +7245,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. // Write decrypted body String text = Helper.readText(plain); - String html = "
" + HtmlHelper.formatPre(text) + "
"; + String html = "
" + HtmlHelper.formatPlainText(text) + "
"; Helper.writeText(message.getFile(context), html); db.message().setMessageStored(message.id, new Date().getTime()); db.message().setMessageFts(message.id, false); diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 50f7fc1d2c..72c7355352 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -1880,14 +1880,16 @@ public class HtmlHelper { return flowed.toString(); } - static String formatPre(String text) { - return formatPre(text, true); + static String formatPlainText(String text) { + return formatPlainText(text, true); } - static String formatPre(String text, boolean view) { + static String formatPlainText(String text, boolean view) { int level = 0; StringBuilder sb = new StringBuilder(); - String[] lines = text.split("\\r?\\n"); + String[] lines = text + .replaceAll("\\r(?!\\n)", "\n") + .split("\\r?\\n"); for (int l = 0; l < lines.length; l++) { String line = lines[l]; lines[l] = null; diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 8e0ce2a092..0584be685a 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -24,7 +24,6 @@ import static android.system.OsConstants.ENOSPC; import android.content.Context; import android.content.SharedPreferences; import android.net.Uri; -import android.os.SystemClock; import android.system.ErrnoException; import android.text.TextUtils; @@ -2834,7 +2833,7 @@ public class MessageHelper { result.substring(e - HTML_END.length(), e).equalsIgnoreCase(HTML_END)) return result; - result = "
" + HtmlHelper.formatPre(result) + "
"; + result = "
" + HtmlHelper.formatPlainText(result) + "
"; } else if (h.isHtml()) { // Conditionally upgrade to UTF8 if ((cs == null ||