mirror of https://github.com/M66B/FairEmail.git
Workaround: remove suggestions spans without composing flag
This commit is contained in:
parent
cda90c8252
commit
e38e4d36ad
|
@ -425,7 +425,7 @@ public class ActivitySignature extends ActivityBase {
|
|||
}
|
||||
|
||||
private String getHtml() {
|
||||
etText.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etText);
|
||||
|
||||
if (etText.isRaw()) {
|
||||
saved = etText.getText().toString();
|
||||
|
|
|
@ -207,7 +207,7 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
|
|||
|
||||
@Override
|
||||
protected void replaceText(CharSequence text) {
|
||||
clearComposingText();
|
||||
HtmlHelper.clearComposingText(this);
|
||||
|
||||
Editable edit = getText();
|
||||
int _end = getSelectionEnd();
|
||||
|
|
|
@ -428,7 +428,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onActionSave() {
|
||||
etText.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etText);
|
||||
|
||||
// Prevent splitting placeholders
|
||||
Editable edit = etText.getText();
|
||||
|
@ -642,7 +642,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onLanguageTool() {
|
||||
etText.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etText);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putCharSequence("text", etText.getText());
|
||||
|
|
|
@ -1546,7 +1546,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void convertRef(boolean plain) {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", working);
|
||||
|
@ -1630,7 +1630,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void deleteRef() {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("html", HtmlHelper.toHtml(etBody.getText(), getContext()));
|
||||
|
@ -2478,7 +2478,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onMenuAnswerCreate() {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString("subject", etSubject.getText().toString());
|
||||
|
@ -2788,7 +2788,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (paragraph == null)
|
||||
return;
|
||||
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Editable edit = etBody.getText();
|
||||
CharSequence text = edit.subSequence(paragraph.first, paragraph.second);
|
||||
|
@ -2918,7 +2918,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onLanguageTool(int start, int end, boolean silent) {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Log.i("LT running enabled=" + etBody.isSuggestionsEnabled());
|
||||
|
||||
|
@ -3589,7 +3589,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void onAddAttachment(List<Uri> uris, String[] types, boolean image, int resize, boolean privacy, boolean focus) {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", working);
|
||||
|
@ -4941,7 +4941,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
// Workaround underlines left by Android
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
|
||||
Editable e = etBody.getText();
|
||||
boolean notext = e.toString().trim().isEmpty();
|
||||
|
@ -7875,7 +7875,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
private void clearSearch() {
|
||||
etBody.clearComposingText();
|
||||
HtmlHelper.clearComposingText(etBody);
|
||||
}
|
||||
|
||||
private AdapterView.OnItemSelectedListener identitySelected = new AdapterView.OnItemSelectedListener() {
|
||||
|
|
|
@ -8140,7 +8140,7 @@ public class FragmentMessages extends FragmentBase
|
|||
private void clearSearch() {
|
||||
if (searchView == null)
|
||||
return;
|
||||
searchView.clearComposingText();
|
||||
HtmlHelper.clearComposingText(searchView);
|
||||
|
||||
View itemView = rvMessage.findContainingItemView(searchView);
|
||||
if (itemView == null)
|
||||
|
|
|
@ -53,12 +53,14 @@ import android.text.style.QuoteSpan;
|
|||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StrikethroughSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.style.SuggestionSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.Base64;
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -3935,6 +3937,21 @@ public class HtmlHelper {
|
|||
.remove("x-keep-line");
|
||||
}
|
||||
|
||||
static void clearComposingText(TextView view) {
|
||||
view.clearComposingText();
|
||||
|
||||
CharSequence text = view.getText();
|
||||
if (text instanceof Spannable) {
|
||||
Spannable edit = (Spannable) text;
|
||||
Object[] spans = edit.getSpans(0, edit.length(), Object.class);
|
||||
if (spans == null || spans.length == 0)
|
||||
return;
|
||||
for (Object span : spans)
|
||||
if (span instanceof SuggestionSpan)
|
||||
edit.removeSpan(span);
|
||||
}
|
||||
}
|
||||
|
||||
static Spanned fromHtml(@NonNull String html, Context context) {
|
||||
Document document = JsoupEx.parse(html);
|
||||
return fromDocument(context, document, null, null);
|
||||
|
|
Loading…
Reference in New Issue