Fix URL issue
This commit is contained in:
parent
6e032ee48e
commit
dbd7bf6f88
|
@ -423,6 +423,7 @@ public class Status implements Parcelable {
|
|||
HashMap<String, String> targetedURL = new HashMap<>();
|
||||
HashMap<String, Account> accountsMentionUnknown = new HashMap<>();
|
||||
String liveInstance = Helper.getLiveInstance(context);
|
||||
int i = 1;
|
||||
while (matcher.find()) {
|
||||
String key;
|
||||
|
||||
|
@ -433,14 +434,14 @@ public class Status implements Parcelable {
|
|||
key = key.substring(1);
|
||||
|
||||
if (!key.startsWith("#") && !key.startsWith("@") && !key.trim().equals("") && !Objects.requireNonNull(matcher.group(2)).contains("search?tag=") && !Objects.requireNonNull(matcher.group(2)).contains(liveInstance + "/users/")) {
|
||||
|
||||
String url;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
url = Html.fromHtml(matcher.group(2), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
} else {
|
||||
url = Html.fromHtml(matcher.group(2)).toString();
|
||||
}
|
||||
targetedURL.put(key, url);
|
||||
targetedURL.put(key + "|" + i, url);
|
||||
i++;
|
||||
} else if (key.startsWith("@") || Objects.requireNonNull(matcher.group(2)).contains(liveInstance + "/users/")) {
|
||||
String acct;
|
||||
String url;
|
||||
|
@ -603,14 +604,19 @@ public class Status implements Parcelable {
|
|||
}
|
||||
if (targetedURL.size() > 0) {
|
||||
Iterator it = targetedURL.entrySet().iterator();
|
||||
int endPosition = 0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry pair = (Map.Entry) it.next();
|
||||
String key = (String) pair.getKey();
|
||||
String key = ((String) pair.getKey()).split("\\|")[0];
|
||||
|
||||
String url = (String) pair.getValue();
|
||||
if (spannableStringT.toString().toLowerCase().contains(key.toLowerCase())) {
|
||||
//Accounts can be mentioned several times so we have to loop
|
||||
int startPosition = spannableStringT.toString().toLowerCase().indexOf(key.toLowerCase());
|
||||
int endPosition = startPosition + key.length();
|
||||
int startPosition = spannableStringT.toString().toLowerCase().indexOf(key.toLowerCase(), endPosition);
|
||||
if (startPosition < 0) {
|
||||
startPosition = 0;
|
||||
}
|
||||
endPosition = startPosition + key.length();
|
||||
if (key.contains("…") && !key.endsWith("…")) {
|
||||
key = key.split("…")[0] + "…";
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder();
|
||||
|
|
Loading…
Reference in New Issue