From 8e7b12a23a17c85e54b807008b98a854dd85a0ba Mon Sep 17 00:00:00 2001 From: ZavaruKitsu Date: Sun, 22 Oct 2023 17:42:47 +0300 Subject: [PATCH] feat: add dev badges Co-authored-by: c0re100 --- Telegram/Resources/icons/ayu/exterabadge.png | Bin 0 -> 312 bytes .../Resources/icons/ayu/exterabadge@2x.png | Bin 0 -> 517 bytes .../Resources/icons/ayu/exterabadge@3x.png | Bin 0 -> 754 bytes Telegram/SourceFiles/ayu/ui/ayu_icons.style | 2 + .../ayu/ui/utils/ayu_profile_values.cpp | 9 +-- .../ayu/utils/telegram_helpers.cpp | 63 ++++++++++++++++++ .../SourceFiles/ayu/utils/telegram_helpers.h | 5 ++ .../chat_helpers/gifs_list_widget.cpp | 4 +- .../info/profile/info_profile_badge.cpp | 14 ++++ .../info/profile/info_profile_badge.h | 4 +- .../info/profile/info_profile_cover.cpp | 29 ++++++++ .../info/profile/info_profile_cover.h | 1 + 12 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 Telegram/Resources/icons/ayu/exterabadge.png create mode 100644 Telegram/Resources/icons/ayu/exterabadge@2x.png create mode 100644 Telegram/Resources/icons/ayu/exterabadge@3x.png diff --git a/Telegram/Resources/icons/ayu/exterabadge.png b/Telegram/Resources/icons/ayu/exterabadge.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6f6e38cd2175f85c7466613fc48c08b01f1353 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GG!XV7ZFl!D-1!HlL zyA#8@b22Z19F}xPUq=Rpjs4tz5?O)#vz{)FAr*{or{?n>RuDM4J~)7LY5@CM=7I(m z6$M644+o~82@NgMI+=&I1-#oeq4q{xQT(jezrV))G-hNt2I_Y@&>IjaYz zT1hrG4z{d@a&il%OcDD0@@GTfujS1~UjMZ}|8B4@UsZ7;{qxdyK#wtay85}Sb4q9e E0Ka^8M*si- literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/exterabadge@2x.png b/Telegram/Resources/icons/ayu/exterabadge@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..beb108eb7ecaa4bd6c35736e2b6314c0274fd6af GIT binary patch literal 517 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?3oVGw3ym^DWND9BhG zKQ$B+ufw==tYn+v4ps@8Y(^0Pe_XFSn)Izcl?Z({J{D1)gc{5^Vym z7xQO6_^o@akR{f|&C2)k*@<;WbynS$ufL?0V4W}gz^lq}`#(>nJD%$mr<^xrJh|lh zncoci8O&~d-#e)-!Y->^-R!1fsm5s`jW=8Y*HXE1Z!=B3oB3*&pQn?q{DsKY4;%`r zPBFD#Sf+ij>HoV>ZJnJ-o4vA^}u?)=a>omAhn-YJ{;MAG;eCML12s<055YDzw z4}}+a7);?`&)^ms+Rn=1o?gl5^Xh~uo2%uozopr09EDA A8vp``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&di3{35wE{-7;jBjV3Ej(l(;AU>m>cASnB8Fp{ChfmpEUW$B{w2{Z=Yx%w`ekc7o_6rFK7S+H z@oL)Hw8tio^u@kU`1niy;gvO_dn#_SK9xzH*BEOS`R&~)eF>2 z(=T(hwAM=8^Mkc@*7@gtOz*1o4ILxuG$-ttT@ZRd!g1jTPZzBj+s!_49P$#hY^*rR zd1%(zv_4@Vi|f%e6#@N9#|W81;jVBw$A}%K(d-K=o(i{kH(34l`gd{Sm7UK7Tb_R3 z9Lp2aKlLj2p{~wZ341)A<~COb_1L-ST*;^9Ai#6&Zcord1_@Z55WL z?~9J|et%l@^GkVPd!?yp0x1Pyr0iIrh7T2?w-*3eXjTG)Ac_YT^~ej zx&5~5`u5wre#?b@mS5gK-&6UQ+)=e8`7}k8B!D$t00rw9C*)j=)|$K)m_ivCJYD@< J);T3K0RU69HM9T# literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index b15d139e7..d3b7260fe 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -15,3 +15,5 @@ ayuMenuIcon: icon {{ "ayu/ayu_menu", menuIconColor }}; ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }}; ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }}; ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }}; + +infoExteraBadge: icon {{ "ayu/exterabadge", profileVerifiedCheckBg }}; diff --git a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp index 082d40c32..9e7b9bec9 100644 --- a/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp +++ b/Telegram/SourceFiles/ayu/ui/utils/ayu_profile_values.cpp @@ -6,6 +6,7 @@ // Copyright @Radolyn, 2023 #include "ayu_profile_values.h" #include "ayu/ayu_settings.h" +#include "ayu/utils/telegram_helpers.h" #include "data/data_peer.h" #include "ui/text/text_utilities.h" @@ -14,13 +15,7 @@ constexpr auto kMaxChannelId = -1000000000000; QString IDString(not_null peer) { - auto resultId = QString::number(peerIsUser(peer->id) - ? peerToUser(peer->id).bare - : peerIsChat(peer->id) - ? peerToChat(peer->id).bare - : peerIsChannel(peer->id) - ? peerToChannel(peer->id).bare - : peer->id.value); + auto resultId = QString::number(getBareID(peer)); const auto settings = &AyuSettings::getInstance(); if (settings->showPeerId == 2) { diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index a871a291d..9e0d1838f 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -24,6 +24,49 @@ #include "history/history_item.h" #include "history/history_unread_things.h" +// https://github.com/AyuGram/AyuGram4AX/blob/rewrite/TMessagesProj/src/main/java/com/radolyn/ayugram/AyuConstants.java +std::unordered_set ayugram_channels = { + 1905581924, // @ayugramchat + 1794457129, // @ayugram1338 + 1434550607, // @radolyn + 1947958814, // @ayugramfun + 1815864846, // @ayugramfcm +}; +std::unordered_set ayugram_devs = { + 139303278, // @alexeyzavar + 778327202, // @sharapagorg + 238292700, // @MaxPlays + 1795176335, // @radolyn_services +}; + +// https://github.com/AyuGram/AyuGram4AX/blob/rewrite/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java +std::unordered_set extera_channels = { + 1233768168, + 1524581881, + 1571726392, + 1632728092, + 1172503281, + 1877362358, + // custom + 1812843581, // @moeGramX + 1634905346, // @moex_log + 1516526055, // @moexci + 1622008530, // @moe_chat +}; +std::unordered_set extera_devs = { + 963080346, + 1282540315, + 1374434073, + 388099852, + 1972014627, + 168769611, + 480000401, + 639891381, + 1773117711, + 5330087923, + 666154369, + 139303278 +}; Main::Session *getSession(ID userId) { @@ -110,6 +153,26 @@ std::pair serializeTextWithEntities(not_null(buff.data()), buff.size())); } +ID getBareID(not_null peer) { + return peerIsUser(peer->id) + ? peerToUser(peer->id).bare + : peerIsChat(peer->id) + ? peerToChat(peer->id).bare + : peerIsChannel(peer->id) + ? peerToChannel(peer->id).bare + : peer->id.value; +} + +bool isAyuGramRelated(ID peerId) +{ + return ayugram_devs.contains(peerId) || ayugram_channels.contains(peerId); +} + +bool isExteraRelated(ID peerId) +{ + return extera_devs.contains(peerId) || extera_channels.contains(peerId); +} + void MarkAsReadChatList(not_null list) { auto mark = std::vector>(); diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h index 710bacb8d..167394ed2 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h @@ -21,6 +21,11 @@ not_null getHistoryFromDialogId(ID dialogId, Main::Session *session); ID getDialogIdFromPeer(not_null peer); std::pair serializeTextWithEntities(not_null item); +ID getBareID(not_null peer); + +bool isAyuGramRelated(ID peerId); +bool isExteraRelated(ID peerId); + void MarkAsReadChatList(not_null list); void MarkAsReadThread(not_null thread); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 280ca4dbd..f21834e10 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -45,8 +45,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include // AyuGram includes -#include -#include +#include "ayu/ayu_settings.h" +#include "ui/boxes/confirm_box.h" namespace ChatHelpers { diff --git a/Telegram/SourceFiles/info/profile/info_profile_badge.cpp b/Telegram/SourceFiles/info/profile/info_profile_badge.cpp index 1cbcef23e..d445e391e 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_badge.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_badge.cpp @@ -19,6 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "styles/style_info.h" +// AyuGram includes +#include "styles/style_ayu_icons.h" + + namespace Info::Profile { namespace { @@ -167,6 +171,16 @@ void Badge::setContent(Content content) { st::attentionButtonFg); }, _view->lifetime()); } break; + case BadgeType::AyuGram: + case BadgeType::Extera: { + const auto icon = &st::infoExteraBadge; + _view->resize(icon->size()); + _view->paintRequest( + ) | rpl::start_with_next([=, check = _view.data()]{ + Painter p(check); + icon->paint(p, 0, 0, check->width()); + }, _view->lifetime()); + } break; } if (_content.badge != BadgeType::Premium || !_premiumClickCallback) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_badge.h b/Telegram/SourceFiles/info/profile/info_profile_badge.h index f0e770d3f..0f275dae1 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_badge.h +++ b/Telegram/SourceFiles/info/profile/info_profile_badge.h @@ -41,6 +41,8 @@ enum class BadgeType { Premium = 0x02, Scam = 0x04, Fake = 0x08, + AyuGram = 0x10, + Extera = 0x20, }; inline constexpr bool is_flag_type(BadgeType) { return true; } @@ -83,9 +85,9 @@ public: [[nodiscard]] Data::CustomEmojiSizeTag sizeTag() const; -private: void setContent(Content content); +private: const not_null _parent; const style::InfoPeerBadge &_st; const not_null _session; diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index a15e49ccb..7c01e22b2 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -39,6 +39,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_info.h" #include "styles/style_dialogs.h" +// AyuGram includes +#include "ayu/utils/telegram_helpers.h" + + namespace Info::Profile { namespace { @@ -302,6 +306,16 @@ Cover::Cover( return controller->isGifPausedAtLeastFor( Window::GifPauseReason::Layer); })) +, _devBadge( + std::make_unique( + this, + st::infoPeerBadge, + peer, + _emojiStatusPanel.get(), + [=] { + return controller->isGifPausedAtLeastFor( + Window::GifPauseReason::Layer); + })) , _userpic(topic ? nullptr : object_ptr( @@ -344,6 +358,16 @@ Cover::Cover( refreshNameGeometry(width()); }, _name->lifetime()); + if (isAyuGramRelated(getBareID(_peer))) { + _devBadge->setContent(Info::Profile::Badge::Content{BadgeType::AyuGram}); + } + else if (isExteraRelated(getBareID(_peer))) { + _devBadge->setContent(Info::Profile::Badge::Content{BadgeType::Extera}); + } + else { + _devBadge->setContent(Info::Profile::Badge::Content{BadgeType::None}); + } + initViewers(std::move(title)); setupChildGeometry(); @@ -571,6 +595,11 @@ void Cover::refreshNameGeometry(int newWidth) { const auto badgeTop = _st.nameTop; const auto badgeBottom = _st.nameTop + _name->height(); _badge->move(badgeLeft, badgeTop, badgeBottom); + + const auto devBadgeLeft = badgeLeft + (_badge->widget() ? (_badge->widget()->width() + 2) : 0) + 4; + const auto devBadgeTop = _st.nameTop; + const auto devBadgeBottom = _st.nameTop + _name->height(); + _devBadge->move(devBadgeLeft, devBadgeTop, devBadgeBottom); } void Cover::refreshStatusGeometry(int newWidth) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.h b/Telegram/SourceFiles/info/profile/info_profile_cover.h index 42a40b190..49a928ed7 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.h +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.h @@ -141,6 +141,7 @@ private: const not_null _peer; const std::unique_ptr _emojiStatusPanel; const std::unique_ptr _badge; + const std::unique_ptr _devBadge; rpl::variable _onlineCount; object_ptr _userpic;