Skip to content

Commit

Permalink
feat: open sticker owner profile
Browse files Browse the repository at this point in the history
Co-authored-by: kukuruzka <[email protected]>
  • Loading branch information
omg-xtao and kukuruzka165 committed Sep 7, 2024
1 parent fa4e1d3 commit 0393a01
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -1451,6 +1454,38 @@ protected void onSend(androidx.collection.LongSparseArray<TLRPC.Dialog> 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);
}
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1479,6 +1481,25 @@ protected void onSend(LongSparseArray<TLRPC.Dialog> 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);
}
}
}

Expand Down

0 comments on commit 0393a01

Please sign in to comment.