From 74fe29af4eb2ec4c58c2ddae07fc3704276e97ee Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sun, 1 Jul 2018 15:57:26 +0200 Subject: [PATCH] enable custom emojis in follow notifications --- .../tusky/adapter/NotificationsAdapter.java | 23 +++++++++++-------- app/src/main/res/layout/item_follow.xml | 2 +- .../res/layout/item_status_notification.xml | 3 +-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java index 4367af73..2ad42ec6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java @@ -38,6 +38,7 @@ import android.widget.TextView; import android.widget.ToggleButton; import com.keylesspalace.tusky.R; +import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Emoji; import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.interfaces.LinkListener; @@ -159,8 +160,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { } case FOLLOW: { FollowViewHolder holder = (FollowViewHolder) viewHolder; - holder.setMessage(concreteNotificaton.getAccount().getName(), - concreteNotificaton.getAccount().getUsername(), concreteNotificaton.getAccount().getAvatar(), bidiFormatter); + holder.setMessage(concreteNotificaton.getAccount(), bidiFormatter); holder.setupButtons(notificationActionListener, concreteNotificaton.getAccount().getId()); break; } @@ -268,25 +268,28 @@ public class NotificationsAdapter extends RecyclerView.Adapter { message.setCompoundDrawablesWithIntrinsicBounds(followIcon, null, null, null); } - void setMessage(String displayName, String username, String avatarUrl, BidiFormatter bidiFormatter) { + void setMessage(Account account, BidiFormatter bidiFormatter) { Context context = message.getContext(); String format = context.getString(R.string.notification_follow_format); - String wrappedDisplayName = bidiFormatter.unicodeWrap(displayName); + String wrappedDisplayName = bidiFormatter.unicodeWrap(account.getName()); String wholeMessage = String.format(format, wrappedDisplayName); - message.setText(wholeMessage); + CharSequence emojifiedMessage = CustomEmojiHelper.emojifyString(wholeMessage, account.getEmojis(), message); + message.setText(emojifiedMessage); format = context.getString(R.string.status_username_format); - String wholeUsername = String.format(format, username); - usernameView.setText(wholeUsername); + String username = String.format(format, account.getUsername()); + usernameView.setText(username); - displayNameView.setText(wrappedDisplayName); + CharSequence emojifiedDisplayName = CustomEmojiHelper.emojifyString(wrappedDisplayName, account.getEmojis(), usernameView); - if (TextUtils.isEmpty(avatarUrl)) { + displayNameView.setText(emojifiedDisplayName); + + if (TextUtils.isEmpty(account.getAvatar())) { avatar.setImageResource(R.drawable.avatar_default); } else { Picasso.with(context) - .load(avatarUrl) + .load(account.getAvatar()) .fit() .transform(new RoundedTransformation(25)) .placeholder(R.drawable.avatar_default) diff --git a/app/src/main/res/layout/item_follow.xml b/app/src/main/res/layout/item_follow.xml index d3a19338..4f19d593 100644 --- a/app/src/main/res/layout/item_follow.xml +++ b/app/src/main/res/layout/item_follow.xml @@ -11,7 +11,7 @@ android:paddingLeft="14dp" android:paddingRight="14dp"> - - -