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
2 people authored and NextAlone committed Sep 7, 2024
1 parent 660b5f3 commit f717dd7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,25 @@ protected void onSend(androidx.collection.LongSparseArray<TLRPC.Dialog> dids, in
} catch (Exception e) {
FileLog.e(e);
}
} 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 @@ -1538,6 +1557,8 @@ public void updatePressedProgress() {
}
}

private final int menu_user_profile = 105;

private class EmojiPackHeader extends FrameLayout {

public LinkSpanDrawable.LinksTextView titleView;
Expand Down Expand Up @@ -1677,6 +1698,7 @@ 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_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 @@ -176,6 +176,8 @@ public interface StickersAlertCustomButtonDelegate {
public boolean probablyEmojis;
private boolean isEditModeEnabled;

private final int menu_user_profile = 105;

public TLRPC.TL_messages_stickerSet stickerSet;
private TLRPC.Document selectedSticker;
private SendMessagesHelper.ImportingSticker selectedStickerPath;
Expand Down Expand Up @@ -1129,6 +1131,7 @@ public void requestLayout() {
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(3, R.drawable.media_download, LocaleController.getString("Save", R.string.Save));
optionsButton.addSubItem(menu_user_profile, R.drawable.msg_openprofile, LocaleController.getString("ChannelAdmin", R.string.ChannelAdmin));

optionsButton.setOnClickListener(v -> {
checkOptions();
Expand Down Expand Up @@ -1431,6 +1434,25 @@ protected void onSend(LongSparseArray<TLRPC.Dialog> dids, int count, TLRPC.TL_fo
dismiss();
MediaDataController.getInstance(currentAccount).toggleStickerSet(getContext(), stickerSet, 1, parentFragment, false, false);
});
} 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 f717dd7

Please sign in to comment.