enable custom emojis in follow notifications

main
Conny Duck 7 years ago
parent 2e53b34612
commit 74fe29af4e
  1. 23
      app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java
  2. 2
      app/src/main/res/layout/item_follow.xml
  3. 3
      app/src/main/res/layout/item_status_notification.xml

@ -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)

@ -11,7 +11,7 @@
android:paddingLeft="14dp"
android:paddingRight="14dp">
<TextView
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/notification_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

@ -8,8 +8,7 @@
android:paddingLeft="14dp"
android:paddingRight="14dp">
<!--TODO: Check if this needs emoji support-->
<TextView
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/notification_top_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Loading…
Cancel
Save