feat: add dev badges

Co-authored-by: c0re100 <corehusky@gmail.com>
This commit is contained in:
ZavaruKitsu 2023-10-22 17:42:47 +03:00
parent b2ce1d2d15
commit 8e7b12a23a
12 changed files with 121 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

View file

@ -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 }};

View file

@ -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<PeerData *> 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) {

View file

@ -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<ID> ayugram_channels = {
1905581924, // @ayugramchat
1794457129, // @ayugram1338
1434550607, // @radolyn
1947958814, // @ayugramfun
1815864846, // @ayugramfcm
};
std::unordered_set<ID> 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<ID> extera_channels = {
1233768168,
1524581881,
1571726392,
1632728092,
1172503281,
1877362358,
// custom
1812843581, // @moeGramX
1634905346, // @moex_log
1516526055, // @moexci
1622008530, // @moe_chat
};
std::unordered_set<ID> 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<std::string, std::string> serializeTextWithEntities(not_null<HistoryIt
return std::make_pair(text, std::string(reinterpret_cast<char *>(buff.data()), buff.size()));
}
ID getBareID(not_null<PeerData *> 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<Dialogs::MainList *> list)
{
auto mark = std::vector<not_null<History *>>();

View file

@ -21,6 +21,11 @@ not_null<History *> getHistoryFromDialogId(ID dialogId, Main::Session *session);
ID getDialogIdFromPeer(not_null<PeerData *> peer);
std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryItem *> item);
ID getBareID(not_null<PeerData *> peer);
bool isAyuGramRelated(ID peerId);
bool isExteraRelated(ID peerId);
void MarkAsReadChatList(not_null<Dialogs::MainList *> list);
void MarkAsReadThread(not_null<Data::Thread *> thread);

View file

@ -45,8 +45,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QApplication>
// AyuGram includes
#include <ayu/ayu_settings.h>
#include <ui/boxes/confirm_box.h>
#include "ayu/ayu_settings.h"
#include "ui/boxes/confirm_box.h"
namespace ChatHelpers {

View file

@ -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) {

View file

@ -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<QWidget*> _parent;
const style::InfoPeerBadge &_st;
const not_null<Main::Session*> _session;

View file

@ -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<Badge>(
this,
st::infoPeerBadge,
peer,
_emojiStatusPanel.get(),
[=] {
return controller->isGifPausedAtLeastFor(
Window::GifPauseReason::Layer);
}))
, _userpic(topic
? nullptr
: object_ptr<Ui::UserpicButton>(
@ -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) {

View file

@ -141,6 +141,7 @@ private:
const not_null<PeerData*> _peer;
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;
const std::unique_ptr<Badge> _badge;
const std::unique_ptr<Badge> _devBadge;
rpl::variable<int> _onlineCount;
object_ptr<Ui::UserpicButton> _userpic;