Fix an issue with URLs
This commit is contained in:
parent
9c6f477a17
commit
c3a00df067
|
@ -37,7 +37,6 @@ import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
import android.util.Patterns;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -183,7 +182,7 @@ public class SpannableHelper {
|
||||||
|
|
||||||
private static void linkify(Context context, SpannableStringBuilder content, HashMap<String, String> urlDetails) {
|
private static void linkify(Context context, SpannableStringBuilder content, HashMap<String, String> urlDetails) {
|
||||||
//--- URLs ----
|
//--- URLs ----
|
||||||
Matcher matcherLink = Patterns.WEB_URL.matcher(content);
|
Matcher matcherLink = urlPattern.matcher(content);
|
||||||
|
|
||||||
int offSetTruncate = 0;
|
int offSetTruncate = 0;
|
||||||
while (matcherLink.find()) {
|
while (matcherLink.find()) {
|
||||||
|
@ -245,8 +244,9 @@ public class SpannableHelper {
|
||||||
AlertDialog alertDialog = dialogBuilder.create();
|
AlertDialog alertDialog = dialogBuilder.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
String finalURl = url;
|
String finalURl = url;
|
||||||
if (urlDetails.containsValue(url)) {
|
String uniqueUrl = url.endsWith("…") ? url : url + "…";
|
||||||
finalURl = Helper.getKeyByValue(urlDetails, url);
|
if (urlDetails.containsValue(uniqueUrl)) {
|
||||||
|
finalURl = Helper.getKeyByValue(urlDetails, uniqueUrl);
|
||||||
}
|
}
|
||||||
String finalURl1 = finalURl;
|
String finalURl1 = finalURl;
|
||||||
popupLinksBinding.displayFullLink.setOnClickListener(v -> {
|
popupLinksBinding.displayFullLink.setOnClickListener(v -> {
|
||||||
|
@ -374,11 +374,13 @@ public class SpannableHelper {
|
||||||
public void onClick(@NonNull View textView) {
|
public void onClick(@NonNull View textView) {
|
||||||
String finalURl = newURL;
|
String finalURl = newURL;
|
||||||
String finalURl2 = url;
|
String finalURl2 = url;
|
||||||
if (urlDetails.containsValue(newURL + "…")) {
|
String uniqueNewURL = newURL.endsWith("…") ? newURL : newURL + "…";
|
||||||
finalURl = Helper.getKeyByValue(urlDetails, newURL + "…");
|
if (urlDetails.containsValue(uniqueNewURL)) {
|
||||||
|
finalURl = Helper.getKeyByValue(urlDetails, uniqueNewURL);
|
||||||
}
|
}
|
||||||
if (urlDetails.containsValue(url + "…")) {
|
String uniqueUrl = url.endsWith("…") ? url : url + "…";
|
||||||
finalURl2 = Helper.getKeyByValue(urlDetails, url + "…");
|
if (urlDetails.containsValue(uniqueUrl)) {
|
||||||
|
finalURl2 = Helper.getKeyByValue(urlDetails, uniqueUrl);
|
||||||
}
|
}
|
||||||
textView.setTag(CLICKABLE_SPAN);
|
textView.setTag(CLICKABLE_SPAN);
|
||||||
Pattern link = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w._-]*[0-9]*)(/[0-9]+)?$");
|
Pattern link = Pattern.compile("https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[\\w._-]*[0-9]*)(/[0-9]+)?$");
|
||||||
|
|
Loading…
Reference in New Issue