fix mentions outside of content warnings not being clickable (#1405)
This commit is contained in:
parent
f975522e63
commit
b15b4fcf83
1 changed files with 7 additions and 3 deletions
|
@ -20,6 +20,8 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.browser.customtabs.CustomTabsIntent;
|
import androidx.browser.customtabs.CustomTabsIntent;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
|
@ -81,7 +83,7 @@ public class LinkHelper {
|
||||||
final String tag = text.subSequence(1, text.length()).toString();
|
final String tag = text.subSequence(1, text.length()).toString();
|
||||||
customSpan = new ClickableSpanNoUnderline() {
|
customSpan = new ClickableSpanNoUnderline() {
|
||||||
@Override
|
@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) {
|
} else if (text.charAt(0) == '@' && mentions != null && mentions.length > 0) {
|
||||||
String accountUsername = text.subSequence(1, text.length()).toString();
|
String accountUsername = text.subSequence(1, text.length()).toString();
|
||||||
|
@ -101,7 +103,7 @@ public class LinkHelper {
|
||||||
final String accountId = id;
|
final String accountId = id;
|
||||||
customSpan = new ClickableSpanNoUnderline() {
|
customSpan = new ClickableSpanNoUnderline() {
|
||||||
@Override
|
@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();
|
final String accountId = mention.getId();
|
||||||
ClickableSpan customSpan = new ClickableSpanNoUnderline() {
|
ClickableSpan customSpan = new ClickableSpanNoUnderline() {
|
||||||
@Override
|
@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
|
end += 1 + accountUsername.length(); // length of @ + username
|
||||||
|
@ -175,6 +177,8 @@ public class LinkHelper {
|
||||||
start = end;
|
start = end;
|
||||||
}
|
}
|
||||||
view.setText(builder);
|
view.setText(builder);
|
||||||
|
view.setLinksClickable(true);
|
||||||
|
view.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue