diff --git a/Telegram/Resources/icons/ayu/exterabadge.png b/Telegram/Resources/icons/ayu/exterabadge.png new file mode 100644 index 000000000..3e6f6e38c Binary files /dev/null and b/Telegram/Resources/icons/ayu/exterabadge.png differ diff --git a/Telegram/Resources/icons/ayu/exterabadge@2x.png b/Telegram/Resources/icons/ayu/exterabadge@2x.png new file mode 100644 index 000000000..beb108eb7 Binary files /dev/null and b/Telegram/Resources/icons/ayu/exterabadge@2x.png differ diff --git a/Telegram/Resources/icons/ayu/exterabadge@3x.png b/Telegram/Resources/icons/ayu/exterabadge@3x.png new file mode 100644 index 000000000..d2bfba122 Binary files /dev/null and b/Telegram/Resources/icons/ayu/exterabadge@3x.png differ 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;