~singpolyma/cheogram-android

ffc1091d292386cecb5eeed4b86eeeec64c89653 — Stephen Paul Weber 7 months ago c0b09c0
Remove suggestion and composing spans when making XHTML
1 files changed, 12 insertions(+), 5 deletions(-)

M src/cheogram/java/com/cheogram/android/SpannedToXHTML.java
M src/cheogram/java/com/cheogram/android/SpannedToXHTML.java => src/cheogram/java/com/cheogram/android/SpannedToXHTML.java +12 -5
@@ 3,6 3,7 @@ package com.cheogram.android;
import android.app.Application;
import android.graphics.Typeface;
import android.text.Spanned;
import android.text.SpannableStringBuilder;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.AlignmentSpan;
import android.text.style.BackgroundColorSpan;


@@ 16,10 17,12 @@ import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.SubscriptSpan;
import android.text.style.SuggestionSpan;
import android.text.style.SuperscriptSpan;
import android.text.style.TypefaceSpan;
import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;
import android.view.inputmethod.BaseInputConnection;

import io.ipfs.cid.Cid;



@@ 28,7 31,13 @@ import eu.siacs.conversations.xml.TextNode;

public class SpannedToXHTML {
	public static Element append(Element out, Spanned text) {
		withinParagraph(out, text, 0, text.length());
		SpannableStringBuilder newText = new SpannableStringBuilder(text);
		SuggestionSpan[] spans = newText.getSpans(0, newText.length(), SuggestionSpan.class);
		for (SuggestionSpan span : spans) {
			newText.removeSpan(span);
		}
		BaseInputConnection.removeComposingSpans(newText);
		withinParagraph(out, newText, 0, newText.length());
		return out;
	}



@@ 61,11 70,9 @@ public class SpannedToXHTML {
				if (style[j] instanceof SubscriptSpan) {
					out = out.addChild("sub");
				}
				// TextEdit underlines text in current word, which ends up getting sent...
				// SPAN_COMPOSING ?
				/*if (style[j] instanceof UnderlineSpan) {
				if (style[j] instanceof UnderlineSpan) {
					out = out.addChild("u");
				}*/
				}
				if (style[j] instanceof StrikethroughSpan) {
					out = out.addChild("span");
					out.setAttribute("style", "text-decoration:line-through;");