diff --git a/app/src/main/java/net/gaast/giggity/EventDialog.java b/app/src/main/java/net/gaast/giggity/EventDialog.java index 5a964b69..1e4e3bbd 100644 --- a/app/src/main/java/net/gaast/giggity/EventDialog.java +++ b/app/src/main/java/net/gaast/giggity/EventDialog.java @@ -161,8 +161,8 @@ public EventDialog(Context ctx, Schedule.Item item, String searchQuery) { v.setVisibility(View.GONE); } - Spannable desc = new SpannableString(item.getDescriptionSpanned(ctx)); - if (searchQuery != null && !searchQuery.isEmpty()) { + Spannable desc = item.getDescriptionSpanned(ctx); + if (desc != null && searchQuery != null && !searchQuery.isEmpty()) { String raw = desc.toString().toLowerCase(); Matcher m = Pattern.compile("(\"([^\"]*)\"|'([^']*)'|(\\S+))").matcher(searchQuery.toLowerCase()); while (m.find()) { diff --git a/app/src/main/java/net/gaast/giggity/Schedule.java b/app/src/main/java/net/gaast/giggity/Schedule.java index 71dd3cbe..0f94b5da 100644 --- a/app/src/main/java/net/gaast/giggity/Schedule.java +++ b/app/src/main/java/net/gaast/giggity/Schedule.java @@ -20,6 +20,7 @@ package net.gaast.giggity; import android.content.Context; +import android.text.SpannableString; import android.text.Spanned; import android.util.Log; @@ -38,6 +39,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.Serializable; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -493,7 +495,7 @@ protected void addMetadata(String md_json) { JSONArray latlon = jroom.getJSONArray("latlon"); room.location = ("geo:0,0?q=" + latlon.optDouble(0, 0) + "," + latlon.optDouble(1, 0) + "(" + - URLEncoder.encode(name, StandardCharsets.UTF_8) + ")"); + URLEncoder.encode(name, "utf-8") + ")"); } } } @@ -504,6 +506,8 @@ protected void addMetadata(String md_json) { } catch (JSONException e) { e.printStackTrace(); return; + } catch (UnsupportedEncodingException e) { + // TODO: Once I'm on API 33+ I can use StandardCharsets.UTF_8 here again. } } @@ -1305,7 +1309,7 @@ public String getLanguage() { return language; } - public Spanned getDescriptionSpanned(Context ctx) { + public SpannableString getDescriptionSpanned(Context ctx) { if (description == null) { return null; } @@ -1320,7 +1324,7 @@ public Spanned getDescriptionSpanned(Context ctx) { description = description.replaceAll("(?is)(\\s*?p>\\s*)+", "
").trim(); description = description.replaceAll("(?i)(<[^/p][^>]+>)(
)+", "$1"); final Markwon mw = Markwon.builder(ctx).usePlugin(HtmlPlugin.create()).build(); - return mw.toMarkdown(description); + return new SpannableString(mw.toMarkdown(description)); } // Seen in the FOSDEM schedule: Markdown-ish but with paragraphs marked with both // whitespace and
tags. Well let's make it markdown then...
@@ -1329,7 +1333,7 @@ public Spanned getDescriptionSpanned(Context ctx) {
final Markwon mw = Markwon.builder(ctx)
.usePlugin(LinkifyPlugin.create()).build();
- return mw.toMarkdown(description);
+ return new SpannableString(mw.toMarkdown(description));
}
public AbstractList