Changes mention and tag highlighting in the composer to use Mastodon's regex. Closes #145 Also, does some haphazard cleanup.

This commit is contained in:
Vavassor 2017-07-01 20:32:35 -04:00
commit 5d621cecda
7 changed files with 83 additions and 60 deletions

View file

@ -16,6 +16,7 @@
package com.keylesspalace.tusky.json;
import android.text.Spanned;
import android.text.SpannedString;
import com.emojione.Emojione;
import com.google.gson.JsonDeserializationContext;
@ -28,7 +29,13 @@ import java.lang.reflect.Type;
public class SpannedTypeAdapter implements JsonDeserializer<Spanned> {
@Override
public Spanned deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return HtmlUtils.fromHtml(Emojione.shortnameToUnicode(json.getAsString(), false));
public Spanned deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
String string = json.getAsString();
if (string != null) {
return HtmlUtils.fromHtml(Emojione.shortnameToUnicode(string, false));
} else {
return new SpannedString("");
}
}
}