Signature fixes

pull/156/head
M66B 6 years ago
parent e3c14cc143
commit 499b0ed6fd

@ -315,9 +315,14 @@ public class FragmentIdentity extends FragmentBase {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (etSignature.getTag() == null) if (etSignature.getTag() == null) {
signature = HtmlHelper.toHtml(s); if (TextUtils.isEmpty(s))
else signature = null;
else {
Helper.clearComposingText(s);
signature = HtmlHelper.toHtml(s);
}
} else
etSignature.setTag(null); etSignature.setTag(null);
} }
}); });

@ -32,6 +32,8 @@ import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.text.Spannable;
import android.text.Spanned;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.text.format.Time; import android.text.format.Time;
import android.view.Menu; import android.view.Menu;
@ -325,6 +327,13 @@ public class Helper {
return text.substring(0, maxLen) + "..."; 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) { static String localizeFolderName(Context context, String name) {
if (name != null && "INBOX".equals(name.toUpperCase())) if (name != null && "INBOX".equals(name.toUpperCase()))
return context.getString(R.string.title_folder_inbox); return context.getString(R.string.title_folder_inbox);

@ -239,8 +239,8 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:fontFamily="monospace" android:fontFamily="monospace"
android:text="Signature"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" /> app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />

Loading…
Cancel
Save