fix mentions outside of content warnings not being clickable (#1405)

This commit is contained in:
Konrad Pozniak 2019-07-25 12:16:19 +02:00 committed by GitHub
parent f975522e63
commit b15b4fcf83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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());
}
/**