From 241407887aa4b586795b1cbace78dace10fc0f44 Mon Sep 17 00:00:00 2001 From: PhotonQyv Date: Tue, 5 Sep 2017 20:37:11 +0100 Subject: [PATCH 1/2] Fixes an issue where a '/' on the end of a URL in a toot to be translated causes the __u?__ tag to remain after translation. --- .../fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index fb594168a..fece4861d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -356,6 +356,10 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf while (matcher.find()){ String key = "__u" + String.valueOf(i) + "__"; String value = matcher.group(0); + int end = matcher.end(); + if (spannableString.charAt(end) == '/') { + text = spannableString.toString().substring(0, end).concat(spannableString.toString().substring(end+1, spannableString.length())); + } if( value != null) { urlConversion.put(key, value); text = text.replace(value, key); From 3956ef680dca0ad7ff0f29869569d052842205a5 Mon Sep 17 00:00:00 2001 From: PhotonQyv Date: Tue, 5 Sep 2017 20:38:45 +0100 Subject: [PATCH 2/2] Reformatted the line of code to make it easier to see. --- .../fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index fece4861d..66ad660be 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -358,7 +358,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf String value = matcher.group(0); int end = matcher.end(); if (spannableString.charAt(end) == '/') { - text = spannableString.toString().substring(0, end).concat(spannableString.toString().substring(end+1, spannableString.length())); + text = spannableString.toString().substring(0, end). + concat(spannableString.toString().substring(end+1, spannableString.length())); } if( value != null) { urlConversion.put(key, value);