fix notification message formatting when username is not at the beginning of the message (#2522)

* fix notification message formatting when username is not at the beginning of the message

* search for placeholder in format string
This commit is contained in:
Konrad Pozniak 2022-05-13 22:00:30 +02:00 committed by GitHub
parent ec2eae9e89
commit 8c6ccf4261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -531,8 +531,13 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
message.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); message.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
String wholeMessage = String.format(format, displayName); String wholeMessage = String.format(format, displayName);
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage); final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
str.setSpan(new StyleSpan(Typeface.BOLD), 0, displayName.length(), int displayNameIndex = format.indexOf("%s");
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); str.setSpan(
new StyleSpan(Typeface.BOLD),
displayNameIndex,
displayNameIndex + displayName.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
);
CharSequence emojifiedText = CustomEmojiHelper.emojify( CharSequence emojifiedText = CustomEmojiHelper.emojify(
str, notificationViewData.getAccount().getEmojis(), message, statusDisplayOptions.animateEmojis() str, notificationViewData.getAccount().getEmojis(), message, statusDisplayOptions.animateEmojis()
); );