From 590cfbbcd2078114aac0b961f2687f96cbe8dc10 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Thu, 25 Jul 2019 12:16:19 +0200 Subject: [PATCH] fix mentions outside of content warnings not being clickable (#1405) --- .../java/com/keylesspalace/tusky/util/LinkHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java index 8fe257be..dbf6be4c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.java @@ -20,6 +20,8 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.preference.PreferenceManager; + +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.browser.customtabs.CustomTabsIntent; import android.text.SpannableStringBuilder; @@ -81,7 +83,7 @@ public class LinkHelper { final String tag = text.subSequence(1, text.length()).toString(); customSpan = new ClickableSpanNoUnderline() { @Override - public void onClick(View widget) { listener.onViewTag(tag); } + public void onClick(@NonNull View widget) { listener.onViewTag(tag); } }; } else if (text.charAt(0) == '@' && mentions != null && mentions.length > 0) { String accountUsername = text.subSequence(1, text.length()).toString(); @@ -101,7 +103,7 @@ public class LinkHelper { final String accountId = id; customSpan = new ClickableSpanNoUnderline() { @Override - public void onClick(View widget) { listener.onViewAccount(accountId); } + public void onClick(@NonNull View widget) { listener.onViewAccount(accountId); } }; } } @@ -155,7 +157,7 @@ public class LinkHelper { final String accountId = mention.getId(); ClickableSpan customSpan = new ClickableSpanNoUnderline() { @Override - public void onClick(View widget) { listener.onViewAccount(accountId); } + public void onClick(@NonNull View widget) { listener.onViewAccount(accountId); } }; end += 1 + accountUsername.length(); // length of @ + username @@ -175,6 +177,8 @@ public class LinkHelper { start = end; } view.setText(builder); + view.setLinksClickable(true); + view.setMovementMethod(LinkMovementMethod.getInstance()); } /**