From 0393a01ab7cc7cd42af8dbbedfdfd9e42747e8e9 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 7 Sep 2024 22:52:42 +0800 Subject: [PATCH] feat: open sticker owner profile Co-authored-by: kukuruzka <60149954+kukuruzka165@users.noreply.github.com> --- .../ui/Components/EmojiPacksAlert.java | 40 +++++++++++++++++++ .../telegram/ui/Components/StickersAlert.java | 21 ++++++++++ 2 files changed, 61 insertions(+) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java index 43ac1e3333..41d0bd52c8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java @@ -6,6 +6,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; @@ -67,6 +68,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.Cells.StickerEmojiCell; import org.telegram.ui.ChatActivity; import org.telegram.ui.Components.Premium.PremiumButtonView; import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet; @@ -80,6 +82,7 @@ import java.util.regex.Pattern; import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.utils.ProxyUtil; public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate { @@ -1451,6 +1454,38 @@ protected void onSend(androidx.collection.LongSparseArray dids, in } catch (Exception e) { FileLog.e(e); } + } else if (id == menu_qrcode) { + for (int i = 0, size = listView.getChildCount(); i < size; i++) { + final View child = listView.getChildAt(i); + if (child instanceof EmojiImageView) { + if (((EmojiImageView) child).imageReceiver != null) { + Bitmap bitmap = ((EmojiImageView) child).imageReceiver.getBitmap(); + if (bitmap == null) continue; + ProxyUtil.showQrDialog(getContext(), stickersUrl, imageSize -> Bitmap.createScaledBitmap(bitmap, imageSize, imageSize, true)); + return; + } + } + } + ProxyUtil.showQrDialog(getContext(), stickersUrl); + } else if (id == menu_user_profile) { + // Na: open sticker's admin user profile or copy admin userId + long userId = stickerSet.set.id >> 32; + if ((stickerSet.set.id >> 24 & 0xff) != 0) { + userId += 0x100000000L; + } + if (fragment != null) { + TLRPC.User user = fragment.getMessagesController().getUser(userId); + if (user != null) { + MessagesController.getInstance(currentAccount).openChatOrProfileWith(user, null, fragment, 0, false); + return; + } + } + try { + AndroidUtilities.addToClipboard("" + userId); + BulletinFactory.of((FrameLayout) containerView, resourcesProvider).createCopyLinkBulletin().show(); + } catch (Exception e) { + FileLog.e(e); + } } } @@ -1527,6 +1562,9 @@ public void updatePressedProgress() { } } + private final int menu_qrcode = 104; + private final int menu_user_profile = 105; + private class EmojiPackHeader extends FrameLayout { public LinkSpanDrawable.LinksTextView titleView; @@ -1666,6 +1704,8 @@ public EmojiPackHeader(Context context, boolean single) { addView(optionsButton, LayoutHelper.createFrame(40, 40, Gravity.TOP | Gravity.RIGHT, 0, 5, 5 - backgroundPaddingLeft / AndroidUtilities.density, 0)); optionsButton.addSubItem(1, R.drawable.msg_share, LocaleController.getString("StickersShare", R.string.StickersShare)); optionsButton.addSubItem(2, R.drawable.msg_link, LocaleController.getString("CopyLink", R.string.CopyLink)); + optionsButton.addSubItem(menu_qrcode, R.drawable.msg_qrcode, LocaleController.getString("ShareQRCode", R.string.ShareQRCode)); + optionsButton.addSubItem(menu_user_profile, R.drawable.msg_openprofile, LocaleController.getString("ChannelAdmin", R.string.ChannelAdmin)); optionsButton.setOnClickListener(v -> optionsButton.toggleSubMenu()); optionsButton.setDelegate(EmojiPacksAlert.this::onSubItemClick); optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java index 2968f548a8..30a0519b4a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java @@ -187,6 +187,7 @@ public interface StickersAlertCustomButtonDelegate { private final int menuDeleteExternalCache = 101; private final int menu_copy_sticker_set = 103; private final int menu_qrcode = 104; + private final int menu_user_profile = 105; public TLRPC.TL_messages_stickerSet stickerSet; private TLRPC.Document selectedSticker; @@ -1147,6 +1148,7 @@ public void requestLayout() { optionsButton.addSubItem(menuDeleteExternalCache, R.drawable.msg_delete, LocaleController.getString(R.string.ExternalStickerCacheDelete)); } optionsButton.addSubItem(menu_copy_sticker_set, R.drawable.msg_copy, LocaleController.getString(R.string.StickersCopyStickerSet)); + optionsButton.addSubItem(menu_user_profile, R.drawable.msg_openprofile, LocaleController.getString("ChannelAdmin", R.string.ChannelAdmin)); optionsButton.setOnClickListener(v -> { checkOptions(); @@ -1479,6 +1481,25 @@ protected void onSend(LongSparseArray dids, int count, TLRPC.TL_fo } }); }); + } else if (id == menu_user_profile) { + // Na: open sticker's admin user profile or copy admin userId + long userId = stickerSet.set.id >> 32; + if ((stickerSet.set.id >> 24 & 0xff) != 0) { + userId += 0x100000000L; + } + if (parentFragment != null) { + TLRPC.User user = parentFragment.getMessagesController().getUser(userId); + if (user != null) { + MessagesController.getInstance(currentAccount).openChatOrProfileWith(user, null, parentFragment, 0, false); + return; + } + } + try { + AndroidUtilities.addToClipboard("" + userId); + BulletinFactory.of((FrameLayout) containerView, resourcesProvider).createCopyLinkBulletin().show(); + } catch (Exception e) { + FileLog.e(e); + } } }