mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-05 19:21:07 +00:00
Clearcomposing: prevent removing images
This commit is contained in:
parent
def5462c87
commit
8d4ff8ba07
1 changed files with 22 additions and 1 deletions
|
@ -33,6 +33,7 @@ import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
|
@ -4167,7 +4168,27 @@ public class HtmlHelper {
|
||||||
static void clearComposingText(TextView view) {
|
static void clearComposingText(TextView view) {
|
||||||
if (view == null)
|
if (view == null)
|
||||||
return;
|
return;
|
||||||
view.clearComposingText();
|
|
||||||
|
CharSequence edit = view.getText();
|
||||||
|
if (!(edit instanceof Spannable))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Copied from BaseInputConnection.removeComposingSpans
|
||||||
|
Spannable text = (Spannable) edit;
|
||||||
|
Object[] sps = text.getSpans(0, text.length(), Object.class);
|
||||||
|
if (sps != null) {
|
||||||
|
for (int i = sps.length - 1; i >= 0; i--) {
|
||||||
|
Object o = sps[i];
|
||||||
|
if (o instanceof ImageSpan) {
|
||||||
|
String source = ((ImageSpan) o).getSource();
|
||||||
|
if (source != null && source.startsWith("cid:"))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((text.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != 0) {
|
||||||
|
text.removeSpan(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearComposingText(Spannable text) {
|
static void clearComposingText(Spannable text) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue