Remove old implementation of get_theme_parameters_json_string.
This commit is contained in:
parent
c6928a9cb6
commit
63c7d03018
@ -84,7 +84,7 @@ class RequestAppWebViewQuery final : public Td::ResultHandler {
|
|||||||
flags |= telegram_api::messages_requestAppWebView::THEME_PARAMS_MASK;
|
flags |= telegram_api::messages_requestAppWebView::THEME_PARAMS_MASK;
|
||||||
|
|
||||||
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
||||||
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme, false);
|
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme);
|
||||||
}
|
}
|
||||||
if (allow_write_access) {
|
if (allow_write_access) {
|
||||||
flags |= telegram_api::messages_requestAppWebView::WRITE_ALLOWED_MASK;
|
flags |= telegram_api::messages_requestAppWebView::WRITE_ALLOWED_MASK;
|
||||||
@ -165,7 +165,7 @@ class RequestWebViewQuery final : public Td::ResultHandler {
|
|||||||
tl_object_ptr<telegram_api::dataJSON> theme_parameters;
|
tl_object_ptr<telegram_api::dataJSON> theme_parameters;
|
||||||
if (theme != nullptr) {
|
if (theme != nullptr) {
|
||||||
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
||||||
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme, false);
|
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme);
|
||||||
|
|
||||||
flags |= telegram_api::messages_requestWebView::THEME_PARAMS_MASK;
|
flags |= telegram_api::messages_requestWebView::THEME_PARAMS_MASK;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class RequestSimpleWebViewQuery final : public Td::ResultHandler {
|
|||||||
flags |= telegram_api::messages_requestSimpleWebView::THEME_PARAMS_MASK;
|
flags |= telegram_api::messages_requestSimpleWebView::THEME_PARAMS_MASK;
|
||||||
|
|
||||||
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
||||||
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme, false);
|
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme);
|
||||||
}
|
}
|
||||||
string start_parameter;
|
string start_parameter;
|
||||||
if (ends_with(url, "#kb")) {
|
if (ends_with(url, "#kb")) {
|
||||||
|
@ -989,7 +989,7 @@ void get_payment_form(Td *td, td_api::object_ptr<td_api::InputInvoice> &&input_i
|
|||||||
tl_object_ptr<telegram_api::dataJSON> theme_parameters;
|
tl_object_ptr<telegram_api::dataJSON> theme_parameters;
|
||||||
if (theme != nullptr) {
|
if (theme != nullptr) {
|
||||||
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
||||||
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme, false);
|
theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme);
|
||||||
}
|
}
|
||||||
td->create_handler<GetPaymentFormQuery>(std::move(promise))
|
td->create_handler<GetPaymentFormQuery>(std::move(promise))
|
||||||
->send(std::move(input_invoice_info), std::move(theme_parameters));
|
->send(std::move(input_invoice_info), std::move(theme_parameters));
|
||||||
|
@ -10016,7 +10016,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getJsonSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getThemeParametersJsonString &request) {
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getThemeParametersJsonString &request) {
|
||||||
return td_api::make_object<td_api::text>(ThemeManager::get_theme_parameters_json_string(request.theme_, true));
|
return td_api::make_object<td_api::text>(ThemeManager::get_theme_parameters_json_string(request.theme_));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::setLogStream &request) {
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::setLogStream &request) {
|
||||||
|
@ -622,34 +622,18 @@ bool ThemeManager::on_update_profile_accent_colors(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
string ThemeManager::get_theme_parameters_json_string(const td_api::object_ptr<td_api::themeParameters> &theme) {
|
||||||
template <bool for_web_view>
|
|
||||||
static auto get_color_json(int32 color);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
auto get_color_json<false>(int32 color) {
|
|
||||||
return static_cast<int64>(static_cast<uint32>(color) | 0xFF000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
auto get_color_json<true>(int32 color) {
|
|
||||||
string res(7, '#');
|
|
||||||
const char *hex = "0123456789abcdef";
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
int32 num = (color >> (i * 8)) & 0xFF;
|
|
||||||
res[2 * i + 1] = hex[num >> 4];
|
|
||||||
res[2 * i + 2] = hex[num & 15];
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <bool for_web_view>
|
|
||||||
string get_theme_parameters_json_string_impl(const td_api::object_ptr<td_api::themeParameters> &theme) {
|
|
||||||
if (for_web_view && theme == nullptr) {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
return json_encode<string>(json_object([&theme](auto &o) {
|
return json_encode<string>(json_object([&theme](auto &o) {
|
||||||
auto get_color = &get_color_json<for_web_view>;
|
auto get_color = [](int32 color) {
|
||||||
|
string res(7, '#');
|
||||||
|
const char *hex = "0123456789abcdef";
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
int32 num = (color >> (i * 8)) & 0xFF;
|
||||||
|
res[2 * i + 1] = hex[num >> 4];
|
||||||
|
res[2 * i + 2] = hex[num & 15];
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
o("bg_color", get_color(theme->background_color_));
|
o("bg_color", get_color(theme->background_color_));
|
||||||
o("secondary_bg_color", get_color(theme->secondary_background_color_));
|
o("secondary_bg_color", get_color(theme->secondary_background_color_));
|
||||||
o("text_color", get_color(theme->text_color_));
|
o("text_color", get_color(theme->text_color_));
|
||||||
@ -665,16 +649,6 @@ string get_theme_parameters_json_string_impl(const td_api::object_ptr<td_api::th
|
|||||||
o("destructive_text_color", get_color(theme->destructive_text_color_));
|
o("destructive_text_color", get_color(theme->destructive_text_color_));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
|
||||||
string ThemeManager::get_theme_parameters_json_string(const td_api::object_ptr<td_api::themeParameters> &theme,
|
|
||||||
bool for_web_view) {
|
|
||||||
if (for_web_view) {
|
|
||||||
return get_theme_parameters_json_string_impl<true>(theme);
|
|
||||||
} else {
|
|
||||||
return get_theme_parameters_json_string_impl<false>(theme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 ThemeManager::get_accent_color_id_object(AccentColorId accent_color_id,
|
int32 ThemeManager::get_accent_color_id_object(AccentColorId accent_color_id,
|
||||||
AccentColorId fallback_accent_color_id) const {
|
AccentColorId fallback_accent_color_id) const {
|
||||||
|
@ -36,8 +36,7 @@ class ThemeManager final : public Actor {
|
|||||||
|
|
||||||
void reload_profile_accent_colors();
|
void reload_profile_accent_colors();
|
||||||
|
|
||||||
static string get_theme_parameters_json_string(const td_api::object_ptr<td_api::themeParameters> &theme,
|
static string get_theme_parameters_json_string(const td_api::object_ptr<td_api::themeParameters> &theme);
|
||||||
bool for_web_view);
|
|
||||||
|
|
||||||
int32 get_accent_color_id_object(AccentColorId accent_color_id,
|
int32 get_accent_color_id_object(AccentColorId accent_color_id,
|
||||||
AccentColorId fallback_accent_color_id = AccentColorId()) const;
|
AccentColorId fallback_accent_color_id = AccentColorId()) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user