Added animation of send action for stickers to middle of text.

This commit is contained in:
23rd
2021-08-30 20:38:11 +03:00
parent 8c17e3e578
commit 436212bb88
8 changed files with 93 additions and 9 deletions

View File

@@ -303,6 +303,7 @@ void Instance::reset(const Language &data) {
_values[i] = GetOriginalValue(ushort(i));
}
ranges::fill(_nonDefaultSet, 0);
updateSupportChoosingStickerReplacement();
_idChanges.fire_copy(_id);
}
@@ -548,6 +549,7 @@ void Instance::fillFromSerialized(
applyValue(nonDefaultStrings[i], nonDefaultStrings[i + 1]);
}
updatePluralRules();
updateSupportChoosingStickerReplacement();
_idChanges.fire_copy(_id);
}
@@ -572,6 +574,7 @@ void Instance::fillFromCustomContent(
_pluralId = PluralCodeForCustom(absolutePath, relativePath);
_name = _nativeName = QString();
loadFromCustomContent(absolutePath, relativePath, content);
updateSupportChoosingStickerReplacement();
_idChanges.fire_copy(_id);
}
@@ -602,6 +605,20 @@ bool Instance::loadFromCustomFile(const QString &filePath) {
return false;
}
void Instance::updateSupportChoosingStickerReplacement() {
// A language changing in the runtime is not supported.
const auto phrase = tr::lng_send_action_choose_sticker(tr::now);
const auto first = phrase.indexOf(kChoosingStickerReplacement.utf8());
const auto last = phrase.lastIndexOf(kChoosingStickerReplacement.utf8());
_supportChoosingStickerReplacement = (first == last)
? (first != -1)
: false;
}
bool Instance::supportChoosingStickerReplacement() const {
return _supportChoosingStickerReplacement;
}
// SetCallback takes two QByteArrays: key, value.
// It is called for all key-value pairs in string.
// ResetCallback takes one QByteArray: key.

View File

@@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Lang {
inline constexpr auto kChoosingStickerReplacement = "oo"_cs;
struct Language {
QString id;
QString pluralId;
@@ -74,6 +76,8 @@ public:
QByteArray serialize() const;
void fillFromSerialized(const QByteArray &data, int dataAppVersion);
bool supportChoosingStickerReplacement() const;
void applyDifference(
Pack pack,
const MTPDlangPackDifference &difference);
@@ -120,6 +124,7 @@ private:
const QString &relativePath,
const QByteArray &content);
void updatePluralRules();
void updateSupportChoosingStickerReplacement();
Instance *_derived = nullptr;
@@ -132,6 +137,8 @@ private:
int _version = 0;
rpl::event_stream<> _updated;
bool _supportChoosingStickerReplacement;
mutable QString _systemLanguage;
std::vector<QString> _values;