diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index e9033707b5..748dc0a0ce 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -3726,8 +3726,6 @@ public class FragmentCompose extends FragmentBase { } private void onAddAttachment(List uris, String[] types, boolean image, int resize, boolean privacy, boolean focus) { - HtmlHelper.clearComposingText(etBody); - Bundle args = new Bundle(); args.putLong("id", working); args.putParcelableArrayList("uris", new ArrayList<>(uris)); @@ -3754,6 +3752,7 @@ public class FragmentCompose extends FragmentBase { int start = args.getInt("start"); SpannableStringBuilder s = new SpannableStringBuilderEx(body); + HtmlHelper.clearComposingText(s); if (start < 0) start = 0; if (start > s.length()) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 431a36910d..efc3e34ce8 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -58,6 +58,7 @@ import android.text.style.UnderlineSpan; import android.util.Base64; import android.util.Patterns; import android.view.View; +import android.view.inputmethod.BaseInputConnection; import android.widget.TextView; import androidx.annotation.NonNull; @@ -4141,6 +4142,12 @@ public class HtmlHelper { view.clearComposingText(); } + static void clearComposingText(Spannable text) { + if (text == null) + return; + BaseInputConnection.removeComposingSpans(text); + } + static Spanned fromHtml(@NonNull String html, Context context) { Document document = JsoupEx.parse(html); return fromDocument(context, document, null, null);