enable custom emojis in follow notifications

This commit is contained in:
Conny Duck 2018-07-01 15:57:26 +02:00
parent e63dd50682
commit c10cc59a8a
3 changed files with 15 additions and 13 deletions
app/src/main
java/com/keylesspalace/tusky/adapter
res/layout

View file

@ -38,6 +38,7 @@ import android.widget.TextView;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.entity.Account;
import com.keylesspalace.tusky.entity.Emoji; import com.keylesspalace.tusky.entity.Emoji;
import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Notification;
import com.keylesspalace.tusky.interfaces.LinkListener; import com.keylesspalace.tusky.interfaces.LinkListener;
@ -159,8 +160,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
} }
case FOLLOW: { case FOLLOW: {
FollowViewHolder holder = (FollowViewHolder) viewHolder; FollowViewHolder holder = (FollowViewHolder) viewHolder;
holder.setMessage(concreteNotificaton.getAccount().getName(), holder.setMessage(concreteNotificaton.getAccount(), bidiFormatter);
concreteNotificaton.getAccount().getUsername(), concreteNotificaton.getAccount().getAvatar(), bidiFormatter);
holder.setupButtons(notificationActionListener, concreteNotificaton.getAccount().getId()); holder.setupButtons(notificationActionListener, concreteNotificaton.getAccount().getId());
break; break;
} }
@ -268,25 +268,28 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
message.setCompoundDrawablesWithIntrinsicBounds(followIcon, null, null, null); 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(); Context context = message.getContext();
String format = context.getString(R.string.notification_follow_format); 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); 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); format = context.getString(R.string.status_username_format);
String wholeUsername = String.format(format, username); String username = String.format(format, account.getUsername());
usernameView.setText(wholeUsername); 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); avatar.setImageResource(R.drawable.avatar_default);
} else { } else {
Picasso.with(context) Picasso.with(context)
.load(avatarUrl) .load(account.getAvatar())
.fit() .fit()
.transform(new RoundedTransformation(25)) .transform(new RoundedTransformation(25))
.placeholder(R.drawable.avatar_default) .placeholder(R.drawable.avatar_default)

View file

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

View file

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