Browse Source

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
pull/2535/head
Konrad Pozniak 4 years ago committed by GitHub
parent
commit
8c6ccf4261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java

9
app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java

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

Loading…
Cancel
Save