diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index a4d1804e70..1c3c1ab165 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -315,9 +315,14 @@ public class FragmentIdentity extends FragmentBase { @Override public void afterTextChanged(Editable s) { - if (etSignature.getTag() == null) - signature = HtmlHelper.toHtml(s); - else + if (etSignature.getTag() == null) { + if (TextUtils.isEmpty(s)) + signature = null; + else { + Helper.clearComposingText(s); + signature = HtmlHelper.toHtml(s); + } + } else etSignature.setTag(null); } }); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 861ba2edd6..5adec1e0f7 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -32,6 +32,8 @@ import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.os.Parcel; +import android.text.Spannable; +import android.text.Spanned; import android.text.format.DateUtils; import android.text.format.Time; import android.view.Menu; @@ -325,6 +327,13 @@ public class Helper { return text.substring(0, maxLen) + "..."; } + static void clearComposingText(Spannable text) { + Object[] spans = text.getSpans(0, text.length(), Object.class); + for (Object span : spans) + if ((text.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) + text.removeSpan(span); + } + static String localizeFolderName(Context context, String name) { if (name != null && "INBOX".equals(name.toUpperCase())) return context.getString(R.string.title_folder_inbox); diff --git a/app/src/main/res/layout/fragment_compose.xml b/app/src/main/res/layout/fragment_compose.xml index 0153f355bb..3e058a9f22 100644 --- a/app/src/main/res/layout/fragment_compose.xml +++ b/app/src/main/res/layout/fragment_compose.xml @@ -239,8 +239,8 @@ android:layout_marginTop="6dp" android:layout_marginEnd="6dp" android:fontFamily="monospace" + android:text="Signature" android:textAppearance="@style/TextAppearance.AppCompat.Small" - android:textStyle="italic" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />