From 23b39923ad4b4ebcfd201ba0ad3e394f0ce37dfa Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 Mar 2017 18:00:59 +0300 Subject: [PATCH] Closed beta 1000018002: more phrases for payments. Also replacing the Buy keyboard button with Receipt if the invoice was payed already (like in mobile apps). This required to move the inline markup apply before the media apply in message editing. --- Telegram/Resources/langs/lang.strings | 5 +++++ Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 2 +- .../history/history_media_types.cpp | 17 ++++++++++++++--- .../SourceFiles/history/history_media_types.h | 9 +++++++-- .../SourceFiles/history/history_message.cpp | 18 ++++++++++++++++-- Telegram/SourceFiles/history/history_message.h | 4 ++++ Telegram/build/version | 2 +- 10 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f25966002..7dfb2f986 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1105,6 +1105,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_theme_editor_export_button" = "Export theme"; "lng_payments_not_supported" = "Sorry, Telegram Desktop doesn't support payments yet. Please use one of our mobile apps to do this."; +"lng_payments_receipt_label" = "Receipt"; +"lng_payments_receipt_label_test" = "Test receipt"; +"lng_payments_invoice_label" = "Invoice"; +"lng_payments_invoice_label_test" = "Test invoice"; +"lng_payments_receipt_button" = "Receipt"; // Not used diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 48431a041..2b582482f 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="1.0.18.2" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 8c5cfcd83..38e069277 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,18,1 - PRODUCTVERSION 1,0,18,1 + FILEVERSION 1,0,18,2 + PRODUCTVERSION 1,0,18,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -52,10 +52,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "1.0.18.1" + VALUE "FileVersion", "1.0.18.2" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.18.1" + VALUE "ProductVersion", "1.0.18.2" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index b264a66fe..b5cac656e 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,18,1 - PRODUCTVERSION 1,0,18,1 + FILEVERSION 1,0,18,2 + PRODUCTVERSION 1,0,18,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "1.0.18.1" + VALUE "FileVersion", "1.0.18.2" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.18.1" + VALUE "ProductVersion", "1.0.18.2" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index a0b350cb2..a1ba6c665 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "core/utils.h" -#define BETA_VERSION_MACRO (1000018001ULL) +#define BETA_VERSION_MACRO (1000018002ULL) constexpr int AppVersion = 1000018; constexpr str_const AppVersionStr = "1.0.18"; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index e8474da9d..ae560f86a 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -3482,13 +3482,24 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) { } } + auto labelText = [&data] { + if (data.has_receipt_msg_id()) { + if (data.is_test()) { + return lang(lng_payments_receipt_label_test); + } + return lang(lng_payments_receipt_label); + } else if (data.is_test()) { + return lang(lng_payments_invoice_label_test); + } + return lang(lng_payments_invoice_label); + }; auto statusText = TextWithEntities { fillAmountAndCurrency(data.vtotal_amount.v, qs(data.vcurrency)), EntitiesInText() }; statusText.entities.push_back(EntityInText(EntityInTextBold, 0, statusText.text.size())); - if (data.is_test()) { - statusText.text += " TEST"; - } + statusText.text += ' ' + labelText().toUpper(); _status.setMarkedText(st::defaultTextStyle, statusText, itemTextOptions(_parent)); + _receiptMsgId = data.has_receipt_msg_id() ? data.vreceipt_msg_id.v : 0; + // init strings auto description = qs(data.vdescription); if (!description.isEmpty()) { diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index be472a330..933701eb5 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -885,6 +885,9 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; + MsgId getReceiptMsgId() const { + return _receiptMsgId; + } QString getTitle() const { return _title.originalText(); } @@ -946,12 +949,14 @@ private: std::unique_ptr _attach; - int _titleHeight; - int _descriptionHeight; + int _titleHeight = 0; + int _descriptionHeight = 0; Text _title; Text _description; Text _status; + MsgId _receiptMsgId = 0; + }; class LocationCoords; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index db1ebace0..bbf98a9ce 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -568,7 +568,6 @@ bool HistoryMessage::displayEditedBadge(bool hasViaBotOrInlineMarkup) const { return true; } - void HistoryMessage::createComponents(const CreateConfig &config) { uint64 mask = 0; if (config.replyTo) { @@ -729,10 +728,25 @@ void HistoryMessage::initMedia(const MTPMessageMedia *media) { } break; case mtpc_messageMediaInvoice: { _media = std::make_unique(this, media->c_messageMediaInvoice()); + if (static_cast(getMedia())->getReceiptMsgId()) { + replaceBuyWithReceiptInMarkup(); + } } break; }; } +void HistoryMessage::replaceBuyWithReceiptInMarkup() { + if (auto markup = inlineReplyMarkup()) { + for (auto &row : markup->rows) { + for (auto &button : row) { + if (button.type == HistoryMessageReplyMarkup::Button::Type::Buy) { + button.text = lang(lng_payments_receipt_button); + } + } + } + } +} + void HistoryMessage::initMediaFromDocument(DocumentData *doc, const QString &caption) { if (doc->sticker()) { _media = std::make_unique(this, doc); @@ -901,8 +915,8 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) { textWithEntities.entities = entitiesFromMTP(message.ventities.v); } setText(textWithEntities); - setMedia(message.has_media() ? (&message.vmedia) : nullptr); setReplyMarkup(message.has_reply_markup() ? (&message.vreply_markup) : nullptr); + setMedia(message.has_media() ? (&message.vmedia) : nullptr); setViewsCount(message.has_views() ? message.vviews.v : -1); finishEdition(keyboardTop); diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h index 540a13c49..ab1cf03b4 100644 --- a/Telegram/SourceFiles/history/history_message.h +++ b/Telegram/SourceFiles/history/history_message.h @@ -156,6 +156,10 @@ private: void setEmptyText(); + // For an invoice button we replace the button text with a "Receipt" key. + // It should show the receipt for the payed invoice. Still let mobile apps do that. + void replaceBuyWithReceiptInMarkup(); + void initDimensions() override; int resizeGetHeight_(int width) override; int performResizeGetHeight(int width); diff --git a/Telegram/build/version b/Telegram/build/version index 738a045fb..d838568da 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -3,4 +3,4 @@ AppVersionStrMajor 1.0 AppVersionStrSmall 1.0.18 AppVersionStr 1.0.18 AlphaChannel 0 -BetaVersion 1000018001 +BetaVersion 1000018002