1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Parse emoji better

This commit is contained in:
世界 2021-03-21 18:24:16 +08:00
parent 75f5a5e43e
commit 6da2d1167f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
25 changed files with 114 additions and 75 deletions

View File

@ -28,6 +28,8 @@ import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.UserObject;
import org.telegram.ui.Components.StaticLayoutEx;
public class SimpleTextView extends View implements Drawable.Callback {
@ -201,6 +203,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
protected boolean createLayout(int width) {
if (text != null) {
text = Emoji.replaceEmoji(text, textPaint.getFontMetricsInt(), (int) textPaint.getTextSize(), false);
try {
if (leftDrawable != null) {
width -= leftDrawable.getIntrinsicWidth();

View File

@ -36,6 +36,7 @@ import org.telegram.messenger.MessageObject;
import org.telegram.messenger.browser.Browser;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.LinkPath;
import org.telegram.ui.ActionBar.Theme;
@ -61,7 +62,7 @@ public class AboutLinkCell extends FrameLayout {
parentFragment = fragment;
valueTextView = new TextView(context);
valueTextView = new EmojiTextView(context);
valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
valueTextView.setLines(1);
@ -96,7 +97,6 @@ public class AboutLinkCell extends FrameLayout {
oldText = text;
stringBuilder = new SpannableStringBuilder(oldText);
MessageObject.addLinks(false, stringBuilder, false, false, !parseLinks);
Emoji.replaceEmoji(stringBuilder, Theme.profile_aboutTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
if (TextUtils.isEmpty(value)) {
valueTextView.setVisibility(GONE);
} else {

View File

@ -21,6 +21,7 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
@ -30,6 +31,7 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
public class AccountSelectCell extends FrameLayout {
@ -52,7 +54,7 @@ public class AccountSelectCell extends FrameLayout {
imageView.setRoundRadius(AndroidUtilities.dp(18));
addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 10, 10, 0, 0));
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setLines(1);
@ -66,7 +68,7 @@ public class AccountSelectCell extends FrameLayout {
textView.setTextColor(Theme.getColor(Theme.key_voipgroup_nameText));
textView.setText(LocaleController.getString("VoipGroupDisplayAs", R.string.VoipGroupDisplayAs));
infoTextView = new TextView(context);
infoTextView = new EmojiTextView(context);
infoTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_lastSeenText));
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
infoTextView.setLines(1);
@ -81,9 +83,9 @@ public class AccountSelectCell extends FrameLayout {
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
checkImageView = new ImageView(context);
checkImageView.setImageResource(R.drawable.baseline_check_24);
checkImageView.setImageResource(R.drawable.baseline_check_24);
checkImageView.setScaleType(ImageView.ScaleType.CENTER);
checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemCheck), PorterDuff.Mode.SRC_IN));
checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemCheck), PorterDuff.Mode.SRC_IN));
addView(checkImageView, LayoutHelper.createFrame(40, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 6, 0));
}
}
@ -125,7 +127,7 @@ public class AccountSelectCell extends FrameLayout {
avatarDrawable.setInfo(user);
textView.setText(ContactsController.formatName(user.first_name, user.last_name));
imageView.getImageReceiver().setCurrentAccount(account);
imageView.setImage(ImageLocation.getForUser(user,false), "50_50", avatarDrawable, user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
checkImageView.setVisibility(check && account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE);
}

View File

@ -32,6 +32,7 @@ import androidx.palette.graphics.Palette;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
@ -45,6 +46,7 @@ import org.telegram.ui.Components.AudioPlayerAlert;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.SnowflakesEffect;
@ -133,7 +135,7 @@ public class DrawerProfileCell extends FrameLayout {
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
nameTextView = new TextView(context);
nameTextView = new EmojiTextView(context);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameTextView.setLines(1);

View File

@ -24,10 +24,12 @@ import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationsController;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.GroupCreateCheckBox;
import org.telegram.ui.Components.LayoutHelper;
@ -51,7 +53,7 @@ public class DrawerUserCell extends FrameLayout {
imageView.setRoundRadius(AndroidUtilities.dp(18));
addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 14, 6, 0, 0));
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
@ -90,7 +92,7 @@ public class DrawerUserCell extends FrameLayout {
return;
}
avatarDrawable.setInfo(user);
textView.setText(Emoji.replaceEmoji(ContactsController.formatName(user.first_name, user.last_name), textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(15), false));
textView.setText(UserObject.getUserName(user));
imageView.getImageReceiver().setCurrentAccount(account);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
checkBox.setVisibility(account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE);

View File

@ -24,6 +24,7 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
public class MentionCell extends LinearLayout {
@ -45,7 +46,7 @@ public class MentionCell extends LinearLayout {
imageView.setRoundRadius(AndroidUtilities.dp(14));
addView(imageView, LayoutHelper.createLinear(28, 28, 12, 4, 0, 0));
nameTextView = new TextView(context);
nameTextView = new EmojiTextView(context);
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
nameTextView.setSingleLine(true);
@ -53,7 +54,7 @@ public class MentionCell extends LinearLayout {
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 0, 0));
usernameTextView = new TextView(context);
usernameTextView = new EmojiTextView(context);
usernameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
usernameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
usernameTextView.setSingleLine(true);
@ -132,7 +133,7 @@ public class MentionCell extends LinearLayout {
stringBuilder.append(suggestion.emoji);
stringBuilder.append(" :");
stringBuilder.append(suggestion.keyword);
nameTextView.setText(Emoji.replaceEmoji(stringBuilder, nameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
nameTextView.setText(stringBuilder);
}
public void setBotCommand(String command, String help, TLRPC.User user) {
@ -149,7 +150,7 @@ public class MentionCell extends LinearLayout {
}
usernameTextView.setVisibility(VISIBLE);
nameTextView.setText(command);
usernameTextView.setText(Emoji.replaceEmoji(help, usernameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
usernameTextView.setText(help);
}
public void setIsDarkTheme(boolean isDarkTheme) {

View File

@ -31,6 +31,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.messenger.SvgHelper;
@ -61,7 +62,7 @@ public class StickerEmojiCell extends FrameLayout {
imageView.setLayerNum(1);
addView(imageView, LayoutHelper.createFrame(66, 66, Gravity.CENTER));
emojiTextView = new TextView(context);
emojiTextView = new EmojiTextView(context);
emojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
addView(emojiTextView, LayoutHelper.createFrame(28, 28, Gravity.BOTTOM | Gravity.RIGHT));
setFocusable(true);
@ -116,7 +117,7 @@ public class StickerEmojiCell extends FrameLayout {
}
if (emoji != null) {
emojiTextView.setText(Emoji.replaceEmoji(emoji, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
emojiTextView.setText(emoji);
emojiTextView.setVisibility(VISIBLE);
} else if (showEmoji) {
boolean set = false;
@ -124,14 +125,14 @@ public class StickerEmojiCell extends FrameLayout {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.alt != null && attribute.alt.length() > 0) {
emojiTextView.setText(Emoji.replaceEmoji(attribute.alt, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
emojiTextView.setText(attribute.alt);
set = true;
}
break;
}
}
if (!set) {
emojiTextView.setText(Emoji.replaceEmoji(MediaDataController.getInstance(currentAccount).getEmojiForSticker(sticker.id), emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
emojiTextView.setText(MediaDataController.getInstance(currentAccount).getEmojiForSticker(sticker.id));
}
emojiTextView.setVisibility(VISIBLE);
} else {
@ -220,7 +221,7 @@ public class StickerEmojiCell extends FrameLayout {
TLRPC.DocumentAttribute attribute = sticker.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.alt != null && attribute.alt.length() > 0) {
emojiTextView.setText(Emoji.replaceEmoji(attribute.alt, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
emojiTextView.setText(attribute.alt);
descr = attribute.alt + " " + descr;
}
break;

View File

@ -27,6 +27,7 @@ import org.telegram.messenger.Emoji;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Components.ColorSpanUnderline;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
@ -58,7 +59,7 @@ public class StickerSetNameCell extends FrameLayout {
FrameLayout.LayoutParams lp;
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelStickerSetName));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
@ -134,7 +135,7 @@ public class StickerSetNameCell extends FrameLayout {
if (searchLength != 0) {
updateTextSearchSpan();
} else {
textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
textView.setText(text);
}
if (resId != 0) {
buttonView.setImageResource(resId);
@ -152,7 +153,7 @@ public class StickerSetNameCell extends FrameLayout {
builder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chat_emojiPanelStickerSetNameHighlight)), stickerSetNameSearchIndex, stickerSetNameSearchIndex + stickerSetNameSearchLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} catch (Exception ignore) {
}
textView.setText(Emoji.replaceEmoji(builder, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
textView.setText(builder);
}
}

View File

@ -21,6 +21,7 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.LocaleController;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
public class TextDetailCell extends FrameLayout {
@ -33,7 +34,7 @@ public class TextDetailCell extends FrameLayout {
public TextDetailCell(Context context) {
super(context);
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
@ -44,7 +45,7 @@ public class TextDetailCell extends FrameLayout {
textView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 23, 8, 23, 0));
valueTextView = new TextView(context);
valueTextView = new EmojiTextView(context);
valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
valueTextView.setLines(1);
@ -67,13 +68,6 @@ public class TextDetailCell extends FrameLayout {
setWillNotDraw(!needDivider);
}
public void setTextWithEmojiAndValue(String text, CharSequence value, boolean divider) {
textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
valueTextView.setText(value);
needDivider = divider;
setWillNotDraw(!divider);
}
public void setContentDescriptionValueFirst(boolean contentDescriptionValueFirst) {
this.contentDescriptionValueFirst = contentDescriptionValueFirst;
}

View File

@ -23,6 +23,7 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.LocaleController;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import cn.hutool.core.util.StrUtil;
@ -38,7 +39,7 @@ public class TextDetailSettingsCell extends FrameLayout {
public TextDetailSettingsCell(Context context) {
super(context);
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
@ -48,7 +49,7 @@ public class TextDetailSettingsCell extends FrameLayout {
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 10, 21, 0));
valueTextView = new TextView(context);
valueTextView = new EmojiTextView(context);
valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
@ -128,13 +129,6 @@ public class TextDetailSettingsCell extends FrameLayout {
valueTextView.setText(value);
}
public void setTextWithEmojiAnd21Value(String text, CharSequence value, boolean divider) {
textView.setText(Emoji.replaceEmoji(text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
valueTextView.setText(value);
needDivider = divider;
setWillNotDraw(!divider);
}
@Override
public void invalidate() {
super.invalidate();

View File

@ -454,7 +454,7 @@ public class UserCell extends FrameLayout {
if (currentName != null) {
lastName = null;
nameTextView.setText(Emoji.replaceEmoji(currentName, Theme.chat_namePaint.getFontMetricsInt(), AndroidUtilities.dp(16), false));
nameTextView.setText(currentName);
} else {
if (currentUser != null) {
lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
@ -463,7 +463,7 @@ public class UserCell extends FrameLayout {
} else {
lastName = "";
}
nameTextView.setText(Emoji.replaceEmoji(lastName, Theme.chat_namePaint.getFontMetricsInt(), AndroidUtilities.dp(16), false));
nameTextView.setText(lastName);
}
if (currentStatus != null) {
statusTextView.setTextColor(statusColor);

View File

@ -191,6 +191,7 @@ import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EditTextBoldCursor;
import org.telegram.ui.Components.EditTextCaption;
import org.telegram.ui.Components.EmbedBottomSheet;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.EmojiView;
import org.telegram.ui.Components.ExtendedGridLayoutManager;
import org.telegram.ui.Components.FireworksOverlay;
@ -5414,7 +5415,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
alertNameTextView.setMaxLines(1);
alertView.addView(alertNameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 8, 5, 8, 0));
alertTextView = new TextView(context);
alertTextView = new EmojiTextView(context);
alertTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
alertTextView.setTextColor(Theme.getColor(Theme.key_chat_topPanelMessage));
alertTextView.setSingleLine(true);
@ -9985,7 +9986,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
replyObjectTextView.setText(Emoji.replaceEmoji(mess, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
replyObjectTextView.setText(mess);
}
}
} else if (messageObjectToReply != null) {
@ -10034,14 +10035,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!TextUtils.isEmpty(restrictionReason)) {
replyObjectTextView.setText(restrictionReason);
} else if (messageObjectToReply.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
replyObjectTextView.setText(Emoji.replaceEmoji(messageObjectToReply.messageOwner.media.game.title, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
replyObjectTextView.setText(messageObjectToReply.messageOwner.media.game.title);
} else if (messageObjectToReply.messageText != null || messageObjectToReply.caption != null) {
String mess = messageObjectToReply.caption != null ? messageObjectToReply.caption.toString() : messageObjectToReply.messageText.toString();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
replyObjectTextView.setText(Emoji.replaceEmoji(mess, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
replyObjectTextView.setText(mess);
}
} else if (messageObjectsToForward != null) {
if (messageObjectsToForward.isEmpty()) {
@ -10140,14 +10141,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObjectsToForward.size() == 1 && messageObjectsToForward.get(0).messageText != null) {
MessageObject messageObject = messageObjectsToForward.get(0);
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
replyObjectTextView.setText(Emoji.replaceEmoji(messageObject.messageOwner.media.game.title, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
replyObjectTextView.setText(messageObject.messageOwner.media.game.title);
} else {
String mess = messageObject.messageText.toString();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
replyObjectTextView.setText(Emoji.replaceEmoji(mess, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
replyObjectTextView.setText(mess);
}
} else {
replyObjectTextView.setText(LocaleController.formatPluralString("ForwardedMessageCount", messageObjectsToForward.size()));
@ -16987,7 +16988,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
alertViewAnimator.start();
}
alertNameTextView.setText(name);
alertTextView.setText(Emoji.replaceEmoji(message.replace('\n', ' '), alertTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
alertTextView.setText(message.replace('\n', ' '));
if (hideAlertViewRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(hideAlertViewRunnable);
}
@ -17390,21 +17391,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
mess = mess.replace('\n', ' ');
messageTextView.setText(mess);
} else if (pinnedMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
messageTextView.setText(Emoji.replaceEmoji(pinnedMessageObject.messageOwner.media.game.title, messageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
messageTextView.setText(pinnedMessageObject.messageOwner.media.game.title);
} else if (!TextUtils.isEmpty(pinnedMessageObject.caption)) {
String mess = pinnedMessageObject.caption.toString();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
messageTextView.setText(Emoji.replaceEmoji(mess, messageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
messageTextView.setText(mess);
} else if (pinnedMessageObject.messageText != null) {
String mess = pinnedMessageObject.messageText.toString();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
messageTextView.setText(Emoji.replaceEmoji(mess, messageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
messageTextView.setText(mess);
}
if (animateToNext != 0) {
pinnedNextAnimation[0] = new AnimatorSet();

View File

@ -103,14 +103,14 @@ public class BotKeyboardView extends LinearLayout {
float weight = 1.0f / row.buttons.size();
for (int b = 0; b < row.buttons.size(); b++) {
TLRPC.KeyboardButton button = row.buttons.get(b);
TextView textView = new TextView(getContext());
TextView textView = new EmojiTextView(getContext());
textView.setTag(button);
textView.setTextColor(Theme.getColor(Theme.key_chat_botKeyboardButtonText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setGravity(Gravity.CENTER);
textView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_chat_botKeyboardButtonBackground), Theme.getColor(Theme.key_chat_botKeyboardButtonBackgroundPressed)));
textView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
textView.setText(Emoji.replaceEmoji(button.text, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(16), false));
textView.setText(button.text);
layout.addView(textView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, weight, 0, 0, b != row.buttons.size() - 1 ? 10 : 0, 0));
textView.setOnClickListener(v -> delegate.didPressedButton((TLRPC.KeyboardButton) v.getTag()));
buttonViews.add(textView);

View File

@ -341,7 +341,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
}
public void setTitle(CharSequence value, boolean scam, boolean fake) {
titleTextView.setText(Emoji.replaceEmoji(value, titleTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(18), false));
titleTextView.setText(value);
if (scam || fake) {
if (!(titleTextView.getRightDrawable() instanceof ScamDrawable)) {
ScamDrawable drawable = new ScamDrawable(11, scam ? 0 : 1);

View File

@ -0,0 +1,35 @@
package org.telegram.ui.Components;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import androidx.annotation.Nullable;
import org.telegram.messenger.Emoji;
public class EmojiTextView extends TextView {
public EmojiTextView(Context context) {
super(context);
}
public EmojiTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public EmojiTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public EmojiTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void setText(CharSequence text, BufferType type) {
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), (int) getTextSize(), false);
super.setText(text, type);
}
}

View File

@ -24,6 +24,7 @@ import android.widget.TextView;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject;
@ -114,7 +115,7 @@ public class JoinCallAlert extends BottomSheet {
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16));
for (int a = 0; a < 2; a++) {
textView[a] = new TextView(context);
textView[a] = new EmojiTextView(context);
textView[a].setLines(1);
textView[a].setSingleLine(true);
textView[a].setGravity(Gravity.CENTER_HORIZONTAL);

View File

@ -150,7 +150,7 @@ public class PollVotesAlert extends BottomSheet {
setBackgroundColor(Theme.getColor(Theme.key_graySection));
textView = new TextView(getContext());
textView = new EmojiTextView(getContext());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setTextColor(Theme.getColor(Theme.key_graySectionText));
@ -211,7 +211,7 @@ public class PollVotesAlert extends BottomSheet {
}
public void setText(String left, int percent, int votesCount, int collapsed) {
textView.setText(Emoji.replaceEmoji(left, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
textView.setText(left);
String p = String.format("%d", percent);
SpannableStringBuilder builder;
if (LocaleController.isRTL) {
@ -838,13 +838,13 @@ public class PollVotesAlert extends BottomSheet {
}
});
titleTextView = new TextView(context);
titleTextView = new EmojiTextView(context);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
titleTextView.setPadding(AndroidUtilities.dp(21), AndroidUtilities.dp(5), AndroidUtilities.dp(14), AndroidUtilities.dp(21));
titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
titleTextView.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
titleTextView.setText(Emoji.replaceEmoji(poll.question, titleTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(18), false));
titleTextView.setText(poll.question);
actionBar = new ActionBar(context) {
@Override

View File

@ -568,14 +568,14 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
TLRPC.DocumentAttribute attribute = selectedSticker.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.alt != null && attribute.alt.length() > 0) {
stickerEmojiTextView.setText(Emoji.replaceEmoji(attribute.alt, stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false));
stickerEmojiTextView.setText(attribute.alt);
set = true;
}
break;
}
}
if (!set) {
stickerEmojiTextView.setText(Emoji.replaceEmoji(MediaDataController.getInstance(currentAccount).getEmojiForSticker(selectedSticker.id), stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false));
stickerEmojiTextView.setText(MediaDataController.getInstance(currentAccount).getEmojiForSticker(selectedSticker.id));
}
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(selectedSticker.thumbs, 90);
@ -663,7 +663,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
stickerImageView.setLayerNum(7);
stickerPreviewLayout.addView(stickerImageView);
stickerEmojiTextView = new TextView(context);
stickerEmojiTextView = new EmojiTextView(context);
stickerEmojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
stickerEmojiTextView.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
stickerPreviewLayout.addView(stickerEmojiTextView);

View File

@ -188,14 +188,14 @@ public class UndoView extends FrameLayout {
super(context);
fromTop = top;
infoTextView = new TextView(context);
infoTextView = new EmojiTextView(context);
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
infoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
infoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
infoTextView.setMovementMethod(new LinkMovementMethodMy());
addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 45, 13, 0, 0));
subinfoTextView = new TextView(context);
subinfoTextView = new EmojiTextView(context);
subinfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
subinfoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
subinfoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
@ -1042,9 +1042,9 @@ public class UndoView extends FrameLayout {
} else {
String info = LocaleController.getServerString("DiceEmojiInfo_" + emoji);
if (!TextUtils.isEmpty(info)) {
infoTextView.setText(Emoji.replaceEmoji(info, infoTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
infoTextView.setText(info);
} else {
infoTextView.setText(Emoji.replaceEmoji(LocaleController.formatString("DiceEmojiInfo", R.string.DiceEmojiInfo, emoji), infoTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false));
infoTextView.setText(LocaleController.formatString("DiceEmojiInfo", R.string.DiceEmojiInfo, emoji));
}
}
leftImageView.setImageDrawable(Emoji.getEmojiDrawable(emoji));

View File

@ -279,7 +279,7 @@ public class FilterCreateActivity extends BaseFragment {
} else {
TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
paint.setTextSize(AndroidUtilities.dp(20));
actionBar.setTitle(Emoji.replaceEmoji(filter.name, paint.getFontMetricsInt(), AndroidUtilities.dp(20), false));
actionBar.setTitle(filter.name);
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override

View File

@ -37,6 +37,7 @@ import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.ProgressButton;
import org.telegram.ui.Components.RLottieImageView;
@ -257,7 +258,7 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
moveImageView.setClickable(true);
addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
textView = new TextView(context);
textView = new EmojiTextView(context);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
@ -342,7 +343,7 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
info.append(LocaleController.getString("FilterNoChats", R.string.FilterNoChats));
}
textView.setText(Emoji.replaceEmoji(filter.name, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
textView.setText(filter.name);
valueTextView.setText(info);
//valueTextView.setVisibility(VISIBLE);
needDivider = divider;

View File

@ -46,6 +46,7 @@ import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.IdenticonDrawable;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.ActionBar.Theme;
@ -177,7 +178,7 @@ public class IdenticonActivity extends BaseFragment implements NotificationCente
textView.setMovementMethod(new LinkMovementMethodMy());
linearLayout1.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
emojiTextView = new TextView(context);
emojiTextView = new EmojiTextView(context);
emojiTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
emojiTextView.setGravity(Gravity.CENTER);
emojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 32);
@ -313,7 +314,7 @@ public class IdenticonActivity extends BaseFragment implements NotificationCente
@Override
protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen && !backward && emojiText != null) {
emojiTextView.setText(Emoji.replaceEmoji(emojiText, emojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
emojiTextView.setText(emojiText);
}
}

View File

@ -405,7 +405,6 @@ public class MessageStatisticActivity extends BaseFragment implements Notificati
if (message.length() > 150) {
message = message.subSequence(0, 150);
}
message = Emoji.replaceEmoji(message, avatarContainer.getSubtitleTextView().getTextPaint().getFontMetricsInt(), AndroidUtilities.dp(17), false);
} else {
message = messageObject.messageText;
}

View File

@ -5782,7 +5782,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
String phoneString = PhoneFormat.getInstance().format("+" + user.phone);
nameTextView[a].setText(phoneString);
} else {
nameTextView[a].setText(Emoji.replaceEmoji(newString, nameTextView[a].getPaint().getFontMetricsInt(), AndroidUtilities.dp(18), false));
nameTextView[a].setText(newString);
}
if (a == 0 && onlineTextOverride != null) {
onlineTextView[a].setText(onlineTextOverride);

View File

@ -74,6 +74,7 @@ import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EmojiTextView;
import org.telegram.ui.Components.HintView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.voip.AcceptDeclineView;
@ -701,7 +702,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
callingUserPhotoViewMini.setRoundRadius(AndroidUtilities.dp(135) / 2);
callingUserPhotoViewMini.setVisibility(View.GONE);
callingUserTitle = new TextView(context);
callingUserTitle = new EmojiTextView(context);
callingUserTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
callingUserTitle.setText(ContactsController.formatName(callingUser.first_name, callingUser.last_name));
callingUserTitle.setShadowLayer(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(.666666667f), 0x4C000000);