From aa1117a7147fbe9fab4805ddb44fb8f5b519d905 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 28 Dec 2022 21:41:38 +0300 Subject: [PATCH] Added ability to sing up and sing in with anonymous numbers. --- Telegram/Resources/icons/fragment.png | Bin 0 -> 525 bytes Telegram/Resources/icons/fragment@2x.png | Bin 0 -> 1029 bytes Telegram/Resources/icons/fragment@3x.png | Bin 0 -> 1575 bytes Telegram/Resources/langs/lang.strings | 4 ++ Telegram/SourceFiles/boxes/boxes.style | 7 +++ Telegram/SourceFiles/intro/intro.style | 1 + Telegram/SourceFiles/intro/intro_code.cpp | 43 +++++++++++++-- Telegram/SourceFiles/intro/intro_code.h | 4 ++ Telegram/SourceFiles/intro/intro_step.cpp | 4 ++ Telegram/SourceFiles/intro/intro_step.h | 5 ++ Telegram/SourceFiles/intro/intro_widget.cpp | 58 +++++++++++++++----- Telegram/SourceFiles/intro/intro_widget.h | 2 + 12 files changed, 109 insertions(+), 19 deletions(-) create mode 100644 Telegram/Resources/icons/fragment.png create mode 100644 Telegram/Resources/icons/fragment@2x.png create mode 100644 Telegram/Resources/icons/fragment@3x.png diff --git a/Telegram/Resources/icons/fragment.png b/Telegram/Resources/icons/fragment.png new file mode 100644 index 0000000000000000000000000000000000000000..d56b3eaaca74eeeb4c6c2f688ee2731d5a59a6c9 GIT binary patch literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlgftlZPZF~maf z?IipDg9S3}EA2PldGs#E=@Q?eYn>CzFF3|`MCd9BzEp^7yLl+du*5(rS8QU*i=2Qj z?>y^I>R&Z^Q8fAem%pED-VR>F4`#&7;5@#cbL}HhXoZj za`LzN+7BlfXiPtC*!8t4H*(sJRHK=G%Qr`@t+~%HoxlBd(M}T{W(HOR!KU(EWxIKw zSKiAp%QlgE6t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IOS@*1{YhGe891g#|z472cARxQ| zcpWs5ON=okOQljgxY$6TnX)aNjIZ~TlM|Y$wY61v0ZM9Y+wWn}yk z&E;}+b#=lK0GFnJo?14JZDeo2-hjOUOE&Nal5*QDh<0Gy00000NkvXXu0mjf&;rkH literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/fragment@3x.png b/Telegram/Resources/icons/fragment@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..154c121c54649b9103ef4d75bc1569df2d69f81f GIT binary patch literal 1575 zcmV+?2H5$DP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91NT34%1ONa40RR91NB{r;0FW_8?*IS=kx4{BRA>e5SxYE=T@?R&ClQkJ zD3T~f%A1lDGC*M>&thO=AWBhQr6?maGBA)#gn<~yBLk#JdF34;6otHf->>iJwA%ab zbN4;>-v9O0IRmY=_FBK+T5Ion9?PFU#$|NC=z!4yqXR|nwky{4*vNy*WTV9>hbsY*HaG@5r&T!eW*IkR(z? z!rGoct5Z``N}^9sPyPM41q2-u zHXHckP+nfHMykTb#zsX&1@=c9#mmd9rlw|neO(O{3HXW5&CQjRl(@OMX=8#E)JTAb zLaN%a>?#_=qrh@?b=BJ1isu^}!08DI2}46e&(F_1&fVQzUteETR1_D)8bAa(kn$j~ zAW1gBtd863?d`2eI2d1EUIqpRVq#*<;@~G=QevEd z#a)il;|qvMS5id+@}Dgx&IwIIm2s}{x}>Vs2r|zGllVvgX_#EH%81+X{{FsXcc~k; zh!X4DF;H9dIFa2kWQLc3%F0T-fYK~wWE4r=7?m!GWRQXy35Xncy9I?Icx7d!x3`x^ z(Y7#^FsgQ}vIYR4e4t7Of@3n1UFqrRG$*JcPuKxPogFMQGgc<=w6rvu zA5_LcRV|x-QczB|_9!ZV7Z(?pv2ox(2IMVTV(b6`6k~L}Dw?sTrl!*5psHI$1wGSG zifcbvG-FLkNui`rX+4UpfBH$GiENvrr~u;sNp*E~1pG%t>eR@n$`S$*PThW;%+FYp zl9FhaP?;UGcKS)t?I-gy*2Kg_N(Yq|W}E3JCHPOaHj$XA}Sc002ovPDHLkV1iZ{)zAO{ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 5f642ad10..3f1ed5c03 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -323,6 +323,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_intro_qr_step3" = "Scan this image to Log In"; "lng_intro_qr_skip" = "Or log in using your phone number"; +"lng_intro_fragment_title" = "Enter code"; +"lng_intro_fragment_about" = "Get the code for {phone_number} in the Anonymous Numbers section on Fragment."; +"lng_intro_fragment_button" = "Open Fragment"; + "lng_phone_title" = "Your Phone Number"; "lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number."; "lng_phone_to_qr" = "Quick log in using QR code"; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 2710e2fe7..5f736325b 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -293,6 +293,13 @@ membersAbout: FlatLabel(defaultFlatLabel) { style: boxLabelStyle; } +fragmentBoxButton: RoundButton(introNextButton) { + width: 256px; + icon: icon {{ "fragment", activeButtonFg }}; + iconOver: icon {{ "fragment", activeButtonFgOver }}; + iconPosition: point(-10px, 9px); +} + passcodeHeaderFont: font(19px); passcodeHeaderHeight: 80px; passcodeInput: InputField(introPhone) { diff --git a/Telegram/SourceFiles/intro/intro.style b/Telegram/SourceFiles/intro/intro.style index c05508bc5..f6381e444 100644 --- a/Telegram/SourceFiles/intro/intro.style +++ b/Telegram/SourceFiles/intro/intro.style @@ -85,6 +85,7 @@ introCoverDuration: 200; introNextButton: RoundButton(defaultActiveButton) { width: 300px; height: 42px; + radius: 6px; textTop: 11px; font: font(boxFontSize semibold); } diff --git a/Telegram/SourceFiles/intro/intro_code.cpp b/Telegram/SourceFiles/intro/intro_code.cpp index 2932decb5..3d4eab1ac 100644 --- a/Telegram/SourceFiles/intro/intro_code.cpp +++ b/Telegram/SourceFiles/intro/intro_code.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "intro/intro_signup.h" #include "intro/intro_password_check.h" +#include "core/file_utilities.h" #include "core/update_checker.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" @@ -19,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_account.h" #include "mtproto/mtp_instance.h" #include "styles/style_intro.h" +#include "styles/style_boxes.h" namespace Intro { namespace details { @@ -99,7 +101,9 @@ CodeWidget::CodeWidget( _code->setDigitsCountMax(getData()->codeLength); - setTitleText(rpl::single(Ui::FormatPhone(getData()->phone))); + setTitleText(getData()->codeByFragmentUrl.isEmpty() + ? rpl::single(Ui::FormatPhone(getData()->phone)) + : tr::lng_intro_fragment_title()); updateDescText(); } @@ -117,10 +121,19 @@ int CodeWidget::errorTop() const { void CodeWidget::updateDescText() { const auto byTelegram = getData()->codeByTelegram; + const auto isFragment = !getData()->codeByFragmentUrl.isEmpty(); setDescriptionText( - (byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)( - Ui::Text::RichLangValue)); - if (getData()->codeByTelegram) { + isFragment + ? tr::lng_intro_fragment_about( + lt_phone_number, + rpl::single(TextWithEntities{ + .text = Ui::FormatPhone(getData()->phone) + }), + Ui::Text::RichLangValue) + : (byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)( + Ui::Text::RichLangValue)); + if (isFragment) { + } else if (getData()->codeByTelegram) { _noTelegramCode->show(); _callTimer.cancel(); } else { @@ -300,7 +313,7 @@ void CodeWidget::codeSubmitFail(const MTP::Error &error) { void CodeWidget::codeChanged() { hideError(); - submit(); + submitCode(); } void CodeWidget::sendCall() { @@ -362,6 +375,14 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) { } void CodeWidget::submit() { + if (getData()->codeByFragmentUrl.isEmpty()) { + submitCode(); + } else { + File::OpenUrl(getData()->codeByFragmentUrl); + } +} + +void CodeWidget::submitCode() { const auto text = QString( _code->getLastText() ).remove( @@ -393,6 +414,18 @@ void CodeWidget::submit() { }).handleFloodErrors().send(); } +rpl::producer CodeWidget::nextButtonText() const { + return getData()->codeByFragmentUrl.isEmpty() + ? Step::nextButtonText() + : tr::lng_intro_fragment_button(); +} + +const style::RoundButton *CodeWidget::nextButtonStyle() const { + return !getData()->codeByFragmentUrl.isEmpty() + ? &st::fragmentBoxButton + : nullptr; +} + void CodeWidget::noTelegramCode() { if (_noTelegramCodeRequestId) { return; diff --git a/Telegram/SourceFiles/intro/intro_code.h b/Telegram/SourceFiles/intro/intro_code.h index d267c477d..95ae597a1 100644 --- a/Telegram/SourceFiles/intro/intro_code.h +++ b/Telegram/SourceFiles/intro/intro_code.h @@ -55,6 +55,8 @@ public: void finished() override; void cancelled() override; void submit() override; + rpl::producer nextButtonText() const override; + const style::RoundButton *nextButtonStyle() const override; void updateDescText(); @@ -83,6 +85,8 @@ private: void noTelegramCodeDone(const MTPauth_SentCode &result); void noTelegramCodeFail(const MTP::Error &result); + void submitCode(); + void stopCheck(); object_ptr _noTelegramCode; diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index 9162775d1..68ff6b40f 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -119,6 +119,10 @@ rpl::producer Step::nextButtonText() const { return tr::lng_intro_next(); } +const style::RoundButton *Step::nextButtonStyle() const { + return nullptr; +} + void Step::goBack() { if (_goCallback) { _goCallback(nullptr, StackAction::Back, Animate::Back); diff --git a/Telegram/SourceFiles/intro/intro_step.h b/Telegram/SourceFiles/intro/intro_step.h index 2148e6e94..256396bf2 100644 --- a/Telegram/SourceFiles/intro/intro_step.h +++ b/Telegram/SourceFiles/intro/intro_step.h @@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "ui/effects/animations.h" +namespace style { +struct RoundButton; +} // namespace style; + namespace Main { class Account; } // namespace Main; @@ -77,6 +81,7 @@ public: virtual void submit() = 0; [[nodiscard]] virtual rpl::producer nextButtonText() const; + [[nodiscard]] virtual const style::RoundButton *nextButtonStyle() const; [[nodiscard]] int contentLeft() const; [[nodiscard]] int contentTop() const; diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index 6e1f427ad..e90cf82d0 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -74,6 +74,7 @@ Widget::Widget( : RpWidget(parent) , _account(account) , _data(details::Data{ .controller = controller }) +, _nextStyle(&st::introNextButton) , _back(this, object_ptr(this, st::introBackButton)) , _settings( this, @@ -83,7 +84,7 @@ Widget::Widget( st::defaultBoxButton)) , _next( this, - object_ptr(this, nullptr, st::introNextButton)) + object_ptr(this, nullptr, *_nextStyle)) , _connecting(std::make_unique( this, account, @@ -127,10 +128,6 @@ Widget::Widget( _back->entity()->setClickedCallback([=] { backRequested(); }); _back->hide(anim::type::instant); - _next->entity()->setClickedCallback([=] { getStep()->submit(); }); - _next->entity()->setTextTransform( - Ui::RoundButton::TextTransform::NoTransform); - if (_changeLanguage) { _changeLanguage->finishAnimating(); } @@ -344,13 +341,31 @@ void Widget::historyMove(StackAction action, Animate animate) { if (_terms) { hideAndDestroy(std::exchange(_terms, { nullptr })); } + { + const auto st = getStep()->nextButtonStyle(); + const auto nextStyle = st ? st : &st::introNextButton; + if (_nextStyle != nextStyle) { + _nextStyle = nextStyle; + _next = nullptr; + _next.create( + this, + object_ptr(this, nullptr, *nextStyle)); + showControls(); + updateControlsGeometry(); + } + } getStep()->finishInit(); getStep()->prepareShowAnimated(wasStep); if (wasStep->hasCover() != getStep()->hasCover()) { _nextTopFrom = wasStep->contentTop() + st::introNextTop; _controlsTopFrom = wasStep->hasCover() ? st::introCoverHeight : 0; - _coverShownAnimation.start([this] { updateControlsGeometry(); }, 0., 1., st::introCoverDuration, wasStep->hasCover() ? anim::linear : anim::easeOutCirc); + _coverShownAnimation.start( + [this] { updateControlsGeometry(); }, + 0., + 1., + st::introCoverDuration, + wasStep->hasCover() ? anim::linear : anim::easeOutCirc); } _stepLifetime.destroy(); @@ -665,6 +680,10 @@ void Widget::showControls() { } void Widget::setupNextButton() { + _next->entity()->setClickedCallback([=] { getStep()->submit(); }); + _next->entity()->setTextTransform( + Ui::RoundButton::TextTransform::NoTransform); + _next->entity()->setText(getStep()->nextButtonText( ) | rpl::filter([](const QString &text) { return !text.isEmpty(); @@ -757,13 +776,18 @@ void Widget::resizeEvent(QResizeEvent *e) { } void Widget::updateControlsGeometry() { - auto shown = _coverShownAnimation.value(1.); + const auto skip = st::introSettingsSkip; + const auto shown = _coverShownAnimation.value(1.); - auto controlsTopTo = getStep()->hasCover() ? st::introCoverHeight : 0; - auto controlsTop = anim::interpolate(_controlsTopFrom, controlsTopTo, shown); - _settings->moveToRight(st::introSettingsSkip, controlsTop + st::introSettingsSkip); + const auto controlsTop = anim::interpolate( + _controlsTopFrom, + getStep()->hasCover() ? st::introCoverHeight : 0, + shown); + _settings->moveToRight(skip, controlsTop + skip); if (_update) { - _update->moveToRight(st::introSettingsSkip + _settings->width() + st::introSettingsSkip, _settings->y()); + _update->moveToRight( + skip + _settings->width() + skip, + _settings->y()); } _back->moveToLeft(0, controlsTop); @@ -779,13 +803,19 @@ void Widget::updateControlsGeometry() { ? QRect(0, 0, width(), realNextTop) : QRect()); if (_changeLanguage) { - _changeLanguage->moveToLeft((width() - _changeLanguage->width()) / 2, _next->y() + _next->height() + _changeLanguage->height()); + _changeLanguage->moveToLeft( + (width() - _changeLanguage->width()) / 2, + _next->y() + _next->height() + _changeLanguage->height()); } if (_resetAccount) { - _resetAccount->moveToLeft((width() - _resetAccount->width()) / 2, height() - st::introResetBottom - _resetAccount->height()); + _resetAccount->moveToLeft( + (width() - _resetAccount->width()) / 2, + height() - st::introResetBottom - _resetAccount->height()); } if (_terms) { - _terms->moveToLeft((width() - _terms->width()) / 2, height() - st::introTermsBottom - _terms->height()); + _terms->moveToLeft( + (width() - _terms->width()) / 2, + height() - st::introTermsBottom - _terms->height()); } } diff --git a/Telegram/SourceFiles/intro/intro_widget.h b/Telegram/SourceFiles/intro/intro_widget.h index e40d914c9..ef224b831 100644 --- a/Telegram/SourceFiles/intro/intro_widget.h +++ b/Telegram/SourceFiles/intro/intro_widget.h @@ -186,6 +186,8 @@ private: int _nextTopFrom = 0; int _controlsTopFrom = 0; + const style::RoundButton *_nextStyle = nullptr; + object_ptr> _back; object_ptr> _update = { nullptr }; object_ptr> _settings;