From b02156548d40c9675db8656b044481da5246a56f Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 13 Apr 2024 21:52:20 +0800 Subject: [PATCH] fix: via bot usernames cannot show --- .../main/java/org/telegram/ui/Cells/ChatMessageCell.java | 9 +++++---- .../src/main/java/org/telegram/ui/ChatActivity.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 71ff1dbdbc..5040590627 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -1811,7 +1811,7 @@ private boolean checkNameMotionEvent(MotionEvent event) { if (currentViaBotUser != null && currentViaBotUser.bot_inline_placeholder == null) { delegate.didPressViaBotNotInline(this, currentViaBotUser != null ? currentViaBotUser.id : 0); } else { - delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name); + delegate.didPressViaBot(this, currentViaBotUser != null ? UserObject.getPublicUsername(currentViaBotUser) : currentMessageObject.messageOwner.via_bot_name); } } else if (currentUser != null) { delegate.didPressUserAvatar(this, currentUser, event.getX(), event.getY()); @@ -3880,7 +3880,7 @@ public boolean onTouchEvent(MotionEvent event) { if (currentViaBotUser != null && currentViaBotUser.bot_inline_placeholder == null) { delegate.didPressViaBotNotInline(this, currentViaBotUser != null ? currentViaBotUser.id : 0); } else { - delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name); + delegate.didPressViaBot(this, currentViaBotUser != null ? UserObject.getPublicUsername(currentViaBotUser) : currentMessageObject.messageOwner.via_bot_name); } } } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { @@ -14854,8 +14854,9 @@ private void setMessageObjectInternal(MessageObject messageObject) { CharSequence viaString = null; if (messageObject.messageOwner.via_bot_id != 0) { TLRPC.User botUser = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.via_bot_id); - if (botUser != null && !TextUtils.isEmpty(botUser.username)) { - viaUsername = "@" + botUser.username; + // na: fix via bot usernames + if (botUser != null && UserObject.getPublicUsername(botUser) != null) { + viaUsername = "@" + UserObject.getPublicUsername(botUser); viaString = AndroidUtilities.replaceTags(String.format(" %s %s", LocaleController.getString("ViaBot", R.string.ViaBot), viaUsername)); viaWidth = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(viaString, 0, viaString.length())); currentViaBotUser = botUser; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 15eeb26231..10378616fb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -22675,7 +22675,7 @@ public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline button) { if (inlineReturn == 0 || button.same_peer || parentLayout == null) { return false; } - String query = "@" + currentUser.username + " " + button.query; + String query = "@" + UserObject.getPublicUsername(currentUser) + " " + button.query; if (inlineReturn == dialog_id) { inlineReturn = 0; chatActivityEnterView.setFieldText(query);