diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 9b9b567eef..ff5d87bc69 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -174,6 +174,8 @@ PRIVATE boxes/peers/edit_peer_permissions_box.h boxes/about_box.cpp boxes/about_box.h + boxes/about_sponsored_box.cpp + boxes/about_sponsored_box.h boxes/abstract_box.cpp boxes/abstract_box.h boxes/add_contact_box.cpp diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 01003683b3..2076d26448 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2894,6 +2894,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_view_button_group" = "View group"; "lng_view_button_channel" = "View channel"; +"lng_sponsored_title" = "What are sponsored messages?"; +"lng_sponsored_info_description1" = "Unlike other apps, Telegram never uses your private data to target ads. You are seeing this message only because someone chose this public one-to-many channel as a space to promote their messages. This means that no user data is mined or analyzed to display ads, and every user viewing a channel on Telegram sees the same sponsored message."; +"lng_sponsored_info_description2" = "Unlike other apps, Telegram doesn\'t track whether you tapped on a sponsored message and doesn\'t profile you based on your activity. We also prevent external links in sponsored messages to ensure that third parties can’t spy on our users. We believe that everyone has the right to privacy, and technological platforms should respect that."; +"lng_sponsored_info_description3" = "Telegram offers free and unlimited service to hundreds of millions of users, which involves significant server and traffic costs. In order to remain independent and stay true to its values, Telegram developed a paid tool to promote messages with user privacy in mind. We welcome responsible advertisers at:"; +"lng_sponsored_info_description4" = "Ads should no longer be synonymous with abuse of user privacy. Let us redefine how a tech company should operate – together."; + // Wnd specific "lng_wnd_choose_program_menu" = "Choose Default Program..."; diff --git a/Telegram/SourceFiles/boxes/about_sponsored_box.cpp b/Telegram/SourceFiles/boxes/about_sponsored_box.cpp new file mode 100644 index 0000000000..36cf49e904 --- /dev/null +++ b/Telegram/SourceFiles/boxes/about_sponsored_box.cpp @@ -0,0 +1,76 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "boxes/about_sponsored_box.h" + +#include "lang/lang_keys.h" +#include "ui/widgets/buttons.h" +#include "ui/widgets/labels.h" +#include "styles/style_boxes.h" +#include "styles/style_layers.h" + +#include + +namespace Ui { +namespace { + +constexpr auto kUrl = "https://telegram.org/ads"_cs; + +} // namespace + +void AboutSponsoredBox(not_null box) { + box->setTitle(tr::lng_sponsored_title()); + box->setWidth(st::boxWideWidth); + box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); }); + + const auto addUrl = [&] { + const auto &st = st::sponsoredUrlButton; + const auto row = box->addRow(object_ptr(box)); + row->resize(0, st.height + st.padding.top() + st.padding.bottom()); + const auto button = Ui::CreateChild( + row, + rpl::single(kUrl.utf8()), + st); + button->setBrushOverride(Qt::NoBrush); + button->setPenOverride(QPen(st::historyLinkInFg)); + button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); + rpl::combine( + row->sizeValue(), + button->sizeValue() + ) | rpl::start_with_next([=]( + const QSize &rowSize, + const QSize &buttonSize) { + button->moveToLeft( + (rowSize.width() - buttonSize.width()) / 2, + (rowSize.height() - buttonSize.height()) / 2); + }, row->lifetime()); + button->addClickHandler([=] { + QDesktopServices::openUrl({ kUrl.utf8() }); + }); + }; + + const auto &stLabel = st::aboutLabel; + const auto info1 = box->addRow(object_ptr(box, stLabel)); + info1->setText(tr::lng_sponsored_info_description1(tr::now)); + box->addSkip(st::sponsoredInfoSkip); + + const auto info2 = box->addRow(object_ptr(box, stLabel)); + info2->setText(tr::lng_sponsored_info_description2(tr::now)); + box->addSkip(st::sponsoredInfoSkip); + + const auto info3 = box->addRow(object_ptr(box, stLabel)); + info3->setText(tr::lng_sponsored_info_description3(tr::now)); + box->addSkip(st::sponsoredUrlButtonSkip); + + addUrl(); + box->addSkip(st::sponsoredUrlButtonSkip); + + const auto info4 = box->addRow(object_ptr(box, stLabel)); + info4->setText(tr::lng_sponsored_info_description4(tr::now)); +} + +} // namespace Ui diff --git a/Telegram/SourceFiles/boxes/about_sponsored_box.h b/Telegram/SourceFiles/boxes/about_sponsored_box.h new file mode 100644 index 0000000000..b6686b0ce2 --- /dev/null +++ b/Telegram/SourceFiles/boxes/about_sponsored_box.h @@ -0,0 +1,16 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "ui/layers/generic_box.h" + +namespace Ui { + +void AboutSponsoredBox(not_null box); + +} // namespace Ui diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index a51f2dcf3e..a5065ce1b4 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -973,3 +973,22 @@ autolockTimeField: InputField(scheduleTimeField) { heightMin: 20px; } autolockTimeWidth: 52px; + +sponsoredInfoSkip: 22px; +sponsoredUrlButtonSkip: 11px; +sponsoredUrlButton: RoundButton(defaultActiveButton) { + height: 32px; + width: -42px; + textBg: transparent; + textBgOver: transparent; + radius: roundRadiusLarge; + padding: margins(2px, 2px, 2px, 2px); + textFg: historyLinkInFg; + textFgOver: historyLinkInFg; + textTop: 7px; + font: normalFont; + + ripple: RippleAnimation(defaultRippleAnimation) { + color: windowBgOver; + } +} diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 27a99404b4..e0115563ca 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -22,7 +22,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_cursor_state.h" #include "history/view/history_view_context_menu.h" #include "history/view/history_view_emoji_interactions.h" -#include "ui/chat/chat_theme.h" #include "ui/chat/chat_style.h" #include "ui/widgets/popup_menu.h" #include "ui/image/image.h" @@ -41,6 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_peer_menu.h" #include "window/window_controller.h" #include "window/notifications_manager.h" +#include "boxes/about_sponsored_box.h" #include "boxes/confirm_box.h" #include "boxes/sticker_set_box.h" #include "chat_helpers/message_field.h" @@ -1871,6 +1871,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } if (msg && view && !link && (view->hasVisibleText() || mediaHasTextForCopy)) { + if (item->isSponsored()) { + _menu->addAction(tr::lng_sponsored_title({}), [=] { + _controller->show(Box(Ui::AboutSponsoredBox)); + }); + } _menu->addAction(tr::lng_context_copy_text(tr::now), [=] { copyContextText(itemId); }); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 7182fad08a..1651470638 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 7182fad08a004b86697af27c971c16bb12c8b421 +Subproject commit 165147063811463505e0928160392488782b5201